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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [format/] [multattr-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Test for multiple format attributes.  Test for printf and scanf attributes
2
   together.  */
3
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4
/* { dg-do compile } */
5
/* { dg-options "-std=gnu99 -Wformat" } */
6
 
7
#include "format.h"
8
 
9
/* If we specify multiple attributes for a single function, they should
10
   all apply.  This should apply whether they are on the same declaration
11
   or on different declarations.  */
12
 
13
extern void my_vprintf_scanf (const char *, va_list, const char *, ...)
14
     __attribute__((__format__(__printf__, 1, 0)))
15
     __attribute__((__format__(__scanf__, 3, 4)));
16
 
17
extern void my_vprintf_scanf2 (const char *, va_list, const char *, ...)
18
     __attribute__((__format__(__scanf__, 3, 4)))
19
     __attribute__((__format__(__printf__, 1, 0)));
20
 
21
extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
22
     __attribute__((__format__(__printf__, 1, 0)));
23
extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
24
     __attribute__((__format__(__scanf__, 3, 4)));
25
 
26
extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
27
     __attribute__((__format__(__scanf__, 3, 4)));
28
extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
29
     __attribute__((__format__(__printf__, 1, 0)));
30
 
31
void
32
foo (va_list ap, int *ip, long *lp)
33
{
34
  my_vprintf_scanf ("%d", ap, "%d", ip);
35
  my_vprintf_scanf ("%d", ap, "%ld", lp);
36
  my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
37
  my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
38
  my_vprintf_scanf2 ("%d", ap, "%d", ip);
39
  my_vprintf_scanf2 ("%d", ap, "%ld", lp);
40
  my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
41
  my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
42
  my_vprintf_scanf3 ("%d", ap, "%d", ip);
43
  my_vprintf_scanf3 ("%d", ap, "%ld", lp);
44
  my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
45
  my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
46
  my_vprintf_scanf4 ("%d", ap, "%d", ip);
47
  my_vprintf_scanf4 ("%d", ap, "%ld", lp);
48
  my_vprintf_scanf4 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
49
  my_vprintf_scanf4 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
50
}

powered by: WebSVN 2.1.0

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