1/* Test for multiple format attributes. Test for printf and scanf attributes 2 together, in different places on the declarations. */ 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, wherever they are placed on the declarations. */ 11 12extern __attribute__((__format__(__printf__, 1, 0))) void 13 my_vprintf_scanf (const char *, va_list, const char *, ...) 14 __attribute__((__format__(__scanf__, 3, 4))); 15 16extern void (__attribute__((__format__(__printf__, 1, 0))) my_vprintf_scanf2) 17 (const char *, va_list, const char *, ...) 18 __attribute__((__format__(__scanf__, 3, 4))); 19 20extern __attribute__((__format__(__scanf__, 3, 4))) void 21 (__attribute__((__format__(__printf__, 1, 0))) my_vprintf_scanf3) 22 (const char *, va_list, const char *, ...); 23 24void 25foo (va_list ap, int *ip, long *lp) 26{ 27 my_vprintf_scanf ("%d", ap, "%d", ip); 28 my_vprintf_scanf ("%d", ap, "%ld", lp); 29 my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */ 30 my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */ 31 my_vprintf_scanf2 ("%d", ap, "%d", ip); 32 my_vprintf_scanf2 ("%d", ap, "%ld", lp); 33 my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */ 34 my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */ 35 my_vprintf_scanf3 ("%d", ap, "%d", ip); 36 my_vprintf_scanf3 ("%d", ap, "%ld", lp); 37 my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */ 38 my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */ 39} 40