[2/2,testsuite] add tests for __has_include with traditional-cpp

Message ID 20200728072830.6615-3-tiziano.mueller@chem.uzh.ch
State New
Headers show
Series
  • cpp: fix __has_include in traditional mode
Related show

Commit Message

Tiziano Müller July 28, 2020, 7:28 a.m.
---
 gcc/testsuite/ChangeLog                       |  4 ++
 .../cpp/has-include-1-traditional.c           | 38 +++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/cpp/has-include-1-traditional.c

-- 
2.26.1

Patch

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 477804eec9b..18f81e1befa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@ 
+2020-07-27  Tiziano Müller <tiziano.mueller@chem.uzh.ch>
+
+	* c-c++-common/cpp/has-include-1-traditional.c: New test.
+
 2020-07-27  Hans-Peter Nilsson  <hp@bitrange.com>
 
 	* gcc.dg/tree-ssa/reassoc-20.c: Adjust for mmix.
diff --git a/gcc/testsuite/c-c++-common/cpp/has-include-1-traditional.c b/gcc/testsuite/c-c++-common/cpp/has-include-1-traditional.c
new file mode 100644
index 00000000000..b0acdbece4d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/has-include-1-traditional.c
@@ -0,0 +1,38 @@ 
+/* { dg-do preprocess { target c } } */
+/* { dg-options "-traditional-cpp" } */
+
+#if __has_include ("stdlib.h")
+#else
+#error error 1
+#endif
+#if __has_include (<stdlib.h>)
+#else
+#error error 2
+#endif
+#if !__has_include ("stdlib.h")
+#error error 3
+#elif !__has_include (<stdlib.h>)
+#error error 4
+#endif
+#if __has_include ("stdlib.h") && __has_include (<stdlib.h>)
+#else
+#error error 5
+#endif
+#if !defined(__has_include)
+#error error 6
+#endif
+#ifndef __has_include
+#error error 7
+#endif
+#ifdef __has_include
+#else
+#error error 8
+#endif
+#define m1 __has_include("stdlib.h")
+#define m2 <stdlib.h>
+#if !m1
+#error error 9
+#endif
+#if !__has_include (m2)
+#error error 13
+#endif