annotate gcc/testsuite/gcc.dg/pr30457.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR 30457 warn about va_start(ap, invalid) */
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-std=c99" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 /* Undefined by C99 7.15.1.4p4 (va_start):
kono
parents:
diff changeset
6 "If the parameter parmN is declared with the register storage
kono
parents:
diff changeset
7 class, with a function or array type, or with a type that is
kono
parents:
diff changeset
8 not compatible with the type that results after application of
kono
parents:
diff changeset
9 the default argument promotions, the behavior is undefined." */
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 #include <stdarg.h>
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 void foo(register short paramN, ...)
kono
parents:
diff changeset
14 {
kono
parents:
diff changeset
15 va_list ap;
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 va_start(ap, paramN); /* { dg-warning "undefined behavior when second parameter of 'va_start' is declared with 'register' storage" } */
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 /* Undefined by C99 7.15.1.1p2: */
kono
parents:
diff changeset
20 (void) va_arg(ap, char); /* { dg-warning "'char' is promoted to 'int' when passed through '...'" "promoted" } */
kono
parents:
diff changeset
21 /* { dg-message "note: .so you should pass .int. not .char. to .va_arg.." "int not char" { target *-*-* } .-1 } */
kono
parents:
diff changeset
22 /* { dg-message "note: if this code is reached, the program will abort" "will abort" { target *-*-* } .-2 } */
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 va_end(ap);
kono
parents:
diff changeset
25 }
kono
parents:
diff changeset
26