diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-16 20:22:34 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-16 20:22:34 -0800 |
commit | 71e955da39cea0ebffcfee3432effa622d14ca99 (patch) | |
tree | a690b84e725e0c8c3ab35c53f16f3e156d1f10d7 /gcc/testsuite | |
parent | b43d6db9780462273c4d885a0111e3376c114c61 (diff) | |
parent | 837eb12629dd8a8a45fac9b8db57b29ecda46f14 (diff) | |
download | gcc-71e955da39cea0ebffcfee3432effa622d14ca99.zip gcc-71e955da39cea0ebffcfee3432effa622d14ca99.tar.gz gcc-71e955da39cea0ebffcfee3432effa622d14ca99.tar.bz2 |
Merge from trunk revision 837eb12629dd8a8a45fac9b8db57b29ecda46f14.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 59 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/analyzer/placement-new.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/analyzer/pr100244.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/malloc-1.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/pr104560-1.c | 43 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/pr104560-2.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/realloc-1.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/torture/uninit-pr63311.c | 134 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/uninit-pr104576.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/vla-1.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/pr99708.c | 21 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/analyzer/uninit-pr63311.f90 | 39 |
15 files changed, 382 insertions, 18 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5230f00..7ddcc12 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,62 @@ +2022-02-16 David Malcolm <dmalcolm@redhat.com> + + PR analyzer/104560 + * g++.dg/analyzer/placement-new.C: Update expected wording. + * g++.dg/analyzer/pr100244.C: Likewise. + * gcc.dg/analyzer/attr-malloc-1.c (test_7): Likewise. + * gcc.dg/analyzer/malloc-1.c (test_24): Likewise. + (test_25): Likewise. + (test_26): Likewise. + (test_50a, test_50b, test_50c): New. + * gcc.dg/analyzer/malloc-callbacks.c (test_5): Update expected + wording. + * gcc.dg/analyzer/malloc-paths-8.c: Likewise. + * gcc.dg/analyzer/pr104560-1.c: New test. + * gcc.dg/analyzer/pr104560-2.c: New test. + * gcc.dg/analyzer/realloc-1.c (test_7): Updated expected wording. + * gcc.dg/analyzer/vla-1.c (test_2): New. Prune output from + -Wfree-nonheap-object. + +2022-02-16 Patrick Palka <ppalka@redhat.com> + + PR c++/104507 + * g++.dg/template/non-dependent21.C: New test. + +2022-02-16 Jakub Jelinek <jakub@redhat.com> + + PR target/104448 + * gcc.target/i386/pr104448.c: New test. + +2022-02-16 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/104544 + * gcc.dg/pr104544.c: New test. + +2022-02-16 Richard Sandiford <richard.sandiford@arm.com> + + * gcc.target/aarch64/atomic-inst-cas.c: Add + -Wno-invalid-memory-model. + +2022-02-16 Richard Sandiford <richard.sandiford@arm.com> + + * gcc.target/aarch64/bic-bitmask-1.c: Remove XFAIL. + +2022-02-16 Richard Sandiford <richard.sandiford@arm.com> + + PR target/100056 + * gcc.target/aarch64/pr100056.c: XFAIL the original UBFIZ test + and instead expect two UBFIZs + two ADD UXTBs. + +2022-02-16 Jakub Jelinek <jakub@redhat.com> + + PR c/104531 + * c-c++-common/gomp/atomic-31.c: New test. + +2022-02-16 Jakub Jelinek <jakub@redhat.com> + + PR c/104510 + * gcc.dg/dfp/pr104510.c: New test. + 2022-02-15 Peter Bergner <bergner@linux.ibm.com> * gcc.target/powerpc/htm-1.c: Retry intermittent failing tbegins. diff --git a/gcc/testsuite/g++.dg/analyzer/placement-new.C b/gcc/testsuite/g++.dg/analyzer/placement-new.C index b648a42..8905549 100644 --- a/gcc/testsuite/g++.dg/analyzer/placement-new.C +++ b/gcc/testsuite/g++.dg/analyzer/placement-new.C @@ -20,9 +20,9 @@ void test_2 (void) void test_3 (void) { - char buf[sizeof(int)]; + char buf[sizeof(int)]; // { dg-message "region created on stack here" } int *p = new(buf) int (42); - delete p; // { dg-warning "memory not on the heap" } + delete p; // { dg-warning "memory on the stack" } } // { dg-prune-output "-Wfree-nonheap-object" } diff --git a/gcc/testsuite/g++.dg/analyzer/pr100244.C b/gcc/testsuite/g++.dg/analyzer/pr100244.C index 261b3cf..1d5e13d 100644 --- a/gcc/testsuite/g++.dg/analyzer/pr100244.C +++ b/gcc/testsuite/g++.dg/analyzer/pr100244.C @@ -11,7 +11,7 @@ struct _Hashtable_alloc { int _M_single_bucket; int *_M_buckets; _Hashtable_alloc () { _M_buckets = &_M_single_bucket; } - ~_Hashtable_alloc () { delete _M_buckets; } // { dg-warning "not on the heap" } + ~_Hashtable_alloc () { delete _M_buckets; } // { dg-warning "on the stack" } }; void diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c index a9a2a3d..e956cf5 100644 --- a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c @@ -70,7 +70,7 @@ void test_6 (struct foo *p) void test_7 () { struct foo f; - foo_release (&f); /* { dg-warning "not on the heap" "analyzer" } */ + foo_release (&f); /* { dg-warning "on the stack" "analyzer" } */ /* { dg-warning "'foo_release' called on unallocated object 'f'" "non-analyzer" { target *-*-* } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c index 3219f85..d69a605 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c @@ -271,23 +271,23 @@ int *test_23a (int n) int test_24 (void) { - void *ptr = __builtin_alloca (sizeof (int)); /* { dg-message "memory is allocated on the stack here" } */ - free (ptr); /* { dg-warning "'free' of memory allocated on the stack by 'alloca' \\('ptr'\\) will corrupt the heap \\\[CWE-590\\\]" } */ + void *ptr = __builtin_alloca (sizeof (int)); /* { dg-message "region created on stack here" } */ + free (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack \\\[CWE-590\\\]" } */ } int test_25 (void) { - char tmp[100]; - void *p = tmp; /* { dg-message "pointer is from here" } */ - free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ + char tmp[100]; /* { dg-message "region created on stack here" } */ + void *p = tmp; + free (p); /* { dg-warning "'free' of 'p' which points to memory on the stack \\\[CWE-590\\\]" } */ /* TODO: more precise messages here. */ } -char global_buffer[100]; +char global_buffer[100]; /* { dg-message "region created here" } */ int test_26 (void) { - void *p = global_buffer; /* { dg-message "pointer is from here" } */ + void *p = global_buffer; free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ /* TODO: more precise messages here. */ } @@ -608,4 +608,22 @@ int test_49 (int i) return x; } +/* Free of function, and of label within function. */ + +void test_50a (void) +{ +} + +void test_50b (void) +{ + free (test_50a); /* { dg-warning "'free' of '&test_50a' which points to memory not on the heap \\\[CWE-590\\\]" } */ +} + +void test_50c (void) +{ + my_label: + free (&&my_label); /* { dg-warning "'free' of '&my_label' which points to memory not on the heap \\\[CWE-590\\\]" } */ +} + + /* { dg-prune-output "\\\[-Wfree-nonheap-object" } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c index 8820ddd..c79f80d 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c @@ -61,9 +61,8 @@ int *test_5 (void) { allocator_t alloc_fn = get_alloca (); deallocator_t dealloc_fn = get_free (); - int *ptr = alloc_fn (sizeof (int)); /* { dg-message "pointer is from here" } */ - /* TODO: message should read "memory is allocated on the stack here". */ - dealloc_fn (ptr); /* { dg-warning "'free' of 'ptr' which points to memory not on the heap" } */ + int *ptr = alloc_fn (sizeof (int)); /* dg-message "region created on stack here" } */ + dealloc_fn (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack" } */ } static void __attribute__((noinline)) diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c index 9a7c414..4988f53 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c @@ -40,7 +40,7 @@ void test_3 (size_t sz) { void *ptr; if (sz <= LIMIT) - ptr = __builtin_alloca (sz); /* { dg-message "memory is allocated on the stack here" } */ + ptr = __builtin_alloca (sz); /* { dg-message "region created on stack here" } */ else ptr = malloc (sz); @@ -49,7 +49,7 @@ void test_3 (size_t sz) /* Bug: the "sz <= LIMIT" above should have been "sz < LIMIT", so there's a free-of-alloca when sz == LIMIT. */ if (sz >= LIMIT) - free (ptr); /* { dg-warning "'free' of memory allocated on the stack by 'alloca'" } */ + free (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack" } */ } /* { dg-bogus "leak of 'ptr'" } */ /* This can't happen, as "sz > 1024" && "sz <= 1023" is impossible. */ diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104560-1.c b/gcc/testsuite/gcc.dg/analyzer/pr104560-1.c new file mode 100644 index 0000000..aeab4b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr104560-1.c @@ -0,0 +1,43 @@ +/* Reduced/adapted from false positive from -Wanalyzer-free-of-non-heap + seen on rdma-core. */ + +#include <stddef.h> + +#define check_types_match(expr1, expr2) \ + ((typeof(expr1) *)0 != (typeof(expr2) *)0) + +#define container_of(member_ptr, containing_type, member) \ + ((containing_type *) \ + ((char *)(member_ptr) \ + - container_off(containing_type, member)) \ + + check_types_match(*(member_ptr), ((containing_type *)0)->member)) + +#define container_off(containing_type, member) \ + offsetof(containing_type, member) + +struct ibv_device { + /* [...snip...] */ +}; + +struct verbs_device { + struct ibv_device device; /* Must be first */ + /* [...snip...] */ + int placeholder; +}; + +struct mlx5_device { + struct verbs_device verbs_dev; + int placeholder; +}; + +static inline struct mlx5_device *to_mdev(struct ibv_device *ibdev) +{ + return container_of(ibdev, struct mlx5_device, verbs_dev.device); +} + +static void mlx5_uninit_device(struct verbs_device *verbs_device) +{ + struct mlx5_device *dev = to_mdev(&verbs_device->device); + + __builtin_free(dev); /* { dg-bogus "not on the heap" } */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104560-2.c b/gcc/testsuite/gcc.dg/analyzer/pr104560-2.c new file mode 100644 index 0000000..f968a58 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr104560-2.c @@ -0,0 +1,26 @@ +struct ibv_device { + /* [...snip...] */ + int placeholder; +}; + +struct verbs_device { + struct ibv_device device; /* Must be first */ + /* [...snip...] */ + int placeholder; +}; + +struct mlx5_device { + struct verbs_device verbs_dev; + int placeholder; +}; + +static inline struct mlx5_device *to_mdev(struct ibv_device *ibdev) +{ + return (struct mlx5_device *)ibdev; +} + +static void mlx5_uninit_device(struct verbs_device *verbs_device) +{ + struct mlx5_device *dev = to_mdev(&verbs_device->device); + __builtin_free(dev); /* { dg-bogus "not on the heap" } */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-1.c b/gcc/testsuite/gcc.dg/analyzer/realloc-1.c index ef117ad..9951e11 100644 --- a/gcc/testsuite/gcc.dg/analyzer/realloc-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/realloc-1.c @@ -59,8 +59,8 @@ void test_6 (size_t sz) void *test_7 (size_t sz) { - char buf[100]; - void *p = realloc (&buf, sz); /* { dg-warning "'realloc' of '&buf' which points to memory not on the heap" } */ + char buf[100]; /* { dg-message "region created on stack here" } */ + void *p = realloc (&buf, sz); /* { dg-warning "'realloc' of '&buf' which points to memory on the stack" } */ return p; } diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/uninit-pr63311.c b/gcc/testsuite/gcc.dg/analyzer/torture/uninit-pr63311.c new file mode 100644 index 0000000..a73289c --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/uninit-pr63311.c @@ -0,0 +1,134 @@ +/* { dg-additional-options "-Wno-analyzer-too-complex" } */ + +int foo () +{ + static volatile int v = 42; + int __result_foo; + + __result_foo = (int) v; + return __result_foo; +} + +void test (int * restrict n, int * restrict flag) +{ + int i; + int j; + int k; + double t; + int tt; + double v; + + if (*flag) + { + t = 4.2e+1; + tt = foo (); + } + L_1: ; + v = 0.0; + { + int D_3353; + + D_3353 = *n; + i = 1; + if (i <= D_3353) + { + while (1) + { + { + int D_3369; + + v = 0.0; + if (*flag) + { + if (tt == i) + { + { + double M_0; + + M_0 = v; + if (t > M_0 || (int) (M_0 != M_0)) + { + M_0 = t; + } + v = M_0; + } + } + L_5:; + } + L_4:; + { + int D_3359; + + D_3359 = *n; + j = 1; + if (j <= D_3359) + { + while (1) + { + { + int D_3368; + + { + int D_3362; + + D_3362 = *n; + k = 1; + if (k <= D_3362) + { + while (1) + { + { + int D_3367; + + { + double D_3366; + double M_1; + + M_1 = v; + D_3366 = (double) __builtin_sinf ((float) (j * k)); + if (D_3366 > M_1 || (int) (M_1 != M_1)) + { + M_1 = D_3366; + } + v = M_1; + } + L_8:; + D_3367 = k == D_3362; + k = k + 1; + if (D_3367) goto L_9; + } + } + } + L_9:; + } + L_6:; + D_3368 = j == D_3359; + j = j + 1; + if (D_3368) goto L_7; + } + } + } + L_7:; + } + L_2:; + D_3369 = i == D_3353; + i = i + 1; + if (D_3369) goto L_3; + } + } + } + L_3:; + } +} + + +int main () +{ + int flag; + int n; + + n = 4; + flag = 0; + test (&n, &flag); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-pr104576.c b/gcc/testsuite/gcc.dg/analyzer/uninit-pr104576.c new file mode 100644 index 0000000..0b59acd --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/uninit-pr104576.c @@ -0,0 +1,16 @@ +float +test_1 (int *flag, float theta) +{ + float t; + float f; + + if (*flag) + t = 2.0f; + + f = __builtin_sinf (theta); + + if (*flag) + f *= t; + + return f; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/vla-1.c b/gcc/testsuite/gcc.dg/analyzer/vla-1.c index e5971c8..9561d74 100644 --- a/gcc/testsuite/gcc.dg/analyzer/vla-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/vla-1.c @@ -12,3 +12,12 @@ void test_1 (int n) s.b = 17; __analyzer_eval (s.b == 17); /* { dg-warning "TRUE" } */ } + +void test_2 (int n) +{ + int arr[n]; /* { dg-message "region created on stack here" } */ + __builtin_free (arr); /* { dg-warning "'free' of '<unknown>' which points to memory on the stack" } */ + // TODO: fix the "unknown" here +} + +/* { dg-prune-output "\\\[-Wfree-nonheap-object" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr99708.c b/gcc/testsuite/gcc.target/powerpc/pr99708.c new file mode 100644 index 0000000..d478f7bc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr99708.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { require-effective-target ppc_float128_sw } */ +/* { dg-options "-O2 -mvsx -mfloat128" } */ + +/* + * PR target/99708 + * + * Verify that __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__ are properly defined. + */ + +#include <stdlib.h> + +int main (void) +{ + if (__SIZEOF_FLOAT128__ != sizeof (__float128) + || __SIZEOF_IBM128__ != sizeof (__ibm128)) + abort (); + + return 0; +} + diff --git a/gcc/testsuite/gfortran.dg/analyzer/uninit-pr63311.f90 b/gcc/testsuite/gfortran.dg/analyzer/uninit-pr63311.f90 new file mode 100644 index 0000000..34cc25d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/analyzer/uninit-pr63311.f90 @@ -0,0 +1,39 @@ +! { dg-additional-options "-O0" } + +MODULE M1 + IMPLICIT NONE +CONTAINS + INTEGER FUNCTION foo() + INTEGER, VOLATILE :: v=42 + foo=v + END FUNCTION + SUBROUTINE test(n,flag) + INTEGER :: n,i,j,k,l,tt + LOGICAL :: flag + REAL(KIND=8) :: v,t + IF (flag) THEN + t=42 + tt=foo() + ENDIF + v=0 + DO i=1,n + v=0 + IF (flag) THEN + IF (tt==i) v=MAX(v,t) + ENDIF + DO j=1,n + DO k=1,n + v=MAX(v,sin(REAL(j*k))) + ENDDO + ENDDO + ENDDO + END SUBROUTINE +END MODULE M1 + +USE M1 +INTEGER :: n +LOGICAL :: flag +n=4 +flag=.FALSE. +CALL test(n,flag) +END |