PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / va-arg-pack-len-2.c
blobc3fa856fdaa54631282d1bc7ae3ae5fc96d5f067
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
4 #include <stdarg.h>
6 extern int error_open_missing_mode (void)
7 __attribute__((__error__ ("open with O_CREAT needs 3 arguments, only 2 were given")));
8 extern int warn_open_too_many_arguments (void)
9 __attribute__((__warning__ ("open called with more than 3 arguments")));
11 extern int myopen2 (const char *path, int oflag);
12 extern int myopenva (const char *path, int oflag, ...);
14 extern inline __attribute__((always_inline, gnu_inline)) int
15 myopen (const char *path, int oflag, ...)
17 if (__builtin_va_arg_pack_len () > 1)
18 warn_open_too_many_arguments (); /* { dg-warning "called with more than 3" } */
20 if (__builtin_constant_p (oflag))
22 if ((oflag & 0x40) != 0 && __builtin_va_arg_pack_len () < 1)
24 error_open_missing_mode (); /* { dg-error "needs 3 arguments, only 2 were given" } */
25 return myopen2 (path, oflag);
27 return myopenva (path, oflag, __builtin_va_arg_pack ());
30 if (__builtin_va_arg_pack_len () < 1)
31 return myopen2 (path, oflag);
33 return myopenva (path, oflag, __builtin_va_arg_pack ());
36 int
37 main (void)
39 myopen ("h", 0x43);
40 myopen ("i", 0x43, 0644, 0655);
41 return 0;