aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/Wvarargs.c
blob: 408f427b5c458221df63634a1d066e4d4effef9c (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
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
/* { dg-do compile } */

#include <stdarg.h>

void
err (int a)
{
  va_list vp;
  va_start (vp, a); // { dg-error "used in function with fixed args" }
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvarargs"

void
foo0 (int a, int b, ...)
{
    va_list vp;
    /* 'a' is not the last argument of the enclosing function, but
       don't warn because we are ignoring -Wvarargs.  */
    va_start (vp, a);
    va_end (vp);
}

void
foo1 (int a, register int b, ...)
{
    va_list vp;
    /* 'b' is declared with register storage, but don't warn
       because we are ignoring -Wvarargs.  */
    va_start (vp, b);
    va_end (vp);
}

#pragma GCC diagnostic pop

void
foo2 (int a, int b, ...)
{
    va_list vp;
    /* 'a' is not the last argument of the enclosing function, so
       warn.  */
    va_start (vp, a); /* { dg-warning "second parameter" } */
    va_end (vp);
}

void
foo3 (int a, register int b, ...)
{
    va_list vp;
    /* 'b' is declared with register storage, so warn.  */
    va_start (vp, b); /* { dg-warning "undefined behaviour" } */
    va_end (vp);
}