1 |
689 |
jeremybenn |
/* Test -Wno-builtin-macro-redefined warnings. */
|
2 |
|
|
|
3 |
|
|
/* { dg-do compile } */
|
4 |
|
|
/* { dg-options "-Wno-builtin-macro-redefined -U__DATE__ -D__TIME__=X" } */
|
5 |
|
|
|
6 |
|
|
/* Check date, time, and datestamp built-ins warnings may be suppressed. */
|
7 |
|
|
|
8 |
|
|
#if defined(__DATE__)
|
9 |
|
|
#error "__DATE__ is defined, but should not be (-U command line error)"
|
10 |
|
|
/* { dg-bogus "__DATE__ is defined" "" { target *-*-* } 9 } */
|
11 |
|
|
#endif
|
12 |
|
|
|
13 |
|
|
#if __TIME__ != X
|
14 |
|
|
#error "__TIME__ is not defined as expected (-D command line error)"
|
15 |
|
|
/* { dg-bogus "__TIME__ is not defined" "" { target *-*-* } 14 } */
|
16 |
|
|
#endif
|
17 |
|
|
|
18 |
|
|
#if !defined(__TIMESTAMP__)
|
19 |
|
|
#error "__TIMESTAMP__ is not defined (built-in macro expectation error)"
|
20 |
|
|
/* { dg-bogus "__TIMESTAMP__ is not defined" "" { target *-*-* } 19 } */
|
21 |
|
|
#endif
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
#undef __TIME__ /* Undefine while defined. */
|
25 |
|
|
#undef __TIME__ /* Undefine while already undefined. */
|
26 |
|
|
|
27 |
|
|
#define __TIME__ "X" /* Define while undefined. */
|
28 |
|
|
#define __TIME__ "X" /* Re-define while defined. */
|
29 |
|
|
|
30 |
|
|
#define __TIME__ "Y" /* { dg-warning "\"__TIME__\" redefined" } */
|
31 |
|
|
/* { dg-message "previous definition" "" { target *-*-* } 28 } */
|
32 |
|
|
|
33 |
|
|
#undef __TIME__ /* Undefine while defined. */
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
#undef __DATE__ /* Undefine while already undefined. */
|
37 |
|
|
|
38 |
|
|
#define __DATE__ "X" /* Define while undefined. */
|
39 |
|
|
#define __DATE__ "X" /* Re-define while defined. */
|
40 |
|
|
|
41 |
|
|
#define __DATE__ "Y" /* { dg-warning "\"__DATE__\" redefined" } */
|
42 |
|
|
/* { dg-message "previous definition" "" { target *-*-* } 39 } */
|
43 |
|
|
|
44 |
|
|
#undef __DATE__ /* Undefine while defined. */
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
#define __TIMESTAMP__ "X" /* Define while already defined. */
|
48 |
|
|
#define __TIMESTAMP__ "X" /* Re-define while defined. */
|
49 |
|
|
|
50 |
|
|
#define __TIMESTAMP__ "Y" /* { dg-warning "\"__TIMESTAMP__\" redefined" } */
|
51 |
|
|
/* { dg-message "previous definition" "" { target *-*-* } 48 } */
|
52 |
|
|
|
53 |
|
|
#undef __TIMESTAMP__ /* Undefine while defined. */
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
/* Check other built-ins with warnings that may be suppressed. */
|
57 |
|
|
|
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 } */
|
61 |
|
|
#endif
|
62 |
|
|
|
63 |
|
|
#define __FILE__ "X" /* Define while already defined. */
|
64 |
|
|
#define __BASE_FILE__ "X" /* Define while already defined. */
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
/* Check selected built-ins not affected by warning suppression. */
|
68 |
|
|
|
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 } */
|
72 |
|
|
#endif
|
73 |
|
|
|
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" } */
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
int unused; /* Silence `ISO C forbids an empty translation unit' warning. */
|