summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c
blob: ea5ad8170cd83ebf8cb59926ca004f4c0556b7a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=builtin-macro-redefined" }
/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#ifndef __TIME__
#error "__TIME__ builtin is not defined"
// { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } .-1 }
#endif

#define __TIME__ "X"  // { dg-error "-:\"__TIME__\" redefined .-Werror=builtin-macro-redefined." }

#define __TIME__ "Y"  // { dg-bogus "-Wbuiltin-macro-redefined" }
                      // { dg-warning "-:\"__TIME__\" redefined" "not-builtin-1" { target *-*-* } .-1 }
                      // { dg-message "-:previous definition" "previous-1" { target *-*-* } 9 }

#define X "X"
#define X "Y"         // { dg-bogus "-Wbuiltin-macro-redefined" }
                      // { dg-warning "-:\"X\" redefined" "not-builtin-2" { target *-*-* } .-1 }
                      // { dg-message "-:previous definition" "previous-2" { target *-*-* } 15 }