aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-82.c
blob: ee2693dcea97a8faa4699c7c039357d46866777b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Verify that notes after warnings for array and VLA parameters show
   the array form.
   { dg-do compile }
   { dg-options "-Wall" } */

void fia5 (int[5]);

void gia3_fia5 (void)
{
  int a[3];
  fia5 (a);             // { dg-warning "-Wstringop-overflow" }
                        // { dg-message "argument 1 of type 'int\\\[5]'" "note" { target *-*-* } .-1 }
}


/* The type of the argument would ideall be 'int[n]' but the variable
   bound is lost/cleared by free-lang-data and never makes it into
   the middle end.  An (inferior) alternative would be 'int[*]' but
   the pretty printer doesn't know how to format the star.  A better
   solution might be to introduce a new notation, like 'int[$1]',
   where the $1 refers to the VLA argument bound.  */
void fvla (int n, int[n]);

void gia3_fvla (void)
{
  int a[3];
  fvla (sizeof a, a);   // { dg-warning "-Wstringop-overflow" }
                        // { dg-message "argument 2 of type 'int\\\[]'" "note" { target *-*-* } .-1 }
}