Require effective target alloca in a few test-cases.
Tested on nvptx.
gcc/testsuite/ChangeLog:
2022-02-10 Tom de Vries <tdevries@suse.de>
* c-c++-common/Walloca-larger-than.c: Require effective target alloca.
* c-c++-common/Warray-bounds-9.c: Same.
* c-c++-common/Wdangling-pointer-2.c: Same.
* c-c++-common/Wdangling-pointer-4.c: Same.
* c-c++-common/Wdangling-pointer-5.c: Same.
* c-c++-common/Wdangling-pointer.c: Same.
* c-c++-common/auto-init-11.c: Same.
* c-c++-common/auto-init-12.c: Same.
* c-c++-common/auto-init-15.c: Same.
* c-c++-common/auto-init-16.c: Same.
* c-c++-common/torture/builtin-clear-padding-4.c: Same.
* gcc.c-torture/compile/pr99787-1.c: Same.
* gcc.dg/Walloca-larger-than-4.c: Same.
* gcc.dg/Wdangling-pointer.c: Same.
* gcc.dg/Wfree-nonheap-object-2.c: Same.
* gcc.dg/Wfree-nonheap-object.c: Same.
* gcc.dg/Wstringop-overflow-56.c: Same.
* gcc.dg/Wstringop-overflow-57.c: Same.
* gcc.dg/Wstringop-overflow-67.c: Same.
* gcc.dg/Wstringop-overflow-71.c: Same.
* gcc.dg/Wvla-larger-than-5.c: Same.
* gcc.dg/analyzer/taint-alloc-1.c: Same.
* gcc.dg/analyzer/torture/ubsan-1.c: Same.
* gcc.dg/graphite/pr99085.c: Same.
* gcc.dg/pr100225.c: Same.
* gcc.dg/pr98721-1.c: Same.
* gcc.dg/pr99122-2.c: Same.
* gcc.dg/sso-14.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-25.c: Same.
* gcc.dg/uninit-38.c: Same.
* gcc.dg/uninit-39.c: Same.
* gcc.dg/uninit-41.c: Same.
* gcc.dg/uninit-pr100250.c: Same.
* gcc.dg/uninit-pr101300.c: Same.
* gcc.dg/uninit-pr101494.c: Same.
* gcc.dg/uninit-pr98578.c: Same.
* gcc.dg/uninit-pr98583.c: Same.
* gcc.dg/vla-stexp-1.c: Same.
* gcc.dg/vla-stexp-2.c: Same.
* gcc.dg/vla-stexp-4.c: Same.
* gcc.dg/vla-stexp-5.c: Same.
/* PR middle-end/100425 - missing -Walloca-larger-than with -O0
{ dg-do compile }
- { dg-options "-O0 -Wall -Walloca-larger-than=128" } */
+ { dg-options "-O0 -Wall -Walloca-larger-than=128" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
/* PR tree-optimization/99121 - ICE in -Warray-bounds on a multidimensional
VLA
{ dg-do compile }
- { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */
+ { dg-options "-O2 -Wall -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
#define NOIPA __attribute__ ((noipa))
variable within the same function
Exercise basic cases of -Wdangling-pointer with optimization.
{ dg-do compile }
- { dg-options "-O2 -Wall -Wno-uninitialized -Wno-return-local-addr -ftrack-macro-expansion=0" } */
+ { dg-options "-O2 -Wall -Wno-uninitialized -Wno-return-local-addr -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
typedef __INTPTR_TYPE__ intptr_t;
typedef __SIZE_TYPE__ size_t;
variable within the same function
Exercise -Wdangling-pointer for VLAs.
{ dg-do compile }
- { dg-options "-O0 -Wall -ftrack-macro-expansion=0" } */
+ { dg-options "-O0 -Wall -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
void sink (void*, ...);
Exercise -Wdangling-pointer for escaping stores of addreses of auto
variables.
{ dg-do compile }
- { dg-options "-O0 -Wall -ftrack-macro-expansion=0" } */
+ { dg-options "-O0 -Wall -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
void* alloca (__SIZE_TYPE__);
variable within the same function
Exercise basic cases of -Wdangling-pointer without optimization.
{ dg-do compile }
- { dg-options "-O0 -Wall -Wno-uninitialized -ftrack-macro-expansion=0" } */
+ { dg-options "-O0 -Wall -Wno-uninitialized -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
typedef __INTPTR_TYPE__ intptr_t;
typedef __SIZE_TYPE__ size_t;
/* Verify zero initialization for VLA automatic variables. */
/* { dg-do compile } */
/* { dg-options "-ftrivial-auto-var-init=zero -fdump-tree-gimple" } */
+/* { dg-require-effective-target alloca } */
extern void bar (int);
/* Verify zero initialization for VLA automatic variables. */
/* { dg-do compile } */
/* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */
+/* { dg-require-effective-target alloca } */
extern void bar (int);
/* Verify the auto initialization of nested VLA. */
/* { dg-do compile } */
/* { dg-options "-ftrivial-auto-var-init=zero -fdump-tree-gimple" } */
+/* { dg-require-effective-target alloca } */
void g(void *);
/* Verify the auto initialization of nested VLA. */
/* { dg-do compile } */
/* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */
+/* { dg-require-effective-target alloca } */
void g(void *);
+/* { dg-require-effective-target alloca } */
+
/* PR libstdc++/88101 */
struct S { char a; short b; char c; };
/* { dg-options "-ftree-slp-vectorize -ffp-contract=on -ffloat-store" } */
+/* { dg-require-effective-target alloca } */
_Complex foo_x_0;
int foo_n11, foo_i, foo_l;
/* PR middle-end/100425 - missing -Walloca-larger-than with -O0
{ dg-do compile }
- { dg-options "-O0 -Wall -Walloca-larger-than=128" } */
+ { dg-options "-O0 -Wall -Walloca-larger-than=128" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
/* Exercise basic C-only cases of -Wdangling-pointer.
{ dg-do compile }
- { dg-options "-O0 -Wall" } */
+ { dg-options "-O0 -Wall" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
Verify that attempting to reallocate unallocated objects referenced
either directly or through pointers is diagnosed.
{ dg-do compile }
- { dg-options "-O2 -Wall -Wfree-nonheap-object" } */
+ { dg-options "-O2 -Wall -Wfree-nonheap-object" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
or through pointers is diagnosed. In most cases this doesn't require
optimization.
{ dg-do compile }
- { dg-options "-Wall -Wfree-nonheap-object" } */
+ { dg-options "-Wall -Wfree-nonheap-object" }
+ { dg-require-effective-target alloca } */
typedef __INTPTR_TYPE__ intptr_t;
typedef __SIZE_TYPE__ size_t;
/* PR middle-end/92942 - missing -Wstringop-overflow for allocations with
a negative lower bound size
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
#define SIZE_MAX __SIZE_MAX__
#define UINT8_MAX __UINT8_MAX__
/* Verify that an anti-range ~[A, B] with small positive A and B
is handled correctly and doesn't trigger warnings.
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
typedef __typeof__ (sizeof 0) size_t;
/* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements
larger than byte
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
__attribute__ ((access (read_only, 1, 2))) void fro (int *, int);
__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int);
a larger scalar into a smaller array
Verify warnings for overflow by stores of results of built-in functions.
{ dg-do compile }
- { dg-options "-O2" } */
+ { dg-options "-O2" }
+ { dg-require-effective-target alloca } */
typedef __INT16_TYPE__ int16_t;
typedef __SIZE_TYPE__ size_t;
/* PR middle-end/100510 - bogus -Wvla-large-than with -Walloca
{ dg-do compile }
- { dg-options "-O0 -Walloca -Wvla-larger-than=1000" } */
+ { dg-options "-O0 -Walloca -Wvla-larger-than=1000" }
+ { dg-require-effective-target alloca } */
void f (void*);
// TODO: remove need for this option
/* { dg-additional-options "-fanalyzer-checker=taint" } */
+/* { dg-require-effective-target alloca } */
#include "analyzer-decls.h"
#include <stdio.h>
/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
/* { dg-additional-options "-fsanitize=bounds" } */
+/* { dg-require-effective-target alloca } */
#include <stdlib.h>
#include "../analyzer-decls.h"
/* PR target/99085 */
/* { dg-do compile } */
/* { dg-options "-O2 -fgraphite-identity -fsel-sched-pipelining -fselective-scheduling2" } */
+/* { dg-require-effective-target alloca } */
void
foo (int m, int n, int o, int i)
/* PR rtl-optimization/100225 */
/* { dg-do compile } */
/* { dg-options "-O1 -fmodulo-sched" } */
+/* { dg-require-effective-target alloca } */
void
vorbis_synthesis_lapout (void);
/* PR tree-optimization/98721 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
+/* { dg-require-effective-target alloca } */
int
foo (int n)
/* { dg-do compile } */
/* { dg-options "-O2 -g -w" } */
+/* { dg-require-effective-target alloca } */
static int foo ();
/* Testcase by George Thopas <george.thopas@gmail.com> */
/* { dg-do compile } */
+/* { dg-require-effective-target alloca } */
#include <stddef.h>
#include <stdlib.h>
/* PR middle-end/97373 - missing warning on sprintf into allocated destination
{ dg-do compile }
- { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */
+ { dg-options "-O2 -Wall -ftrack-macro-expansion=0" }
+ { dg-require-effective-target alloca } */
#include "../range.h"
be adjusted. Ditto if -Wuninitialized output changes for some
other reason.
{ dg-do compile { target { { lp64 || ilp32 } || llp64 } } }
- { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -fno-ipa-modref" } */
+ { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -fno-ipa-modref" }
+ { dg-require-effective-target alloca } */
#define CONCAT(x, y) x ## y
#define CAT(x, y) CONCAT(x, y)
/* PR c/98592 - ICE in gimple_canonical_types_compatible_p while formatting
a MEM_REF
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
void f (int);
/* Verify that calls to non-modifying built-ins aren't considered
potentially modifying.
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
/* PR middle-end/100250 - ICE related to -Wmaybe-uninitialized
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
extern void f (int D, const int[D], const int[D]);
/* PR middle-end/101300 - -fsanitize=undefined suppresses -Wuninitialized
for a VLA read at -O0
{ dg-do compile }
- { dg-options "-O0 -Wall -fsanitize=undefined" } */
+ { dg-options "-O0 -Wall -fsanitize=undefined" }
+ { dg-require-effective-target alloca } */
int warn_vla_rd0 (int n)
{
/* PR middle-end/101494 - bogus -Wmaybe-uninitialized on memrchr of size 0
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
/* PR middle-end/98578 - ICE warning on uninitialized VLA access
{ dg-do compile }
- { dg-options "-O2 -Wall -fno-ipa-modref" } */
+ { dg-options "-O2 -Wall -fno-ipa-modref" }
+ { dg-require-effective-target alloca } */
void* malloc (__SIZE_TYPE__);
/* PR middle-end/98583 - missing -Wuninitialized reading from a second VLA
in its own block
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall" }
+ { dg-require-effective-target alloca } */
void f (int*);
void g (int);
/* PR29970*/
/* { dg-do run } */
/* { dg-options "-Wall -O0" } */
+/* { dg-require-effective-target alloca } */
int foo(void)
{
/* PR101838 */
/* { dg-do run } */
/* { dg-options "-Wpedantic -O0" } */
+/* { dg-require-effective-target alloca } */
int bar0(
/* PR29970, PR91038 */
/* { dg-do run } */
/* { dg-options "-O0 -Wunused-variable" } */
+/* { dg-require-effective-target alloca } */
int foo3b(void) // should not return 0
{
/* PR29970 */
/* { dg-do run } */
/* { dg-options "-Wunused-variable" } */
+/* { dg-require-effective-target alloca } */