1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
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 ());
40 myopen ("i", 0x43, 0644, 0655);