view gcc/testsuite/gcc.dg/Warray-bounds-41.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

/* PR tree-optimization/89662- -Warray-bounds ICE on void* arithmetic
   { dg-do compile }
   { dg-require-effective-target alloca }
   { dg-options "-O2 -Wall" } */

static void* vptr (void *c)
{
  return c;
}

void sink (void*);

void test_vptr_arith_vla_cst (void)
{
  int n = 1;
  char c[n];
  sink (vptr (c) - 1);    /* { dg-warning "\\\[-Warray-bounds" } */
}

void test_vptr_arith_vla_range (int n)
{
  if (n < 1 || 4 < n)
    return;

  char c[n];
  sink (vptr (c) - 1);    /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */
}

void test_vptr_arith_vla_var (int n)
{
  char c[n];
  sink (vptr (c) - 1);    /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */
}