aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-10-29 17:43:57 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-10-29 17:43:57 +0000
commit9f6ef6bcaf5716524e0b97c9ae07cdb885858cf3 (patch)
tree866bc0a0d9329f355ba4833ecdfb5908e7e5b5e4 /gcc/testsuite/gcc.dg/cpp
parent8c7b74b9393310aa17ef1c4360f0375a882b2500 (diff)
downloadgcc-9f6ef6bcaf5716524e0b97c9ae07cdb885858cf3.zip
gcc-9f6ef6bcaf5716524e0b97c9ae07cdb885858cf3.tar.gz
gcc-9f6ef6bcaf5716524e0b97c9ae07cdb885858cf3.tar.bz2
defined.c, [...]: New tests.
* gcc.dg/cpp/defined.c, include1.c, paste11.c, skipping.c: New tests. * gcc.dg/cpp/macsyntx.c: Move test to defined.c. * gcc.dg/cpp/mi3.c, mi3.h: New test for over-enthusiastic optimisation. From-SVN: r37126
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/defined.c27
-rw-r--r--gcc/testsuite/gcc.dg/cpp/include1.c13
-rw-r--r--gcc/testsuite/gcc.dg/cpp/macsyntx.c1
-rw-r--r--gcc/testsuite/gcc.dg/cpp/mi3.c5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/mi3.h7
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste11.c15
-rw-r--r--gcc/testsuite/gcc.dg/cpp/skipping.c20
7 files changed, 86 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/defined.c b/gcc/testsuite/gcc.dg/cpp/defined.c
new file mode 100644
index 0000000..0e82f7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/defined.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Tests behaviour of the defined operator. */
+
+/* Source: Neil Booth, 29 Oct 2000. */
+
+/* No diagnostics, though you could argue there should be. */
+#if defined defined
+#error defined is defined!
+#endif
+
+#define defined /* { dg-error "defined" } */
+
+#define is_Z_defined defined Z
+
+/* The behaviour of "defined" when it comes from a macro expansion is
+ now documented. */
+#if is_Z_defined /* { dg-warning "macro expansion" } */
+#error Macro expanding into defined operator test 1
+#endif
+
+#define Z
+#if !is_Z_defined /* { dg-warning "macro expansion" } */
+#error Macro expanding into defined operator test 2
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/include1.c b/gcc/testsuite/gcc.dg/cpp/include1.c
new file mode 100644
index 0000000..a0a54e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/include1.c
@@ -0,0 +1,13 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Tests that "#include MACRO" works. */
+
+/* Source: Neil Booth, 29 Oct 2000. */
+
+#define MACRO "mi1c.h"
+#include MACRO
+#ifndef CPP_MIC_H
+#error #include MACRO does not work
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/macsyntx.c b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
index e7f3528..ee5fd36 100644
--- a/gcc/testsuite/gcc.dg/cpp/macsyntx.c
+++ b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
@@ -21,7 +21,6 @@
#define ; /* { dg-error "identifier" } */
#define SEMI; /* { dg-warning "space" } */
-#define defined /* { dg-error "defined" } */
#define foo(X /* { dg-error "missing" } */
#define foo\
(X,) /* { dg-error "parameter name" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/mi3.c b/gcc/testsuite/gcc.dg/cpp/mi3.c
index 533b509..f33fd78 100644
--- a/gcc/testsuite/gcc.dg/cpp/mi3.c
+++ b/gcc/testsuite/gcc.dg/cpp/mi3.c
@@ -10,8 +10,11 @@
#include "mi3.def"
#undef X
+#include "mi3.h"
+#include "mi3.h" /* The second include declares variable c. */
+
int
main(void)
{
- return a + b;
+ return a + b + c;
}
diff --git a/gcc/testsuite/gcc.dg/cpp/mi3.h b/gcc/testsuite/gcc.dg/cpp/mi3.h
new file mode 100644
index 0000000..8774fcf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/mi3.h
@@ -0,0 +1,7 @@
+/* Another test case for over-eager multiple include optimization. */
+
+#ifndef GUARD
+#define GUARD
+#elif 1 /* #elif kills optimisation */
+int c;
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/paste11.c b/gcc/testsuite/gcc.dg/cpp/paste11.c
new file mode 100644
index 0000000..18530b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/paste11.c
@@ -0,0 +1,15 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Test correct pasting of identifiers and numbers. We can paste any
+ number, as long as no '.', '-' or '+' appears in its spelling. */
+
+#define glue(x, y) x ## y
+
+glue (ident, 12) /* OK. */
+glue (ident, 12e3) /* OK. */
+glue (ident, 12e+3) /* { dg-warning "valid preprocessing tok" } */
+glue (ident, 12e-3) /* { dg-warning "valid preprocessing tok" } */
+glue (ident, 1.2) /* { dg-warning "valid preprocessing tok" } */
+glue (ident, .12) /* { dg-warning "valid preprocessing tok" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/skipping.c b/gcc/testsuite/gcc.dg/cpp/skipping.c
new file mode 100644
index 0000000..d87ea70
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/skipping.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Tests expansion of macros whilst skipping false conditionals. */
+
+/* Source: Neil Booth, 29 Oct 2000. */
+
+#define F()
+#define TRUE 1
+
+#if 0
+F( /* No diagnostic: don't even try to expand it. */
+#endif
+
+#if 0
+#elif TRUE /* Expand this, even though we were skipping. */
+#else
+#error Macros not expanded in #elif
+#endif