aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2012-10-04 17:33:11 +0200
committerFlorian Weimer <fw@gcc.gnu.org>2012-10-04 17:33:11 +0200
commitf591bd8f507db985a2d194b3b58b5d8b128dce0a (patch)
tree3992b4ad76993de282e9b81bbe8d85f5c7834619 /gcc
parentc62b924434c30cc417df9c1f0bac770e653f0241 (diff)
downloadgcc-f591bd8f507db985a2d194b3b58b5d8b128dce0a.zip
gcc-f591bd8f507db985a2d194b3b58b5d8b128dce0a.tar.gz
gcc-f591bd8f507db985a2d194b3b58b5d8b128dce0a.tar.bz2
Implement #pragma GCC warning/error
2012-10-04 Florian Weimer <fweimer@redhat.com> * doc/cpp.texi (Pragmas): Document #pragma GCC warning, #pragma GCC error. 2012-10-04 Florian Weimer <fweimer@redhat.com> * c-c++-common/cpp/diagnostic-pragma-1.c: New testcase. 2012-10-04 Florian Weimer <fweimer@redhat.com> * directives.c (do_pragma_warning_or_error): New. (do_pragma_warning): New. (do_pragma_error): New. (_cpp_init_internal_pragmas): Register new pragmas. From-SVN: r192084
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/doc/cpp.texi9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c11
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1e030d9..959086c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-04 Florian Weimer <fweimer@redhat.com>
+
+ * doc/cpp.texi (Pragmas): Document #pragma GCC warning, #pragma
+ GCC error.
+
2012-10-04 Richard Guenther <rguenther@suse.de>
PR middle-end/54735
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index b363db0..fa5989e 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -3634,6 +3634,15 @@ This pragma takes no arguments. It causes the rest of the code in the
current file to be treated as if it came from a system header.
@xref{System Headers}.
+@item #pragma GCC warning
+@itemx #pragma GCC error
+@code{#pragma GCC warning "message"} causes the preprocessor to issue
+a warning diagnostic with the text @samp{message}. The message
+contained in the pragma must be a single string literal. Similarly,
+@code{#pragma GCC error "message"} issues an error message. Unlike
+the @samp{#warning} and @samp{#error} directives, these pragmas can be
+embedded in preprocessor macros using @samp{_Pragma}.
+
@end ftable
@node Other Directives
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 306d277..e058566 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-04 Florian Weimer <fweimer@redhat.com>
+
+ * c-c++-common/cpp/diagnostic-pragma-1.c: New testcase.
+
2012-10-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54323
diff --git a/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c
new file mode 100644
index 0000000..9867c94
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+#pragma GCC warning "warn-a" // { dg-warning warn-a }
+#pragma GCC error "err-b" // { dg-error err-b }
+
+#define CONST1 _Pragma("GCC warning \"warn-c\"") 1
+#define CONST2 _Pragma("GCC error \"err-d\"") 2
+
+char a[CONST1]; // { dg-warning warn-c }
+char b[CONST2]; // { dg-error err-d }
+