OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [va-arg-pack-len-2.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O2" } */
3
 
4
#include <stdarg.h>
5
 
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")));
10
 
11
extern int myopen2 (const char *path, int oflag);
12
extern int myopenva (const char *path, int oflag, ...);
13
 
14
extern inline __attribute__((always_inline, gnu_inline)) int
15
myopen (const char *path, int oflag, ...)
16
{
17
  if (__builtin_va_arg_pack_len () > 1)
18
    warn_open_too_many_arguments ();    /* { dg-warning "called with more than 3" } */
19
 
20
  if (__builtin_constant_p (oflag))
21
    {
22
      if ((oflag & 0x40) != 0 && __builtin_va_arg_pack_len () < 1)
23
        {
24
          error_open_missing_mode ();   /* { dg-error "needs 3 arguments, only 2 were given" } */
25
          return myopen2 (path, oflag);
26
        }
27
      return myopenva (path, oflag, __builtin_va_arg_pack ());
28
    }
29
 
30
  if (__builtin_va_arg_pack_len () < 1)
31
    return myopen2 (path, oflag);
32
 
33
  return myopenva (path, oflag, __builtin_va_arg_pack ());
34
}
35
 
36
int
37
main (void)
38
{
39
  myopen ("h", 0x43);
40
  myopen ("i", 0x43, 0644, 0655);
41
  return 0;
42
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.