diff options
Diffstat (limited to 'gcc/testsuite/c-c++-common')
102 files changed, 1032 insertions, 248 deletions
diff --git a/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-2a.c b/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-2a.c index cf014b0..175d9c3 100644 --- a/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-2a.c +++ b/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-2a.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-fanalyzer-verbosity=2" } */ +/* { dg-additional-options "-fanalyzer-verbosity=2 -fno-exceptions" } */ typedef struct FILE FILE; diff --git a/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-3a.c b/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-3a.c index b0ece20..8d66c8f 100644 --- a/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-3a.c +++ b/gcc/testsuite/c-c++-common/analyzer/analyzer-verbosity-3a.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-fanalyzer-verbosity=3" } */ +/* { dg-additional-options "-fanalyzer-verbosity=3 -fno-exceptions" } */ typedef struct FILE FILE; diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-const-2.c b/gcc/testsuite/c-c++-common/analyzer/attr-const-2.c index ab79514..5329a89 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-const-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-const-2.c @@ -1,5 +1,5 @@ extern int const_p (int) __attribute__((const)); -extern void do_stuff (void); +extern void do_stuff (void) __attribute__((nothrow)); void test (int a) { diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-4.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-4.c index 1517667..1e2e1f9 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-4.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-4.c @@ -2,7 +2,7 @@ struct foo; extern void foo_release (struct foo *) - __attribute__((nonnull)); + __attribute__((nonnull, nothrow)); extern struct foo *foo_acquire (void) __attribute__ ((malloc (foo_release))); diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-5.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-5.c index 7ff4e57..8b7ffc1 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-5.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-5.c @@ -1,7 +1,7 @@ /* Example of extra argument to "malloc" attribute. */ struct foo; -extern void foo_release (int, struct foo *); +extern void foo_release (int, struct foo *) __attribute__((nothrow)); extern struct foo *foo_acquire (void) __attribute__ ((malloc (foo_release, 2))); diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-6.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-6.c index 1665d41..45ee406f 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-6.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-6.c @@ -1,4 +1,5 @@ /* Adapted from gcc.dg/Wmismatched-dealloc.c. */ +/* { dg-additional-options "-fno-exceptions" } */ #define A(...) __attribute__ ((malloc (__VA_ARGS__))) diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c index 87ad42a..fd51630 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c @@ -1,6 +1,8 @@ /* Adapted from linux 5.3.11: drivers/net/wireless/ath/ath10k/usb.c Reduced reproducer for CVE-2019-19078 (leak of struct urb). */ +/* { dg-additional-options "-fno-exceptions" } */ + typedef unsigned char u8; typedef unsigned short u16; diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-exception.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-exception.c new file mode 100644 index 0000000..9f5e2e8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-exception.c @@ -0,0 +1,17 @@ +/* { dg-additional-options "-fexceptions" } */ + +extern void free (void *); + +/* Not marked "nothrow", so assume it could throw. */ +char *xstrdup (const char *) + __attribute__((malloc (free), returns_nonnull)); + +void test_1 (const char *s, const char *t) +{ + char *p = xstrdup (s); /* { dg-message "allocated here" } */ + char *q = xstrdup (t); /* { dg-warning "leak of 'p'" } */ + /* { dg-message "if .* throws an exception\.\.\." "" { target *-*-* } .-1 } */ + + free (q); + free (p); +} diff --git a/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158-2.c b/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158-2.c index b395623..a15ab65 100644 --- a/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158-2.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-fanalyzer-call-summaries -Wno-analyzer-too-complex -Wno-analyzer-symbol-too-complex" } */ +/* { dg-additional-options "-fanalyzer-call-summaries -Wno-analyzer-too-complex -Wno-analyzer-symbol-too-complex -fno-exceptions" } */ /* { dg-skip-if "c++98 has no noreturn attribute" { c++98_only } } */ #ifdef __cplusplus diff --git a/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158.c b/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158.c index de70583..6fbbce4 100644 --- a/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158.c +++ b/gcc/testsuite/c-c++-common/analyzer/call-summaries-pr107158.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-fanalyzer-call-summaries -Wno-analyzer-symbol-too-complex" } */ +/* { dg-additional-options "-fanalyzer-call-summaries -Wno-analyzer-symbol-too-complex -fno-exceptions" } */ typedef __SIZE_TYPE__ size_t; enum { _ISspace = ((5) < 8 ? ((1 << (5)) << 8) : ((1 << (5)) >> 8)) }; diff --git a/gcc/testsuite/c-c++-common/analyzer/capacity-2.c b/gcc/testsuite/c-c++-common/analyzer/capacity-2.c index 7d2de4e..3846239 100644 --- a/gcc/testsuite/c-c++-common/analyzer/capacity-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/capacity-2.c @@ -1,5 +1,6 @@ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-skip-if "requires hosted libstdc++ for stdlib size_t" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/coreutils-sum-pr108666.c b/gcc/testsuite/c-c++-common/analyzer/coreutils-sum-pr108666.c index c41b61d..95091e7 100644 --- a/gcc/testsuite/c-c++-common/analyzer/coreutils-sum-pr108666.c +++ b/gcc/testsuite/c-c++-common/analyzer/coreutils-sum-pr108666.c @@ -1,5 +1,7 @@ /* Reduced from coreutils's sum.c: bsd_sum_stream */ +/* { dg-additional-options "-fno-exceptions" } */ + typedef __SIZE_TYPE__ size_t; typedef unsigned char __uint8_t; typedef unsigned long int __uintmax_t; diff --git a/gcc/testsuite/c-c++-common/analyzer/data-model-22.c b/gcc/testsuite/c-c++-common/analyzer/data-model-22.c index 8429b2f..65bf346 100644 --- a/gcc/testsuite/c-c++-common/analyzer/data-model-22.c +++ b/gcc/testsuite/c-c++-common/analyzer/data-model-22.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + #include <string.h> #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/data-model-5d.c b/gcc/testsuite/c-c++-common/analyzer/data-model-5d.c index a86d506..bb45917 100644 --- a/gcc/testsuite/c-c++-common/analyzer/data-model-5d.c +++ b/gcc/testsuite/c-c++-common/analyzer/data-model-5d.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ /* A toy re-implementation of CPython's object model. */ diff --git a/gcc/testsuite/c-c++-common/analyzer/data-model-path-1.c b/gcc/testsuite/c-c++-common/analyzer/data-model-path-1.c index d7058ea..0609dc8 100644 --- a/gcc/testsuite/c-c++-common/analyzer/data-model-path-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/data-model-path-1.c @@ -3,7 +3,7 @@ static int *__attribute__((noinline)) callee (void) { - return NULL; + return NULL; /* { dg-message "using NULL here" } */ } void test_1 (void) diff --git a/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c b/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c index 7431bd1..b790997 100644 --- a/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c +++ b/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c @@ -1,4 +1,5 @@ /* Reduced from git-2.39.0's pack-revindex.c */ +/* { dg-additional-options "-fno-exceptions" } */ typedef unsigned int __uint32_t; typedef unsigned long int __uintmax_t; diff --git a/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c b/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c index 7123cf5..a7f8049 100644 --- a/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c +++ b/gcc/testsuite/c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c @@ -1,6 +1,7 @@ /* Reduced from haproxy-2.7.1: src/tcpcheck.c. */ /* { dg-additional-options "-Wno-analyzer-too-complex" } */ +/* { dg-additional-options "-fno-exceptions" } */ typedef __SIZE_TYPE__ size_t; diff --git a/gcc/testsuite/c-c++-common/analyzer/edges-2.c b/gcc/testsuite/c-c++-common/analyzer/edges-2.c index 7e4543c..df4bfaa 100644 --- a/gcc/testsuite/c-c++-common/analyzer/edges-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/edges-2.c @@ -1,5 +1,7 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ + #include <stdlib.h> int foo (); diff --git a/gcc/testsuite/c-c++-common/analyzer/fd-2.c b/gcc/testsuite/c-c++-common/analyzer/fd-2.c index 10c9ecd..b6b0a57 100644 --- a/gcc/testsuite/c-c++-common/analyzer/fd-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/fd-2.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + int open(const char *, int mode); void close(int fd); #define O_RDONLY 0 @@ -61,4 +63,4 @@ test_5 (const char *path, mode_t mode) int fd = creat (path, mode); close(fd); close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" "warning" } */ -}
\ No newline at end of file +} diff --git a/gcc/testsuite/c-c++-common/analyzer/fd-3.c b/gcc/testsuite/c-c++-common/analyzer/fd-3.c index 8e71b14..4894b64 100644 --- a/gcc/testsuite/c-c++-common/analyzer/fd-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/fd-3.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + int open(const char *, int mode); void close(int fd); int write (int fd, void *buf, int nbytes); diff --git a/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c b/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c index fd57d3b..2a44e45 100644 --- a/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c +++ b/gcc/testsuite/c-c++-common/analyzer/fd-glibc-byte-stream-socket.c @@ -5,6 +5,8 @@ /* { dg-additional-options "-fno-exceptions" } */ /* { dg-skip-if "" { hppa*-*-hpux* powerpc*-*-aix* } } */ +/* On vxworks, netinet/in.h indirectly includes atomic, that requires C++11. */ +/* { dg-skip-if "" { *-*-vxworks* && { c++ && { ! c++11 } } } } */ #include <stdio.h> #include <string.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/fd-meaning.c b/gcc/testsuite/c-c++-common/analyzer/fd-meaning.c index 6a9ec92..bd0d458a 100644 --- a/gcc/testsuite/c-c++-common/analyzer/fd-meaning.c +++ b/gcc/testsuite/c-c++-common/analyzer/fd-meaning.c @@ -1,4 +1,5 @@ - /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */ +/* { dg-additional-options "-fno-exceptions" } */ +/* { dg-additional-options "-fanalyzer-verbose-state-changes" } */ int open(const char *, int mode); void close(int fd); @@ -34,4 +35,4 @@ void test_3 (const char* path) close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */ close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */ } -}
\ No newline at end of file +} diff --git a/gcc/testsuite/c-c++-common/analyzer/file-1.c b/gcc/testsuite/c-c++-common/analyzer/file-1.c index 316cbb3..e87cf73 100644 --- a/gcc/testsuite/c-c++-common/analyzer/file-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/file-1.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + typedef struct FILE FILE; FILE* fopen (const char*, const char*); diff --git a/gcc/testsuite/c-c++-common/analyzer/file-3.c b/gcc/testsuite/c-c++-common/analyzer/file-3.c index 8f93a98..ca992bf 100644 --- a/gcc/testsuite/c-c++-common/analyzer/file-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/file-3.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + typedef struct _IO_FILE FILE; extern struct _IO_FILE *stderr; diff --git a/gcc/testsuite/c-c++-common/analyzer/file-meaning-1.c b/gcc/testsuite/c-c++-common/analyzer/file-meaning-1.c index 66b72a7..c9aee5e 100644 --- a/gcc/testsuite/c-c++-common/analyzer/file-meaning-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/file-meaning-1.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fno-exceptions" } */ /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */ typedef struct FILE FILE; diff --git a/gcc/testsuite/c-c++-common/analyzer/hard-reg-1.c b/gcc/testsuite/c-c++-common/analyzer/hard-reg-1.c new file mode 100644 index 0000000..d22a5b5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/hard-reg-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target x86_64-*-* } } */ + +void * +get_from_hard_reg (void) +{ + register void *sp asm ("sp"); + return sp; +} diff --git a/gcc/testsuite/c-c++-common/analyzer/infinite-recursion.c b/gcc/testsuite/c-c++-common/analyzer/infinite-recursion.c index 6b7d25c..bbbb68e 100644 --- a/gcc/testsuite/c-c++-common/analyzer/infinite-recursion.c +++ b/gcc/testsuite/c-c++-common/analyzer/infinite-recursion.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + extern void marker_A(void); extern void marker_B(void); extern void marker_C(void); diff --git a/gcc/testsuite/c-c++-common/analyzer/leak-3.c b/gcc/testsuite/c-c++-common/analyzer/leak-3.c index a386d88..19d7501 100644 --- a/gcc/testsuite/c-c++-common/analyzer/leak-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/leak-3.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-dedupe-1.c b/gcc/testsuite/c-c++-common/analyzer/malloc-dedupe-1.c index 8653c67..c296061 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-dedupe-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-dedupe-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-in-loop.c b/gcc/testsuite/c-c++-common/analyzer/malloc-in-loop.c index e7179f0..0d86801 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-in-loop.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-in-loop.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> #include "../../gcc.dg/analyzer/analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-many-paths-3.c b/gcc/testsuite/c-c++-common/analyzer/malloc-many-paths-3.c index 6ee30f3..5daa696 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-many-paths-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-many-paths-3.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-5.c b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-5.c index f03f978..4a1870d 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-5.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-5.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdio.h> #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-7.c b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-7.c index 766bbe7..12b93b2 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-7.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-7.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-8.c b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-8.c index 77e3e02..8af84ed 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-paths-8.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-paths-8.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fno-exceptions" } */ /* { dg-additional-options "-fanalyzer-transitivity" } */ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-1a.c b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-1a.c index 4e40833..ffb0ffe 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-1a.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-1a.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fno-exceptions" } */ /* { dg-additional-options "-fno-analyzer-call-summaries -fanalyzer-transitivity" } */ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-2.c b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-2.c index 36ec510..052b401 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-2.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-3.c b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-3.c index 70b3edd..258706c 100644 --- a/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/malloc-vs-local-3.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c index c5f1fa4..4f04e46 100644 --- a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c +++ b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c @@ -66,7 +66,7 @@ static inline struct connection *__objt_conn(enum obj_type *t) static inline struct connection *objt_conn(enum obj_type *t) { if (!t || *t != OBJ_TYPE_CONN) - return (struct connection *) ((void *)0); + return (struct connection *) ((void *)0); /* { dg-message "using NULL here" } */ return __objt_conn(t); } struct session { @@ -85,7 +85,7 @@ smp_fetch_ssl_fc_has_early(const struct arg *args, struct sample *smp, const cha SSL *ssl; struct connection *conn; - conn = objt_conn(smp->sess->origin); + conn = objt_conn(smp->sess->origin); /* { dg-message "return of NULL" } */ ssl = ssl_sock_get_ssl_object(conn); if (!ssl) return 0; diff --git a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c index 9dcf7aa..0ebeeff 100644 --- a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c +++ b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c @@ -60,7 +60,7 @@ void WuExpireSessionKey(WEBUI *wu) for(i=0; i<LIST_NUM(wu->Contexts); i++) { - STRMAP_ENTRY *entry = (STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i); + STRMAP_ENTRY *entry = (STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i); /* { dg-message "'entry' is NULL" } */ WU_CONTEXT *context = (WU_CONTEXT*)entry->Value; /* { dg-bogus "dereference of NULL 'entry'" "PR analyzer/108400" { xfail *-*-* } } */ if(context->ExpireDate < Tick64()) { diff --git a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c b/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c deleted file mode 100644 index 0a2cc34..0000000 --- a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-json.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-additional-options "-fdiagnostics-format=json-file" } */ - -/* The custom JSON format doesn't support text art, so this is just a simple - smoketext. */ - -#include <stdint.h> - -int32_t arr[10]; - -void int_arr_write_element_after_end_off_by_one(int32_t x) -{ - arr[10] = x; -} diff --git a/gcc/testsuite/c-c++-common/analyzer/paths-7.c b/gcc/testsuite/c-c++-common/analyzer/paths-7.c index 2743de5..f7c5cbf 100644 --- a/gcc/testsuite/c-c++-common/analyzer/paths-7.c +++ b/gcc/testsuite/c-c++-common/analyzer/paths-7.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/pr110830.c b/gcc/testsuite/c-c++-common/analyzer/pr110830.c index f5a39b7..ebfd38d 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr110830.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr110830.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + typedef __SIZE_TYPE__ size_t; void free(void *); diff --git a/gcc/testsuite/c-c++-common/analyzer/pr93032-mztools-simplified.c b/gcc/testsuite/c-c++-common/analyzer/pr93032-mztools-simplified.c index 4a08f0f1..e389e43 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr93032-mztools-simplified.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr93032-mztools-simplified.c @@ -1,4 +1,5 @@ /* { dg-do "compile" } */ +/* { dg-additional-options "-fno-exceptions" } */ /* Minimal replacement of system headers. */ #define NULL ((void *) 0) diff --git a/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-feasibility-3.c b/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-feasibility-3.c index 50d3388..19a3023 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-feasibility-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-feasibility-3.c @@ -3,6 +3,7 @@ Adapted from intl/localealias.c, with all #includes removed. */ /* { dg-do "compile" } */ +/* { dg-additional-options "-fno-exceptions" } */ /* Handle aliases for locale names. Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. diff --git a/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-simplified.c b/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-simplified.c index 6f65add..45517468 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-simplified.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr93355-localealias-simplified.c @@ -3,6 +3,7 @@ Adapted from intl/localealias.c, with all #includes removed. */ /* { dg-do "compile" } */ +/* { dg-additional-options "-fno-exceptions" } */ /* Handle aliases for locale names. Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. diff --git a/gcc/testsuite/c-c++-common/analyzer/pr96650-1-trans.c b/gcc/testsuite/c-c++-common/analyzer/pr96650-1-trans.c index b20630b..fb194ad 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr96650-1-trans.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr96650-1-trans.c @@ -1,4 +1,5 @@ /* { dg-additional-options "-O2 -fanalyzer-transitivity" } */ +/* { dg-additional-options "-fno-exceptions" } */ int *wf; diff --git a/gcc/testsuite/c-c++-common/analyzer/pr97072.c b/gcc/testsuite/c-c++-common/analyzer/pr97072.c index 4024124..82411a1 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr97072.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr97072.c @@ -1,4 +1,4 @@ -void unknown_fn_1 (void *); +void unknown_fn_1 (void *) __attribute__((nothrow)); void test_1 (int co, int y) { diff --git a/gcc/testsuite/c-c++-common/analyzer/pr98575-1.c b/gcc/testsuite/c-c++-common/analyzer/pr98575-1.c index 6472e76..b8ddf77 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr98575-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr98575-1.c @@ -4,7 +4,7 @@ void **g; -extern void unknown_fn (void); +extern void unknown_fn (void) __attribute__((nothrow)); /* Without a call to unknown_fn. */ diff --git a/gcc/testsuite/c-c++-common/analyzer/pr99716-1.c b/gcc/testsuite/c-c++-common/analyzer/pr99716-1.c index 41be8ca..60f3a598 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr99716-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr99716-1.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + typedef struct FILE FILE; FILE* fopen (const char*, const char*); diff --git a/gcc/testsuite/c-c++-common/analyzer/pr99716-2.c b/gcc/testsuite/c-c++-common/analyzer/pr99716-2.c index ef7cc5f..caf5c86 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr99716-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr99716-2.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib rand" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ /* Reduced from https://github.com/libguestfs/libguestfs/blob/e0a11061035d47b118c95706240bcc17fd576edc/tests/mount-local/test-parallel-mount-local.c#L299-L335 diff --git a/gcc/testsuite/c-c++-common/analyzer/pr99716-3.c b/gcc/testsuite/c-c++-common/analyzer/pr99716-3.c index 414d57e..98f656f 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr99716-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr99716-3.c @@ -1,4 +1,5 @@ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/pragma-2.c b/gcc/testsuite/c-c++-common/analyzer/pragma-2.c index bd96a25..f309876 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pragma-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/pragma-2.c @@ -1,6 +1,7 @@ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* Verify that we can disable -Wanalyzer-too-complex via pragmas. */ /* { dg-additional-options "-Wanalyzer-too-complex -Werror=analyzer-too-complex -fno-analyzer-state-merge -g" } */ +/* { dg-additional-options "-fno-exceptions" } */ /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/realloc-1.c b/gcc/testsuite/c-c++-common/analyzer/realloc-1.c index 04925cf..0bb846c 100644 --- a/gcc/testsuite/c-c++-common/analyzer/realloc-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/realloc-1.c @@ -92,5 +92,5 @@ void test_9 (void *p) void test_10 (char *s, int n) { __builtin_realloc(s, n); /* { dg-warning "ignoring return value of '__builtin_realloc' declared with attribute 'warn_unused_result'" "" { target c } } */ - /* { dg-warning "ignoring return value of 'void\\* __builtin_realloc\\(void\\*, (long )?unsigned int\\)' declared with attribute 'warn_unused_result'" "" { target c++ } .-1 } */ + /* { dg-warning "ignoring return value of 'void\\* __builtin_realloc\\(void\\*, (long )*unsigned int\\)' declared with attribute 'warn_unused_result'" "" { target c++ } .-1 } */ } /* { dg-warning "leak" } */ diff --git a/gcc/testsuite/c-c++-common/analyzer/rhbz1878600.c b/gcc/testsuite/c-c++-common/analyzer/rhbz1878600.c index 9f6ccb6..9606044 100644 --- a/gcc/testsuite/c-c++-common/analyzer/rhbz1878600.c +++ b/gcc/testsuite/c-c++-common/analyzer/rhbz1878600.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + #include <stdio.h> #define INI_MAX_LINE 200 diff --git a/gcc/testsuite/c-c++-common/analyzer/sprintf-3.c b/gcc/testsuite/c-c++-common/analyzer/sprintf-3.c new file mode 100644 index 0000000..ac5169e --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/sprintf-3.c @@ -0,0 +1,44 @@ +/* See e.g. https://en.cppreference.com/w/c/io/fprintf + and https://www.man7.org/linux/man-pages/man3/sprintf.3.html */ + +extern int +sprintf(char* dst, const char* fmt, ...) + __attribute__((__nothrow__)); + +#include "../../gcc.dg/analyzer/analyzer-decls.h" + +void test_text_ok (void) +{ + char buf[16]; + sprintf (buf, "hello world"); +} + +void test_text_oob (void) +{ + char buf[3]; + sprintf (buf, "hello world"); /* { dg-warning "out-of-bounds" "PR analyzer/107017" { xfail *-*-* } } */ +} + +void test_percent_s_ok (void) +{ + char buf[16]; + sprintf (buf, "%s", "foo"); +} + +void test_percent_s_oob (void) +{ + char buf[3]; + sprintf (buf, "%s", "foo"); /* { dg-warning "out-of-bounds" "PR analyzer/107017" { xfail *-*-* } } */ +} + +void test_percent_i_ok (void) +{ + char buf[16]; + sprintf (buf, "%i", "42"); +} + +void test_percent_i_oob (void) +{ + char buf[4]; + sprintf (buf, "%i", "1066"); /* { dg-warning "out-of-bounds" "PR analyzer/107017" { xfail *-*-* } } */ +} diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c index 3f90afe..915f220 100644 --- a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c @@ -1,6 +1,7 @@ /* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* hppa*-*-hpux* *-*-mingw* *-*-vxworks* } } */ /* { dg-additional-options "-D_POSIX_C_SOURCE=200809L" } */ /* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */ +/* { dg-additional-options "-fno-exceptions" } */ #include <string.h> #include <stdlib.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c b/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c index a396c64..9611727 100644 --- a/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c +++ b/gcc/testsuite/c-c++-common/analyzer/strtok-cppreference.c @@ -13,7 +13,7 @@ /* { dg-additional-options " -Wno-analyzer-too-complex -Wno-analyzer-symbol-too-complex" } */ -#define __STDC_WANT_LIB_EXT1__ 0 +#define __STDC_WANT_LIB_EXT1__ 1 #include <string.h> #include <stdio.h> diff --git a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4-disabled.c b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4-disabled.c index 868c393..1aa4159 100644 --- a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4-disabled.c +++ b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4-disabled.c @@ -2,6 +2,7 @@ region_model_context_decorator::add_note. */ /* { dg-additional-options "-Wno-analyzer-write-to-string-literal" } */ +/* { dg-additional-options "-fno-exceptions" } */ typedef __SIZE_TYPE__ size_t; diff --git a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4.c b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4.c index 971e8f3..b60fba0 100644 --- a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4.c +++ b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-4.c @@ -1,3 +1,5 @@ +/* { dg-additional-options "-fno-exceptions" } */ + typedef __SIZE_TYPE__ size_t; int getrandom (void *__buffer, size_t __length, /* { dg-line getrandom } */ diff --git a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-5.c b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-5.c index 2ecad8c..78b2204 100644 --- a/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-5.c +++ b/gcc/testsuite/c-c++-common/analyzer/write-to-string-literal-5.c @@ -2,6 +2,7 @@ notes) works. */ /* { dg-additional-options "-fanalyzer-show-duplicate-count" } */ +/* { dg-additional-options "-fno-exceptions" } */ #include "../../gcc.dg/analyzer/analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/analyzer/zlib-5.c b/gcc/testsuite/c-c++-common/analyzer/zlib-5.c index 1e3746d..fa82e43 100644 --- a/gcc/testsuite/c-c++-common/analyzer/zlib-5.c +++ b/gcc/testsuite/c-c++-common/analyzer/zlib-5.c @@ -1,4 +1,5 @@ /* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-fno-exceptions" } */ #include "analyzer-decls.h" diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-1.c b/gcc/testsuite/c-c++-common/asan/pr120608-1.c new file mode 100644 index 0000000..114c42d --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr120608-1.c @@ -0,0 +1,43 @@ +/* PR middle-end/120608 */ +/* { dg-do run { target musttail } } */ +/* { dg-options "-O2 -fsanitize=address" } */ + +__attribute__((noipa)) void +foo (int *x, int *y, int *z) +{ + ++x[0]; + ++y[0]; + ++z[0]; +} + +__attribute__((noipa)) void +bar (int *x, int *y, int *z) +{ + if (x || y || z) + __builtin_abort (); +} + +__attribute__((noipa)) void +baz (int *x, int *y, int *z) +{ + (void) x; (void) y; (void) z; + int a = 42, b = -42, c = 0; + foo (&a, &b, &c); + [[gnu::musttail]] return bar (0, 0, 0); +} + +__attribute__((noipa)) void +qux (int *x, int *y, int *z) +{ + (void) x; (void) y; (void) z; + int a = 42, b = -42, c = 0; + foo (&a, &b, &c); + [[gnu::musttail]] return bar (0, 0, 0); +} + +int +main () +{ + baz (0, 0, 0); + qux (0, 0, 0); +} diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-2.c b/gcc/testsuite/c-c++-common/asan/pr120608-2.c new file mode 100644 index 0000000..251ff3a --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr120608-2.c @@ -0,0 +1,39 @@ +/* PR middle-end/120608 */ +/* { dg-do run { target musttail } } */ +/* { dg-options "-O2 -fsanitize=address" } */ +/* { dg-set-target-env-var ASAN_OPTIONS "detect_stack_use_after_return=1" } */ +/* { dg-shouldfail "asan" } */ + +__attribute__((noipa)) void +foo (int *x, int *y, int *z) +{ + ++x[0]; + ++y[0]; + ++z[0]; +} + +__attribute__((noipa)) void +bar (int *x, int *y, int *z) +{ + volatile int a = x[0] + y[0] + z[0]; +} + +__attribute__((noipa)) void +baz (int *x, int *y, int *z) +{ + (void) x; (void) y; (void) z; + int a = 42, b = -42, c = 0; + foo (&a, &b, &c); + [[gnu::musttail]] return bar (&a, &b, &c); /* { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" } */ +} /* { dg-warning "address of automatic variable 'b' passed to 'musttail' call argument" "" { target *-*-* } .-1 } */ + /* { dg-warning "address of automatic variable 'c' passed to 'musttail' call argument" "" { target *-*-* } .-2 } */ + +int +main () +{ + baz (0, 0, 0); +} + +// { dg-output "ERROR: AddressSanitizer: stack-use-after-return on address.*(\n|\r\n|\r)" } +// { dg-output "READ of size .*" } +// { dg-output ".*'a' \\(line 25\\) <== Memory access at offset \[0-9\]* is inside this variable.*" } diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-3.c b/gcc/testsuite/c-c++-common/asan/pr120608-3.c new file mode 100644 index 0000000..8ea4468 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr120608-3.c @@ -0,0 +1,36 @@ +/* PR middle-end/120608 */ +/* { dg-do compile { target musttail } } */ +/* { dg-options "-fsanitize=address -fno-exceptions" } */ + +[[gnu::noipa]] int +foo (int x) +{ + return x; +} + +[[gnu::noipa]] void +bar (int *x, int *y, int *z) +{ + (void) x; + (void) y; + (void) z; +} + +[[gnu::noipa]] int +baz (int x) +{ + int a = 4; + { + int b = 8; + { + int c = 10; + bar (&a, &b, &c); + if (a + b + c == 22) + [[gnu::musttail]] return foo (x); + bar (&a, &b, &c); + } + bar (&a, &b, &a); + } + bar (&a, &a, &a); + return 42; +} diff --git a/gcc/testsuite/c-c++-common/asan/pr120608-4.c b/gcc/testsuite/c-c++-common/asan/pr120608-4.c new file mode 100644 index 0000000..86891454 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr120608-4.c @@ -0,0 +1,30 @@ +/* PR middle-end/120608 */ +/* { dg-do compile { target musttail } } */ +/* { dg-options "-fsanitize=address -fno-exceptions" } */ + +[[gnu::noipa]] void +bar (int *x, int *y, int *z) +{ + (void) x; + (void) y; + (void) z; +} + +[[gnu::noipa]] int +baz (int x) +{ + int a = 4; + { + int b = 8; + { + int c = 10; + bar (&a, &b, &c); + if (a + b + c + x == 22) + [[gnu::musttail]] return baz (x - 1); + bar (&a, &b, &c); + } + bar (&a, &b, &a); + } + bar (&a, &a, &a); + return 42; +} diff --git a/gcc/testsuite/c-c++-common/cpp/pragma-diagnostic-loc-2.c b/gcc/testsuite/c-c++-common/cpp/pragma-diagnostic-loc-2.c new file mode 100644 index 0000000..734da21 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/pragma-diagnostic-loc-2.c @@ -0,0 +1,15 @@ +/* PR c/118838 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Wunknown-pragmas" } */ + +/* Make sure the warnings are suppressed as expected. */ + +/* The tokens need to be all on the same line here. */ +_Pragma ("GCC diagnostic push") _Pragma ("GCC diagnostic ignored \"-Wunknown-pragmas\"") _Pragma ("__unknown__") _Pragma ("GCC diagnostic pop") + +#define MACRO \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wunknown-pragmas\"") \ + _Pragma ("__unknown__") \ + _Pragma ("GCC diagnostic pop") +MACRO diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c deleted file mode 100644 index c95218c..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json" } */ - -#error message - -/* { dg-begin-multiline-output "" } -[{"kind": "error", - "message": "#error message", - "children": [], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 4, - "display-column": 2, - "byte-column": 2, - "column": 2}, - "finish": {"file": - "line": 4, - "display-column": 6, - "byte-column": 6, - "column": 6}}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c deleted file mode 100644 index a8828b7..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json" } */ - -#warning message - -/* { dg-begin-multiline-output "" } -[{"kind": "warning", - "message": "#warning message", - "option": "-Wcpp", - { dg-end-multiline-output "" } */ -/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */ -/* { dg-begin-multiline-output "" } - "children": [], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 4, - "display-column": 2, - "byte-column": 2, - "column": 2}, - "finish": {"file": - "line": 4, - "display-column": 8, - "byte-column": 8, - "column": 8}}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c deleted file mode 100644 index 178bbf9..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json -Werror" } */ - -#warning message - -/* { dg-begin-multiline-output "" } -[{"kind": "error", - "message": "#warning message", - "option": "-Werror=cpp", - { dg-end-multiline-output "" } */ -/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */ -/* { dg-begin-multiline-output "" } - "children": [], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 4, - "display-column": 2, - "byte-column": 2, - "column": 2}, - "finish": {"file": - "line": 4, - "display-column": 8, - "byte-column": 8, - "column": 8}}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c deleted file mode 100644 index 899a03f..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c +++ /dev/null @@ -1,44 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json -Wmisleading-indentation" } */ - -int test (void) -{ - if (1) - return 3; - return 4; - return 5; -} - -/* { dg-begin-multiline-output "" } -[{"kind": "warning", - "message": "this 'if' clause does not guard...", - "option": "-Wmisleading-indentation", - { dg-end-multiline-output "" } */ -/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\",\n" } */ -/* { dg-begin-multiline-output "" } - "children": [{"kind": "note", - "message": "...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'", - "locations": [{"caret": {"file": - "line": 8, - "display-column": 5, - "byte-column": 5, - "column": 5}, - "finish": {"file": - "line": 8, - "display-column": 10, - "byte-column": 10, - "column": 10}}], - "escape-source": false}], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 6, - "display-column": 3, - "byte-column": 3, - "column": 3}, - "finish": {"file": - "line": 6, - "display-column": 4, - "byte-column": 4, - "column": 4}}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c deleted file mode 100644 index ed3139c..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json" } */ - -struct s { int color; }; - -int test (struct s *ptr) -{ - return ptr->colour; -} - -/* { dg-begin-multiline-output "" } -[{"kind": "error", - "message": "'struct s' has no member named 'colour'; did you mean 'color'?", - "children": [], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 8, - "display-column": 15, - "byte-column": 15, - "column": 15}, - "finish": {"file": - "line": 8, - "display-column": 20, - "byte-column": 20, - "column": 20}}], - "fixits": [{"start": {"file": - "line": 8, - "display-column": 15, - "byte-column": 15, - "column": 15}, - "next": {"file": - "line": 8, - "display-column": 21, - "byte-column": 21, - "column": 21}, - "string": "color"}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c deleted file mode 100644 index ddac780..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Check that -fdiagnostics-format=json-file works. */ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json-file" } */ - -#warning message - -/* Verify that some JSON was written to a file with the expected name. */ -/* { dg-final { scan-file "diagnostic-format-json-file-1.c.gcc.json" "\"message\": \"#warning message\"" } } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c deleted file mode 100644 index e798c6b..0000000 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Check that "json" and "json-stderr" are synonymous when used as - arguments to "-fdiagnostics-format=". */ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json-stderr" } */ - -#error message - -/* { dg-begin-multiline-output "" } -[{"kind": "error", - "message": "#error message", - "children": [], - "column-origin": 1, - "locations": [{"caret": {"file": - "line": 6, - "display-column": 2, - "byte-column": 2, - "column": 2}, - "finish": {"file": - "line": 6, - "display-column": 6, - "byte-column": 6, - "column": 6}}], - "escape-source": false}] - { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c b/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c new file mode 100644 index 0000000..bc7ff02 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/acc-wait-1.c @@ -0,0 +1,51 @@ +// { dg-do compile } +// { dg-additional-options "-fdump-tree-original" } + +void f0 (int x) +{ + #pragma acc wait(x) if(false) async +} +// { dg-final { scan-tree-dump-times "if \\(0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-1, 1, x\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-not "__builtin_GOACC_wait \\(-1, 1, x\\);" "original" { target c++ } } } + + +void f1 (int y, int ia) +{ + #pragma acc wait(y) if(true) async(ia) +} +// { dg-final { scan-tree-dump-times "if \\(1\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(ia, 1, y\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-times "__builtin_GOACC_wait \\(ia, 1, y\\)" 1 "original" { target c++ } } } +// { dg-final { scan-tree-dump-not "if \\(\[^\\n\\r\]+\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(ia, 1, y\\);" "original" { target c++ } } } + + +void fl (int z, bool ll) +{ + #pragma acc wait(z) if(ll) async(3) +} +// { dg-final { scan-tree-dump-times "if \\(ll != 0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(3, 1, z\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-times "if \\(ll\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(3, 1, z\\);" 1 "original" { target c++ } } } + + +void a0 (int a) +{ + #pragma acc wait(a) if(false) +} +// { dg-final { scan-tree-dump-times "if \\(0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, a\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-not "__builtin_GOACC_wait \\(-2, 1, a\\);" "original" { target c++ } } } + + +void a1 (int b) +{ + #pragma acc wait(b) if(true) +} +// { dg-final { scan-tree-dump-times "if \\(1\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, b\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-times "__builtin_GOACC_wait \\(-2, 1, b\\)" 1 "original" { target c++ } } } +// { dg-final { scan-tree-dump-not "if \\(\[^\\n\\r\]+\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, b\\);" "original" { target c++ } } } + + +void al (int c, bool qq) +{ + #pragma acc wait(c) if(qq) +} +// { dg-final { scan-tree-dump-times "if \\(qq != 0\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, c\\);" 1 "original" { target c } } } +// { dg-final { scan-tree-dump-times "if \\(qq\\)\[\\n\\r\]+ *\{\[\\n\\r\]+ *__builtin_GOACC_wait \\(-2, 1, c\\);" 1 "original" { target c++ } } } diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c index 31dd054..803bf0a 100644 --- a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c +++ b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c @@ -9,7 +9,7 @@ f (int x[], int y[], int z[]) { int i; - [[omp::sequence (directive (target map(to: x, y) map(from: z)), + [[omp::sequence (directive (target map(to: x, y) map(from: z)), /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */ directive (metadirective when (device={arch("nvptx")}: teams loop) default (parallel loop)))]] @@ -20,5 +20,6 @@ f (int x[], int y[], int z[]) /* If offload device "nvptx" isn't supported, the front end can eliminate that alternative and not produce a metadirective at all. Otherwise this won't be resolved until late. */ -/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */ -/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */ +/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c new file mode 100644 index 0000000..4020c4b --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-10.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +struct S { + int x,y; +}; + +#pragma omp declare mapper(default : struct S var) map(mapper(default), tofrom: var) +#pragma omp declare mapper(only_x : struct S var) map(mapper(default), tofrom: var.x) + +void f(){ + struct S z = {1,2}; +#pragma omp target defaultmap(alloc) + z.x += 5; +#pragma omp target map(z) + z.x += 7; +#pragma omp target map(mapper(default), tofrom: z) + z.x += 8; +#pragma omp target map(mapper(only_x), tofrom: z) + z.x += 9; +if (z.x != 1+5+7+8+9) __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(alloc\\) map\\(tofrom:z \\\[len: 8\\\]\\)" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) map\\(tofrom:z \\\[len: 8\\\]\\)" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) map\\(struct:z \\\[len: 1\\\]\\) map\\(tofrom:z.x \\\[len: 4\\\]\\)" 1 "gimple" } } */ + +int main() { + f(); +} diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c new file mode 100644 index 0000000..1f65bad --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-11.c @@ -0,0 +1,70 @@ +#pragma omp declare mapper (int v) +// { dg-error "missing 'map' clause before end of line" "" { target c++ } .-1 } +// { dg-error "'int' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-2 } + +#pragma omp declare mapper (float v) map() +// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 } +// { dg-error "'float' is not a struct, union or class type in '#pragma omp declare mapper'" "" { target c++ } .-2 } +// { dg-error "'float' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-3 } + +#pragma omp declare mapper (char v) map(v) +// { dg-error "'char' is not a struct, union or class type in '#pragma omp declare mapper'" "" { target c++ } .-1 } +// { dg-error "'char' is not a struct or union type in '#pragma omp declare mapper'" "" { target c } .-2 } + +struct XT { + int x; +}; +#pragma omp declare mapper (XT y) map() +// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 } +// { dg-error "unknown type name 'XT'" "" { target c } .-2 } +// { dg-error "expected end of line before 'y'" "" { target c } .-3 } +#pragma omp declare mapper ( bar : struct XT y) map() +// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 } +// { dg-error "expected expression before '\\)' token" "" { target c } .-2 } + +struct t { + int x; +}; + +typedef struct t myStruct; + +#pragma omp declare mapper(t) +// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 } +// { dg-error "unknown type name 't'" "" { target c } .-2 } +// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 } +#pragma omp declare mapper(struct t) +// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 } +// { dg-error "expected identifier" "" { target c } .-2 } +// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 } +#pragma omp declare mapper(myStruct) +// { dg-error "expected unqualified-id before '\\)' token" "" { target c++ } .-1 } +// { dg-error "expected identifier" "" { target c } .-2 } +// { dg-error "expected end of line before '\\)' token" "" { target c } .-3 } + +#pragma omp declare mapper(name : t v) map() +// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 } +// { dg-error "unknown type name 't'" "" { target c } .-2 } +// { dg-error "expected end of line before 'v'" "" { target c } .-3 } + +#pragma omp declare mapper(fancy : struct t v) map(always,present,close,mapper(d),tofrom: v) // { dg-error "in 'declare mapper' directives, parameter to 'mapper' modifier must be 'default'" } + +#pragma omp declare mapper(myStruct v) map(v, v.x) +// { dg-note "'#pragma omp declare mapper \\(myStruct\\)' previously declared here" "" { target c++ } .-1 } +// { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } +#pragma omp declare mapper(default : struct t v) map(v, v.x) +// { dg-error "redefinition of '#pragma omp declare mapper \\(t\\)'" "" { target c++ } .-1 } +// { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct t'" "" { target c } .-2 } + +union u_t { }; +union u_q { }; + +#pragma omp declare mapper(union u_t v) map() +// { dg-error "expected primary-expression before '\\)' token" "" { target c++ } .-1 } +// { dg-error "expected expression before '\\)' token" "" { target c } .-2 } + +#pragma omp declare mapper( one : union u_t v) map(v) +// { dg-note "'#pragma omp declare mapper \\(one: u_t\\)' previously declared here" "" { target c++ } .-1 } +// { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } +#pragma omp declare mapper( one : union u_t u) map( u ) +// { dg-error "redefinition of '#pragma omp declare mapper \\(one: u_t\\)'" "" { target c++ } .-1 } +// { dg-error "redeclaration of 'one' '#pragma omp declare mapper' for type 'union u_t'" "" { target c } .-2 } diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c new file mode 100644 index 0000000..dffb19d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-12.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +struct XYZ { + int a; + int *b; + int c; +}; + +#pragma omp declare mapper(struct XYZ t) +/* { dg-error "missing 'map' clause" "" { target c } .-1 } */ +/* { dg-error "missing 'map' clause before end of line" "" { target c++ } .-2 } */ + +struct ABC { + int *a; + int b; + int c; +}; + +#pragma omp declare mapper(struct ABC d) firstprivate(d.b) +/* { dg-error "unexpected clause" "" { target c } .-1 } */ +/* { dg-error "expected end of line before '\\(' token" "" { target c } .-2 } */ +/* { dg-error "unexpected clause before '\\(' token" "" { target c++ } .-3 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c new file mode 100644 index 0000000..e491bcd --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-3.c @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-additional-options "-fdump-tree-gimple" } + +#include <stdlib.h> + +// Test named mapper invocation. + +struct S { + int *ptr; + int size; +}; + +int main (int argc, char *argv[]) +{ + int N = 1024; +#pragma omp declare mapper (mapN:struct S s) map(to:s.ptr, s.size) \ + map(s.ptr[:N]) + + struct S s; + s.ptr = (int *) malloc (sizeof (int) * N); + +#pragma omp target map(mapper(mapN), tofrom: s) +// { dg-final { scan-tree-dump {map\(struct:s \[len: 2\]\) map\(alloc:s\.ptr \[len: [0-9]+\]\) map\(to:s\.size \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: _[0-9]+\]\) map\(attach:s\.ptr \[bias: 0\]\)} "gimple" } } + { + for (int i = 0; i < N; i++) + s.ptr[i]++; + } + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c new file mode 100644 index 0000000..39e3ab1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-4.c @@ -0,0 +1,78 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-original" } */ + +/* Check mapper binding clauses. */ + +struct Y { + int z; +}; + +struct Z { + int z; +}; + +#pragma omp declare mapper (struct Y y) map(tofrom: y) +#pragma omp declare mapper (struct Z z) map(tofrom: z) + +int foo (void) +{ + struct Y yy; + struct Z zz; + int dummy; + +#pragma omp target data map(dummy) + { + #pragma omp target + { + yy.z++; + zz.z++; + } + yy.z++; + } + return yy.z; +} + +struct P +{ + struct Z *zp; +}; + +int bar (void) +{ + struct Y yy; + struct Z zz; + struct P pp; + struct Z t; + int dummy; + + pp.zp = &t; + +#pragma omp declare mapper (struct Y y) map(tofrom: y.z) +#pragma omp declare mapper (struct Z z) map(tofrom: z.z) + +#pragma omp target data map(dummy) + { + #pragma omp target + { + yy.z++; + zz.z++; + } + yy.z++; + } + + #pragma omp declare mapper(struct P x) map(to:x.zp) map(tofrom:*x.zp) + + #pragma omp target + { + zz = *pp.zp; + } + + return zz.z; +} + +/* { dg-final { scan-tree-dump-times {mapper_binding\(struct Y,omp declare mapper ~1Y\) mapper_binding\(struct Z,omp declare mapper ~1Z\)} 2 "original" { target c++ } } } */ +/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,omp declare mapper ~1Z\) mapper_binding\(struct P,omp declare mapper ~1P\)} "original" { target c++ } } } */ + +/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\)\) mapper_binding\(struct Y,#pragma omp declare mapper \(struct Y y\) map\(tofrom:y\)\)} "original" { target c } } } */ +/* { dg-final { scan-tree-dump {mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\.z\)\) mapper_binding\(struct Y,#pragma omp declare mapper \(struct Y y\) map\(tofrom:y\.z\)\)} "original" { target c } } } */ +/* { dg-final { scan-tree-dump {mapper_binding\(struct P,#pragma omp declare mapper \(struct P x\) map\(tofrom:\(x\.zp\)\[0:1\]\) map\(to:x.zp\)\) mapper_binding\(struct Z,#pragma omp declare mapper \(struct Z z\) map\(tofrom:z\.z\)\)} "original" { target c } } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c new file mode 100644 index 0000000..e8ab159 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-5.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +typedef struct S_ { + int *myarr; + int size; +} S; + +#pragma omp declare mapper (named: struct S_ v) map(to:v.size, v.myarr) \ + map(tofrom: v.myarr[0:v.size]) +/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } */ +/* { dg-note "'#pragma omp declare mapper \\(named: S_\\)' previously defined here" "" { target c++ } .-3 } */ + +#pragma omp declare mapper (named: S v) map(to:v.size, v.myarr) \ + map(tofrom: v.myarr[0:v.size]) +/* { dg-error "redeclaration of 'named' '#pragma omp declare mapper' for type 'S' \\\{aka 'struct S_'\\\}" "" { target c } .-2 } */ +/* { dg-error "redefinition of '#pragma omp declare mapper \\(named: S\\)'" "" { target c++ } .-3 } */ + +#pragma omp declare mapper (struct S_ v) map(to:v.size, v.myarr) \ + map(tofrom: v.myarr[0:v.size]) +/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-2 } */ +/* { dg-note "'#pragma omp declare mapper \\(S_\\)' previously defined here" "" { target c++ } .-3 } */ + +#pragma omp declare mapper (S v) map(to:v.size, v.myarr) \ + map(tofrom: v.myarr[0:v.size]) +/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'S' \\\{aka 'struct S_'\\\}" "" { target c } .-2 } */ +/* { dg-error "redefinition of '#pragma omp declare mapper \\(S\\)'" "" { target c++ } .-3 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c new file mode 100644 index 0000000..c13eb8b --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-6.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +int x = 5; + +struct Q { + int *arr1; + int *arr2; + int *arr3; +}; + +#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x]) + +struct R { + int *arr1; + int *arr2; + int *arr3; +}; + +#pragma omp declare mapper (struct R myr) map(myr.arr3[0:y]) +/* { dg-error "'y' undeclared" "" { target c } .-1 } */ +/* { dg-error "'y' was not declared in this scope" "" { target c++ } .-2 } */ + +int y = 7; diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c new file mode 100644 index 0000000..0f8dd25 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-7.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +struct Q { + int *arr1; + int *arr2; + int *arr3; +}; + +int foo (void) +{ + int x = 5; + #pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x]) + return x; +} + +struct R { + int *arr1; + int *arr2; + int *arr3; +}; + +int bar (void) +{ + #pragma omp declare mapper (struct R myr) map(myr.arr3[0:y]) + /* { dg-error "'y' undeclared" "" { target c } .-1 } */ + /* { dg-error "'y' was not declared in this scope" "" { target c++ } .-2 } */ + int y = 7; + return y; +} diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c new file mode 100644 index 0000000..dadca28 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-8.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ + +struct Q { + int *arr1; + int *arr2; + int *arr3; + int len; +}; + +struct R { + struct Q qarr[5]; +}; + +struct R2 { + struct Q *qptr; +}; + +#pragma omp declare mapper (struct Q myq) map(myq.arr1[0:myq.len]) \ + map(myq.arr2[0:myq.len]) \ + map(myq.arr3[0:myq.len]) + +#pragma omp declare mapper (struct R myr) map(myr.qarr[2:3]) + +#pragma omp declare mapper (struct R2 myr2) map(myr2.qptr[2:3]) + +int main (int argc, char *argv[]) +{ + struct R r; + struct R2 r2; + int N = 256; + +#pragma omp target +/* { dg-message "sorry, unimplemented: user-defined mapper with non-unit length array section" "" { target *-*-* } .-1 } */ + { + for (int i = 2; i < 5; i++) + for (int j = 0; j < N; j++) + { + r.qarr[i].arr1[j]++; + r2.qptr[i].arr2[j]++; + } + } +} + diff --git a/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c b/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c new file mode 100644 index 0000000..709bc0c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-mapper-9.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +int x = 5; + +struct Q { + int *arr1; + int *arr2; + int *arr3; +}; + +int y = 5; + +#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:x]) +/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-1 } */ +/* { dg-note "'#pragma omp declare mapper \\(Q\\)' previously defined here" "" { target c++ } .-2 } */ + +#pragma omp declare mapper (struct Q myq) map(myq.arr2[0:y]) +/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct Q'" "" { target c } .-1 } */ +/* { dg-error "redefinition of '#pragma omp declare mapper \\(Q\\)'" "" { target c++ } .-2 } */ + +struct R { + int *arr1; +}; + +void foo (void) +{ +#pragma omp declare mapper (struct R myr) map(myr.arr1[0:x]) +/* { dg-note "'#pragma omp declare mapper' previously declared here" "" { target c } .-1 } */ +/* { dg-note "'#pragma omp declare mapper \\(R\\)' previously declared here" "" { target c++ } .-2 } */ + +#pragma omp declare mapper (struct R myr) map(myr.arr1[0:y]) +/* { dg-error "redeclaration of '<default>' '#pragma omp declare mapper' for type 'struct R'" "" { target c } .-1 } */ +/* { dg-error "redeclaration of '#pragma omp declare mapper \\(R\\)'" "" { target c++ } .-2 } */ +} diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c index 7711dbc..83e1bb1 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c @@ -38,7 +38,7 @@ void f18 (void); void f19 (void); #pragma omp declare variant (f1) match(user={condition()}) /* { dg-error "expected \[^\n\r]*expression before '\\)' token" } */ void f20 (void); -#pragma omp declare variant (f1) match(user={condition(f1)}) /* { dg-error "property must be integer expression" } */ +#pragma omp declare variant (f1) match(user={condition(f1)}) void f21 (void); #pragma omp declare variant (f1) match(user={condition(1, 2, 3)}) /* { dg-error "expected '\\)' before ',' token" } */ void f22 (void); @@ -47,10 +47,9 @@ void f23 (void); #pragma omp declare variant (f1) match(construct={teams,parallel,master,for}) /* { dg-warning "unknown selector 'master' for context selector set 'construct'" } */ void f24 (void); #pragma omp declare variant (f1) match(construct={parallel(1 /* { dg-error "selector 'parallel' does not accept any properties" } */ -void f25 (void); /* { dg-error "expected '\\\}' before end of line" "" { target c++ } .-1 } */ - /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-2 } */ +void f25 (void); /* { dg-error "expected '\\\}' before end of line" "" { target *-*-* } .-1 } */ #pragma omp declare variant (f1) match(construct={parallel(1)}) /* { dg-error "selector 'parallel' does not accept any properties" } */ -void f26 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ +void f26 (void); #pragma omp declare variant (f0) match(construct={simd(12)}) /* { dg-error "expected \[^\n\r]* clause before" } */ void f27 (void); /* { dg-error "'\\)' before numeric constant" "" { target c++ } .-1 } */ #pragma omp declare variant (f1) match(construct={parallel},construct={for}) /* { dg-error "selector set 'construct' specified more than once" } */ @@ -96,13 +95,13 @@ void f46 (void); #pragma omp declare variant (f1) match(implementation={vendor("foobar")}) /* { dg-warning "unknown property '.foobar.' of 'vendor' selector" } */ void f47 (void); #pragma omp declare variant (f1) match(implementation={unified_address(yes)}) /* { dg-error "selector 'unified_address' does not accept any properties" } */ -void f48 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ +void f48 (void); #pragma omp declare variant (f1) match(implementation={unified_shared_memory(no)}) /* { dg-error "selector 'unified_shared_memory' does not accept any properties" } */ -void f49 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ +void f49 (void); #pragma omp declare variant (f1) match(implementation={dynamic_allocators(42)}) /* { dg-error "selector 'dynamic_allocators' does not accept any properties" } */ -void f50 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ +void f50 (void); #pragma omp declare variant (f1) match(implementation={reverse_offload()}) /* { dg-error "selector 'reverse_offload' does not accept any properties" } */ -void f51 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ +void f51 (void); #pragma omp declare variant (f1) match(implementation={atomic_default_mem_order}) /* { dg-error "expected '\\(' before '\\\}' token" } */ void f52 (void); #pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(acquire)}) diff --git a/gcc/testsuite/c-c++-common/gomp/map-6.c b/gcc/testsuite/c-c++-common/gomp/map-6.c index 014ed35..852839e 100644 --- a/gcc/testsuite/c-c++-common/gomp/map-6.c +++ b/gcc/testsuite/c-c++-common/gomp/map-6.c @@ -13,20 +13,20 @@ foo (void) #pragma omp target map (to:a) ; - #pragma omp target map (a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */ - ; + #pragma omp target map (a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */ + ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */ - #pragma omp target map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */ - ; + #pragma omp target map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */ + ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */ - #pragma omp target enter data map(b7) map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */ - ; + #pragma omp target enter data map(b7) map (close, a to: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */ + ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */ - #pragma omp target exit data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */ - ; + #pragma omp target exit data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */ + ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */ - #pragma omp target data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close' or 'present'" } */ - ; + #pragma omp target data map(b7) map (close, a from: b) /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present'" "" { target c++ } } */ + ; /* { dg-error "'map' clause with map-type modifier other than 'always', 'close', 'mapper' or 'present' before 'a'" "" { target c } .-1 } */ #pragma omp target map (close a) /* { dg-error "'close' undeclared" "" { target c } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c index 0ac0d1d..b6c1601 100644 --- a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c +++ b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c @@ -8,7 +8,7 @@ f (int x[], int y[], int z[]) { int i; - #pragma omp target map(to: x, y) map(from: z) + #pragma omp target map(to: x, y) map(from: z) /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */ #pragma omp metadirective \ when (device={arch("nvptx")}: teams loop) \ default (parallel loop) @@ -19,5 +19,6 @@ f (int x[], int y[], int z[]) /* If offload device "nvptx" isn't supported, the front end can eliminate that alternative and not produce a metadirective at all. Otherwise this won't be resolved until late. */ -/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */ -/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */ +/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c b/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c new file mode 100644 index 0000000..3484478 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/metadirective-condition-constexpr.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { c || c++11 } } } */ +/* { dg-additional-options "-std=c23" { target c } } */ +/* { dg-additional-options "-fdump-tree-original" } */ + +constexpr int flag = 1; + +void f() { +#pragma omp metadirective when(user={condition(flag)} : nothing) \ + otherwise(error at(execution)) +} + +/* { dg-final { scan-tree-dump-not "__builtin_GOMP_error" "original" } } */ + diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c b/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c new file mode 100644 index 0000000..099ad9d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/metadirective-condition.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-original" } */ + +static int arr[10]; +static int g (int a) { return -a; } + +void f (int *ptr, float x) { + + /* Implicit conversion float -> bool */ + #pragma omp metadirective when(user={condition(x)} : nothing) otherwise(nothing) + + /* Implicit conversion pointer -> bool */ + #pragma omp metadirective when(user={condition(ptr)} : nothing) otherwise(nothing) + + /* Array expression undergoes array->pointer conversion, OK but test is + always optimized away. */ + #pragma omp metadirective when(user={condition(arr)} : nothing) otherwise(nothing) + + /* Function reference has pointer-to-function type, OK but test is + always optimized away. */ + #pragma omp metadirective when(user={condition(g)} : nothing) otherwise(nothing) +} + +/* { dg-final { scan-tree-dump "x != 0.0" "original" } } */ +/* { dg-final { scan-tree-dump "ptr != 0B" "original" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c b/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c new file mode 100644 index 0000000..92995a2 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/metadirective-error-recovery.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +/* This test used to ICE in C and only diagnose the first error in C++. */ + +struct s { + int a, b; +}; + +void f (int aa, int bb) +{ + struct s s1, s2; + s1.a = aa; + s1.b = bb; + s2.a = aa + 1; + s2.b = bb + 1; + + /* A struct is not a valid argument for the condition selector. */ + #pragma omp metadirective when(user={condition(s1)} : nothing) otherwise(nothing) + /* { dg-error "used struct type value where scalar is required" "" { target c } .-1 } */ + /* { dg-error "could not convert .s1. from .s. to .bool." "" { target c++ } .-2 } */ + #pragma omp metadirective when(user={condition(s2)} : nothing) otherwise(nothing) + /* { dg-error "used struct type value where scalar is required" "" { target c } .-1 } */ + /* { dg-error "could not convert .s2. from .s. to .bool." "" { target c++ } .-2 } */ + +} diff --git a/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c new file mode 100644 index 0000000..891f5cf --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1 -fdump-tree-optimized -fno-builtin-omp_get_num_devices -fno-builtin-omp_get_initial_device" } */ + +#ifdef __cplusplus +extern "C" { +#endif +extern int omp_get_initial_device (); +extern int omp_get_num_devices (); +#ifdef __cplusplus +} +#endif + +int f() +{ +/* The following assumes that omp_get_initial_device () will not return + omp_initial_device (== -1), which is also permitted since OpenMP 6.0. */ + if (omp_get_initial_device () != omp_get_num_devices ()) __builtin_abort (); + + if (omp_get_num_devices () != omp_get_num_devices ()) __builtin_abort (); + + if (omp_get_initial_device () != omp_get_initial_device ()) __builtin_abort (); + + return omp_get_num_devices (); +} + +/* { dg-final { scan-tree-dump-times "abort" 3 "optimized" } } */ + +/* { dg-final { scan-tree-dump-times "omp_get_num_devices" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "omp_get_initial_device" 3 "optimized" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c new file mode 100644 index 0000000..6e2c1a8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/omp_get_num_devices_initial_device.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1 -fdump-tree-optimized" } */ + +#ifdef __cplusplus +extern "C" { +#endif +extern int omp_get_initial_device (); +extern int omp_get_num_devices (); +#ifdef __cplusplus +} +#endif + +int f() +{ +/* The following assumes that omp_get_initial_device () will not return + omp_initial_device (== -1), which is also permitted since OpenMP 6.0. */ + if (omp_get_initial_device () != omp_get_num_devices ()) __builtin_abort (); + + if (omp_get_num_devices () != omp_get_num_devices ()) __builtin_abort (); + + if (omp_get_initial_device () != omp_get_initial_device ()) __builtin_abort (); + + return omp_get_num_devices (); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ + +/* { dg-final { scan-tree-dump-not "omp_get_num_devices" "optimized" { target { ! offloading_enabled } } } } */ +/* { dg-final { scan-tree-dump "return 0;" "optimized" { target { ! offloading_enabled } } } } */ + +/* { dg-final { scan-tree-dump-times "omp_get_num_devices" 1 "optimized" { target offloading_enabled } } } */ +/* { dg-final { scan-tree-dump "_1 = __builtin_omp_get_num_devices \\(\\);\[\\r\\n\]+\[ \]+return _1;" "optimized" { target offloading_enabled } } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/pr120180.c b/gcc/testsuite/c-c++-common/gomp/pr120180.c new file mode 100644 index 0000000..cb5a0d5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr120180.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +/* This test used to ICE after erroring on the metadirective in the + loop nest. */ + +int main() +{ + int blksize = 15000; + double *qq; + int i, k, nq; + + #pragma omp metadirective when(user={condition(0)}: target teams distribute parallel for collapse(2) map(qq[:0]) private(i)) \ + when(user={condition(0)}: target teams distribute parallel for map(qq[:0]) private(i)) \ + when(user={condition(1)}: target teams loop collapse(2) map(qq[:0]) private(i)) + for(k=0; k<blksize; k++) + { +#pragma omp metadirective when(user={condition(0)}: simd) default() // { dg-error "intervening code must not contain OpenMP directives" } + for (i=0; i<nq; i++) + qq[k*nq + i] = 0.0; + } + return 0; +} diff --git a/gcc/testsuite/c-c++-common/musttail14.c b/gcc/testsuite/c-c++-common/musttail14.c index 56a52b8..5bda742 100644 --- a/gcc/testsuite/c-c++-common/musttail14.c +++ b/gcc/testsuite/c-c++-common/musttail14.c @@ -1,5 +1,5 @@ /* PR tree-optimization/118430 */ -/* { dg-do compile { target musttail } } */ +/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */ /* { dg-options "-O2 -fdump-tree-optimized" } */ /* { dg-final { scan-tree-dump-times " \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times " \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */ diff --git a/gcc/testsuite/c-c++-common/musttail22.c b/gcc/testsuite/c-c++-common/musttail22.c index eb81249..7dc0f19 100644 --- a/gcc/testsuite/c-c++-common/musttail22.c +++ b/gcc/testsuite/c-c++-common/musttail22.c @@ -1,5 +1,5 @@ /* PR tree-optimization/118430 */ -/* { dg-do compile { target musttail } } */ +/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */ /* { dg-options "-O2 -fdump-tree-optimized" } */ /* { dg-final { scan-tree-dump-times " \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times " \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */ diff --git a/gcc/testsuite/c-c++-common/pr106133.c b/gcc/testsuite/c-c++-common/pr106133.c deleted file mode 100644 index 7d2c5af..0000000 --- a/gcc/testsuite/c-c++-common/pr106133.c +++ /dev/null @@ -1,3 +0,0 @@ -/* PR middle-end/106133 */ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-format=json-file -E" } */ diff --git a/gcc/testsuite/c-c++-common/pr118868-1.c b/gcc/testsuite/c-c++-common/pr118868-1.c new file mode 100644 index 0000000..d0a9e77f7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr118868-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +/* PR middle-end/118868 */ + +/* __builtin_assoc_barrier should work on pointers without any ICE */ +void *f(void *a) +{ + return __builtin_assoc_barrier(a); +} diff --git a/gcc/testsuite/c-c++-common/pragma-optimize-1.c b/gcc/testsuite/c-c++-common/pragma-optimize-1.c new file mode 100644 index 0000000..1446e5a --- /dev/null +++ b/gcc/testsuite/c-c++-common/pragma-optimize-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +/* PR c++/48026 */ +/* Make sure `#pragma GCC optimize` affects the pre-defined macros too */ + +#pragma GCC optimize ("no-fast-math") +#ifdef __FAST_MATH__ +# error Hey yo, What you doing on FAST_MATH?? +#endif diff --git a/gcc/testsuite/c-c++-common/tsan/pr119801.c b/gcc/testsuite/c-c++-common/tsan/pr119801.c new file mode 100644 index 0000000..d3a6bb4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/tsan/pr119801.c @@ -0,0 +1,24 @@ +/* PR sanitizer/119801 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=thread" } */ + +[[gnu::noipa]] int +bar (int *p) +{ + return ++*p; +} + +int +foo (int *p) +{ + ++*p; + [[gnu::musttail]] return bar (p); +} + +[[gnu::noinline]] int +baz (int x) +{ + if (x < 10) + return x; + [[gnu::musttail]] return baz (x - 2); +} diff --git a/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c b/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c new file mode 100644 index 0000000..e2320df --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/nonnull-8.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */ + +__attribute__((noipa, nonnull_if_nonzero (1, 4, 7))) +__attribute__((nonnull (3), nonnull_if_nonzero (5, 2, 6))) void +foo (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g) +{ + (void) a; + (void) b; + (void) c; + (void) d; + (void) e; + (void) f; + (void) g; +} + +__attribute__((noipa)) +void +bar (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g) +{ + foo (a, b, c, d, e, f, g); +} + +int +main () +{ + char x; + bar (&x, 42, &x, 1, &x, 2, 3); + bar (0, 0, &x, 0, 0, 0, 0); + bar (0, 5, &x, 4, 0, 0, 0); + bar (0, 0, &x, 0, 0, 6, 7); +} diff --git a/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c b/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c new file mode 100644 index 0000000..68a4417 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/nonnull-9.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=nonnull-attribute" } */ + +__attribute__((noipa, nonnull_if_nonzero (1, 4, 7))) +__attribute__((nonnull (3), nonnull_if_nonzero (5, 2, 6))) void +foo (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g) +{ + (void) a; + (void) b; + (void) c; + (void) d; + (void) e; + (void) f; + (void) g; +} + +__attribute__((noipa)) +void +bar (void *a, unsigned long b, void *c, int d, void *e, unsigned long f, int g) +{ + foo (a, b, c, d, e, f, g); +} + +int +main () +{ + char x; + bar (&x, 42, 0, 1, &x, 17, 18); + bar (0, 25, &x, 7, &x, 0, 8); + bar (&x, -82, &x, 68, 0, 9, 0); + foo (&x, 42, 0, 1, &x, 17, 18); + foo (0, 25, &x, 7, &x, 0, 8); + foo (&x, -82, &x, 68, 0, 9, 0); +} + +/* { dg-output "\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 3, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*\.c:21:\[0-9]*:\[^\n\r]*null pointer passed as argument 5, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*\.c:31:\[0-9]*:\[^\n\r]*null pointer passed as argument 3, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*\.c:32:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*\.c:33:\[0-9]*:\[^\n\r]*null pointer passed as argument 5, which is declared to never be null" } */ |