112277Sssadetsky/* Test for format attributes: test use of __attribute__. */ 212277Sssadetsky/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ 312277Sssadetsky/* { dg-do compile { target { *-*-mingw* } } } */ 412277Sssadetsky/* { dg-options "-std=gnu99 -Wformat" } */ 512277Sssadetsky 612277Sssadetsky#define DONT_GNU_PROTOTYPE 712277Sssadetsky#include "format.h" 812277Sssadetsky 912277Sssadetskyextern void tformatprintf (const char *, ...) __attribute__((format(ms_printf, 1, 2))); 1012277Sssadetskyextern void tformat__printf__ (const char *, ...) __attribute__((format(__ms_printf__, 1, 2))); 1112277Sssadetskyextern void tformatscanf (const char *, ...) __attribute__((format(ms_scanf, 1, 2))); 1212277Sssadetskyextern void tformat__scanf__ (const char *, ...) __attribute__((format(__ms_scanf__, 1, 2))); 1312277Sssadetskyextern void tformatstrftime (const char *) __attribute__((format(ms_strftime, 1, 0))); 1412277Sssadetskyextern void tformat__strftime__ (const char *) __attribute__((format(__ms_strftime__, 1, 0))); 1512277Sssadetskyextern void tformatstrfmon (const char *, ...) __attribute__((format(strfmon, 1, 2))); 1612277Sssadetskyextern void tformat__strfmon__ (const char *, ...) __attribute__((format(__strfmon__, 1, 2))); 1712277Sssadetskyextern void t__format__printf (const char *, ...) __attribute__((__format__(ms_printf, 1, 2))); 1812277Sssadetskyextern void t__format____printf__ (const char *, ...) __attribute__((__format__(__ms_printf__, 1, 2))); 1912277Sssadetskyextern void t__format__scanf (const char *, ...) __attribute__((__format__(ms_scanf, 1, 2))); 2012277Sssadetskyextern void t__format____scanf__ (const char *, ...) __attribute__((__format__(__ms_scanf__, 1, 2))); 2112277Sssadetskyextern void t__format__strftime (const char *) __attribute__((__format__(ms_strftime, 1, 0))); 2212277Sssadetskyextern void t__format____strftime__ (const char *) __attribute__((__format__(__ms_strftime__, 1, 0))); 2312277Sssadetskyextern void t__format__strfmon (const char *, ...) __attribute__((__format__(strfmon, 1, 2))); 2412277Sssadetskyextern void t__format____strfmon__ (const char *, ...) __attribute__((__format__(__strfmon__, 1, 2))); 2512277Sssadetsky 2612277Sssadetskyextern char *tformat_arg (const char *) __attribute__((format_arg(1))); 2712277Sssadetskyextern char *t__format_arg__ (const char *) __attribute__((__format_arg__(1))); 2812277Sssadetsky 2912277Sssadetskyvoid 3012277Sssadetskyfoo (int i, int *ip, double d) 3112277Sssadetsky{ 3212277Sssadetsky tformatprintf ("%d", i); 3312277Sssadetsky tformatprintf ("%"); /* { dg-warning "format" "attribute format printf" } */ 3412277Sssadetsky tformat__printf__ ("%d", i); 3512277Sssadetsky tformat__printf__ ("%"); /* { dg-warning "format" "attribute format __printf__" } */ 3612277Sssadetsky tformatscanf ("%d", ip); 3712277Sssadetsky tformatscanf ("%"); /* { dg-warning "format" "attribute format scanf" } */ 3812277Sssadetsky tformat__scanf__ ("%d", ip); 3912277Sssadetsky tformat__scanf__ ("%"); /* { dg-warning "format" "attribute format __scanf__" } */ 4012277Sssadetsky tformatstrftime ("%a"); 4112277Sssadetsky tformatstrftime ("%"); /* { dg-warning "format" "attribute format strftime" } */ 4212277Sssadetsky tformat__strftime__ ("%a"); 4312277Sssadetsky tformat__strftime__ ("%"); /* { dg-warning "format" "attribute format __strftime__" } */ 4412277Sssadetsky tformatstrfmon ("%n", d); 4512277Sssadetsky tformatstrfmon ("%"); /* { dg-warning "format" "attribute format strfmon" } */ 4612277Sssadetsky tformat__strfmon__ ("%n", d); 4712277Sssadetsky tformat__strfmon__ ("%"); /* { dg-warning "format" "attribute format __strfmon__" } */ 4812277Sssadetsky t__format__printf ("%d", i); 4912277Sssadetsky t__format__printf ("%"); /* { dg-warning "format" "attribute __format__ printf" } */ 5012277Sssadetsky t__format____printf__ ("%d", i); 5112277Sssadetsky t__format____printf__ ("%"); /* { dg-warning "format" "attribute __format__ __printf__" } */ 5212277Sssadetsky t__format__scanf ("%d", ip); 5312277Sssadetsky t__format__scanf ("%"); /* { dg-warning "format" "attribute __format__ scanf" } */ 5412277Sssadetsky t__format____scanf__ ("%d", ip); 5512277Sssadetsky t__format____scanf__ ("%"); /* { dg-warning "format" "attribute __format__ __scanf__" } */ 5612277Sssadetsky t__format__strftime ("%a"); 5712277Sssadetsky t__format__strftime ("%"); /* { dg-warning "format" "attribute __format__ strftime" } */ 5812277Sssadetsky t__format____strftime__ ("%a"); 5912277Sssadetsky t__format____strftime__ ("%"); /* { dg-warning "format" "attribute __format__ __strftime__" } */ 6012277Sssadetsky t__format__strfmon ("%n", d); 6112277Sssadetsky t__format__strfmon ("%"); /* { dg-warning "format" "attribute __format__ strfmon" } */ 6212277Sssadetsky t__format____strfmon__ ("%n", d); 6312277Sssadetsky t__format____strfmon__ ("%"); /* { dg-warning "format" "attribute __format__ __strfmon__" } */ 6412277Sssadetsky tformatprintf (tformat_arg ("%d"), i); 6512277Sssadetsky tformatprintf (tformat_arg ("%")); /* { dg-warning "format" "attribute format_arg" } */ 6612277Sssadetsky tformatprintf (t__format_arg__ ("%d"), i); 6712277Sssadetsky tformatprintf (t__format_arg__ ("%")); /* { dg-warning "format" "attribute __format_arg__" } */ 6812277Sssadetsky} 6912277Sssadetsky