1 /* Test -Wno-builtin-macro-redefined warnings. */
3 /* { dg-do compile } */
4 /* { dg-options "-Wno-builtin-macro-redefined -U__DATE__ -D__TIME__=X" } */
6 /* Check date, time, and datestamp built-ins warnings may be suppressed. */
9 #error "__DATE__ is defined, but should not be (-U command line error)"
10 /* { dg-bogus "__DATE__ is defined" "" { target *-*-* } 9 } */
14 #error "__TIME__ is not defined as expected (-D command line error)"
15 /* { dg-bogus "__TIME__ is not defined" "" { target *-*-* } 14 } */
18 #if !defined(__TIMESTAMP__)
19 #error "__TIMESTAMP__ is not defined (built-in macro expectation error)"
20 /* { dg-bogus "__TIMESTAMP__ is not defined" "" { target *-*-* } 19 } */
24 #undef __TIME__ /* Undefine while defined. */
25 #undef __TIME__ /* Undefine while already undefined. */
27 #define __TIME__ "X" /* Define while undefined. */
28 #define __TIME__ "X" /* Re-define while defined. */
30 #define __TIME__ "Y" /* { dg-warning "\"__TIME__\" redefined" } */
31 /* { dg-message "previous definition" "" { target *-*-* } 28 } */
33 #undef __TIME__ /* Undefine while defined. */
36 #undef __DATE__ /* Undefine while already undefined. */
38 #define __DATE__ "X" /* Define while undefined. */
39 #define __DATE__ "X" /* Re-define while defined. */
41 #define __DATE__ "Y" /* { dg-warning "\"__DATE__\" redefined" } */
42 /* { dg-message "previous definition" "" { target *-*-* } 39 } */
44 #undef __DATE__ /* Undefine while defined. */
47 #define __TIMESTAMP__ "X" /* Define while already defined. */
48 #define __TIMESTAMP__ "X" /* Re-define while defined. */
50 #define __TIMESTAMP__ "Y" /* { dg-warning "\"__TIMESTAMP__\" redefined" } */
51 /* { dg-message "previous definition" "" { target *-*-* } 48 } */
53 #undef __TIMESTAMP__ /* Undefine while defined. */
56 /* Check other built-ins with warnings that may be suppressed. */
58 #if !defined(__FILE__) || !defined(__BASE_FILE__)
59 #error "Expected built-in is not defined (built-in macro expectation error)"
60 /* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } 59 } */
63 #define __FILE__ "X" /* Define while already defined. */
64 #define __BASE_FILE__ "X" /* Define while already defined. */
67 /* Check selected built-ins not affected by warning suppression. */
69 #if !defined(__LINE__) || !defined(__INCLUDE_LEVEL__) || !defined(__COUNTER__)
70 #error "Expected built-in is not defined (built-in macro expectation error)"
71 /* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } 70 } */
74 #define __LINE__ 0 /* { dg-warning "\"__LINE__\" redef" } */
75 #define __INCLUDE_LEVEL__ 0 /* { dg-warning "\"__INCLUDE_LEVEL__\" redef" } */
76 #define __COUNTER__ 0 /* { dg-warning "\"__COUNTER__\" redef" } */
79 int unused
; /* Silence `ISO C forbids an empty translation unit' warning. */