File: Wvla-parameter-4.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (94 lines) | stat: -rw-r--r-- 3,147 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* PR c/50584 - No warning for passing small array to C99 static array
   declarator
   Verify warnings for redeclarations of functions with pointer parameters
   to arrays with variable bounds involving typedefs.
   { dg-do compile }
   { dg-options "-Wall -Wvla-parameter" } */

extern int m, n;

typedef int IA3[3];

/* Verify the warning points to the declaration with more unspecified
   bounds, guiding the user to specify them rather than making them all
   unspecified.  */

void* f_pIA3an (IA3 *x[n]);              // { dg-message "previously declared as 'int \\\(\\\*\\\[n]\\\)\\\[3]' with 0 unspecified variable bounds" "note" }
void* f_pIA3an (IA3 *x[n]);
void* f_pIA3an (IA3 *x[*]);              // { dg-warning "argument 1 of type 'int \\\(\\\*\\\[\\\*]\\\)\\\[3]' .aka '\[^\n\r\}\]+'. declared with 1 unspecified variable bound" }
void* f_pIA3an (IA3 *x[n]) { return x; }


void nowarn_local_fndecl (void)
{
  typedef int IAm[m];

  void* f_IAm (IAm);
  void* f_IAm (int[m]);
  void* f_IAm (IAm);

  void* f_iam (int[m]);
  void* f_iam (IAm);
  void* f_iam (int[m]);

  typedef int     IA3[3];
  typedef IA3     IAn_3[n];
  typedef IAn_3   IA2_n_3[2];
  typedef IA2_n_3 IAm_2_n_3[m];

  void f_IAm_2_n_3 (IAm_2_n_3);
  void f_IAm_2_n_3 (IA2_n_3[m]);
  void f_IAm_2_n_3 (IAn_3[m][2]);
  void f_IAm_2_n_3 (IA3[m][2][n]);
  void f_IAm_2_n_3 (int[m][2][n][3]);

  void f_iam_2_n_3 (int[m][2][n][3]);
  void f_iam_2_n_3 (IA3[m][2][n]);
  void f_iam_2_n_3 (IAn_3[m][2]);
  void f_iam_2_n_3 (IAm_2_n_3);

  void f_IAx_m_2_n_3 (IAm_2_n_3[*]);
  void f_IAx_m_2_n_3 (IA2_n_3[*][m]);
  void f_IAx_m_2_n_3 (IAn_3[*][m][2]);
  void f_IAx_m_2_n_3 (IA3[*][m][2][n]);
  void f_IAx_m_2_n_3 (int[*][m][2][n][3]);

  void f_IA__m_2_n_3 (IAm_2_n_3[]);
  void f_IA__m_2_n_3 (IA2_n_3[][m]);
  void f_IA__m_2_n_3 (IAn_3[][m][2]);
  void f_IA__m_2_n_3 (IA3[][m][2][n]);
  void f_IA__m_2_n_3 (int[][m][2][n][3]);
}


void warn_local_fndecl (void)
{
  typedef int IAm[m];
  typedef int IAn[n];

  void* g_IAm (IAm);                    // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" }
  void* g_IAm (int[n]);                 // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" }
  void* g_IAm (IAm);

  void* g_iam (int[m]);                 // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" }
  void* g_iam (IAn);                    // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" }
  void* g_iam (int[m]);


  typedef int     IA3[3];
  typedef IA3     IAn_3[n];
  typedef IAn_3   IA2_n_3[2];
  typedef IA2_n_3 IAm_2_n_3[m];

  typedef IA3     IAm_3[m];
  typedef IAm_3   IA2_m_3[2];
  typedef IA2_m_3 IAm_2_m_3[m];

  void* g_IAm_2_n_3 (IAm_2_n_3);
  void* g_IAm_2_n_3 (int[m][2][m][3]);  // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" }
  void* g_IAm_2_n_3 (IAm_2_n_3);

  void* g_iam_2_n_2 (int[m][2][n][3]);
  void* g_iam_2_n_2 (IAm_2_m_3);        // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" }
  void* g_iam_2_n_2 (int[m][2][n][3]);
}