aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/vla-1.c
blob: 9561d742c3a8ed86bf6df743e9caaa3b6a95d151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* { dg-require-effective-target alloca } */
#include "analyzer-decls.h"

void test_1 (int n)
{
  struct
  {
    char a[n], b;
  } s;
  s.a[0] = 42;
  __analyzer_eval (s.a[0] == 42); /* { dg-warning "TRUE" } */
  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" } */