summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pragma-message.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/pragma-message.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/pragma-message.c')
-rw-r--r--gcc/testsuite/gcc.dg/pragma-message.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pragma-message.c b/gcc/testsuite/gcc.dg/pragma-message.c
new file mode 100644
index 000000000..0f9c6bf44
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pragma-message.c
@@ -0,0 +1,53 @@
+/* Test that #pragma message "..." writes compiler messages. */
+
+#pragma message /* { dg-warning "expected a string" } */
+#pragma message 0 /* { dg-warning "expected a string" } */
+#pragma message id /* { dg-warning "expected a string" } */
+#pragma message ( /* { dg-warning "expected a string" } */
+#pragma message (0 /* { dg-warning "expected a string" } */
+#pragma message (id /* { dg-warning "expected a string" } */
+#pragma message () /* { dg-warning "expected a string" } */
+#pragma message (0) /* { dg-warning "expected a string" } */
+#pragma message (id) /* { dg-warning "expected a string" } */
+
+/* gcc prefixes '#pragma message ...' output with filename and line number,
+ then 'note: #pragma message: ', allowing dg-message to check output.
+ If unexpected pragma messages are printed (anything not caught by a
+ matching dg-message), dejagnu will report these as excess errors. */
+
+#pragma message "
+/* { dg-error "missing terminating" "" { target *-*-* } 18 } */
+/* { dg-warning "expected a string" "" { target *-*-* } 18 } */
+#pragma message "Bad 1
+/* { dg-error "missing terminating" "" { target *-*-* } 21 } */
+/* { dg-warning "expected a string" "" { target *-*-* } 21 } */
+#pragma message ("Bad 2
+/* { dg-error "missing terminating" "" { target *-*-* } 24 } */
+/* { dg-warning "expected a string" "" { target *-*-* } 24 } */
+#pragma message ("Bad 3"
+/* { dg-warning "malformed '#pragma message" "" { target *-*-* } 27 } */
+
+#pragma message "" junk
+/* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } 30 } */
+
+#pragma message ("") junk
+/* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } 33 } */
+
+#pragma message "" /* No output expected for empty messages. */
+#pragma message ("")
+
+#pragma message "Okay 1" /* { dg-message "Okay 1" } */
+#pragma message ("Okay 2") /* { dg-message "Okay 2" } */
+#define THREE "3"
+#pragma message ("Okay " THREE) /* { dg-message "Okay 3" } */
+
+/* Create a TODO() that prints a message on compilation. */
+#define DO_PRAGMA(x) _Pragma (#x)
+#define TODO(x) DO_PRAGMA(message ("TODO - " #x))
+TODO(Okay 4) /* { dg-message "TODO - Okay 4" } */
+
+#if 0
+#pragma message ("Not printed")
+#endif
+
+int unused; /* Silence `ISO C forbids an empty translation unit' warning. */