This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: More tests.
- To: gcc-patches at gcc dot gnu dot org
- Subject: cpplib: More tests.
- From: Neil Booth <NeilB at earthling dot net>
- Date: Sun, 29 Oct 2000 17:53:30 +0000
More things that broke or were fixed during recent development.
If anyone can help me devise tests that cpplib ends with a zero exit
status on an empty file, and that it passes through #pragma
implementation to the output, please do. I don't know gejagnu /
expect well enough, and these things keep breaking.
Neil.
* 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.
Index: gcc.dg/cpp/defined.c
===================================================================
RCS file: defined.c
diff -N defined.c
--- /dev/null Tue May 5 13:32:27 1998
+++ defined.c Sun Oct 29 09:39:21 2000
@@ -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
Index: gcc.dg/cpp/include1.c
===================================================================
RCS file: include1.c
diff -N include1.c
--- /dev/null Tue May 5 13:32:27 1998
+++ include1.c Sun Oct 29 09:39:21 2000
@@ -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
Index: gcc.dg/cpp/macsyntx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.dg/cpp/macsyntx.c,v
retrieving revision 1.6
diff -u -p -r1.6 macsyntx.c
--- macsyntx.c 2000/10/28 18:01:40 1.6
+++ macsyntx.c 2000/10/29 17:39:35
@@ -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" } */
Index: gcc.dg/cpp/mi3.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.dg/cpp/mi3.c,v
retrieving revision 1.1
diff -u -p -r1.1 mi3.c
--- mi3.c 2000/06/27 22:26:11 1.1
+++ mi3.c 2000/10/29 17:39:35
@@ -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;
}
Index: gcc.dg/cpp/mi3.h
===================================================================
RCS file: mi3.h
diff -N mi3.h
--- /dev/null Tue May 5 13:32:27 1998
+++ mi3.h Sun Oct 29 09:39:35 2000
@@ -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
Index: gcc.dg/cpp/paste11.c
===================================================================
RCS file: paste11.c
diff -N paste11.c
--- /dev/null Tue May 5 13:32:27 1998
+++ paste11.c Sun Oct 29 09:39:35 2000
@@ -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" } */
Index: gcc.dg/cpp/skipping.c
===================================================================
RCS file: skipping.c
diff -N skipping.c
--- /dev/null Tue May 5 13:32:27 1998
+++ skipping.c Sun Oct 29 09:39:35 2000
@@ -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