1 /* Test that #pragma message "..." writes compiler messages. */
3 #pragma message /* { dg-warning "expected a string" } */
4 #pragma message 0 /* { dg-warning "expected a string" } */
5 #pragma message id /* { dg-warning "expected a string" } */
6 #pragma message ( /* { dg-warning "expected a string" } */
7 #pragma message (0 /* { dg-warning "expected a string" } */
8 #pragma message (id /* { dg-warning "expected a string" } */
9 #pragma message () /* { dg-warning "expected a string" } */
10 #pragma message (0) /* { dg-warning "expected a string" } */
11 #pragma message (id) /* { dg-warning "expected a string" } */
13 /* gcc prefixes '#pragma message ...' output with filename and line number,
14 then 'note: #pragma message: ', allowing dg-message to check output.
15 If unexpected pragma messages are printed (anything not caught by a
16 matching dg-message), dejagnu will report these as excess errors. */
19 /* { dg-error "17:missing terminating" "" { target *-*-* } 18 } */
20 /* { dg-warning "expected a string" "" { target *-*-* } 18 } */
21 #pragma message "Bad 1
22 /* { dg-error "17:missing terminating" "" { target *-*-* } 21 } */
23 /* { dg-warning "expected a string" "" { target *-*-* } 21 } */
24 #pragma message ("Bad 2
25 /* { dg-error "18:missing terminating" "" { target *-*-* } 24 } */
26 /* { dg-warning "expected a string" "" { target *-*-* } 24 } */
27 #pragma message ("Bad 3"
28 /* { dg-warning "malformed '#pragma message" "" { target *-*-* } 27 } */
30 #pragma message "" junk
31 /* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } 30 } */
33 #pragma message ("") junk
34 /* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } 33 } */
36 #pragma message "" /* No output expected for empty messages. */
39 #pragma message "Okay 1" /* { dg-message "Okay 1" } */
40 #pragma message ("Okay 2") /* { dg-message "Okay 2" } */
42 #pragma message ("Okay " THREE) /* { dg-message "Okay 3" } */
44 /* Create a TODO() that prints a message on compilation. */
45 #define DO_PRAGMA(x) _Pragma (#x)
46 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
47 TODO(Okay 4) /* { dg-message "TODO - Okay 4" } */
50 #pragma message ("Not printed")
53 int unused; /* Silence `ISO C forbids an empty translation unit' warning. */