libcpp: Diagnose __has_include outside of preprocessor directives [PR93545]
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Feb 2020 12:40:56 +0000 (13:40 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 4 Feb 2020 12:40:56 +0000 (13:40 +0100)
Add forgotten gcc/testsuite/c-c++-common/gomp/has-include-1.c.

2020-02-04  Jakub Jelinek  <jakub@redhat.com>

* macro.c (builtin_has_include): Diagnose __has_include* use outside
of preprocessing directives.

* c-c++-common/cpp/has-include-1.c: New test.
* c-c++-common/cpp/has-include-next-1.c: New test.
* c-c++-common/gomp/has-include-1.c: New test.

gcc/testsuite/c-c++-common/gomp/has-include-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/c-c++-common/gomp/has-include-1.c b/gcc/testsuite/c-c++-common/gomp/has-include-1.c
new file mode 100644 (file)
index 0000000..bb1b905
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+#pragma omp parallel if (__has_include ("<stdlib.h>")) /* { dg-error "used outside of preprocessing directive" } */
+  ;
+}