aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-07-18 23:25:06 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-07-18 23:25:06 +0000
commit96be6998336d305447f3963eb2c9d902eae516a7 (patch)
treebe6672085587ff8d9d75f630009b64878dc2aec5 /gcc/testsuite/gcc.dg/cpp
parentd0089985e7e6ec8fd020e40eb59667a88d0282de (diff)
downloadgcc-96be6998336d305447f3963eb2c9d902eae516a7.zip
gcc-96be6998336d305447f3963eb2c9d902eae516a7.tar.gz
gcc-96be6998336d305447f3963eb2c9d902eae516a7.tar.bz2
cpplib.h (TTYPE_TABLE): Rearrange to use only two per-entry macros, not five.
* cpplib.h (TTYPE_TABLE): Rearrange to use only two per-entry macros, not five. * cpphash.h (TOKEN_NAME): New macro. (_cpp_spell_operator): Deleted. (token_spellings): Now _cpp_token_spellings. * cppexp.c: Use TOKEN_NAME or TYPE_NAME, not _cpp_spell_operator. * cpplex.c: Use OP and TK macros when expanding the TTYPE_TABLE. Eliminate token_names. For non-OPERATOR tokens, store the stringification of the enumeration name (CPP_CHAR, etc.) in the name slot of token_spellings. Use TOKEN_NAME and/or TOKEN_SPELL, do not reference token_spellings directly. * cpplib.c: Use TOKEN_SPELL. * cpplex.c (_cpp_push_token): If the token being pushed back is the previous token in this context, just subtract one from context->posn. * cppmacro.c (save_expansion): Clear aux field when storing a placemarker. * gcc.dg/cpp/paste5.c: New test. * gcc.dg/cpp/vararg1.c: New test. From-SVN: r35124
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste5.c24
-rw-r--r--gcc/testsuite/gcc.dg/cpp/vararg1.c19
2 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/paste5.c b/gcc/testsuite/gcc.dg/cpp/paste5.c
new file mode 100644
index 0000000..2a763f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/paste5.c
@@ -0,0 +1,24 @@
+/* Regression test for bug in convoluted situation involving token paste
+ plus function-like macros used outside function context. It may be
+ easier to understand if you mentally replace 'struct' with 'A'
+ throughout this file; 'struct' is used only to get the code to compile
+ when preprocessed correctly.
+
+ The original problem was seen in the Linux kernel and reported by
+ Jakub Jelinek <jakub@redhat.com>; this test is synthetic. */
+
+/* { dg-do compile } */
+
+#define glue(a,b) a##b
+#define struct(x) B(x)
+#define E(x) struct x
+#define FG (22)
+
+extern void B(int);
+
+void foo(void)
+{
+ E(glue(F,*)) dummy; /* { dg-warning "valid preprocessing token" } */
+
+ E(glue(F,G)) ;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/vararg1.c b/gcc/testsuite/gcc.dg/cpp/vararg1.c
new file mode 100644
index 0000000..aa8ed79
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/vararg1.c
@@ -0,0 +1,19 @@
+/* Test for changed behavior of the GNU varargs extension.
+ ##args, where args is a rest argument which received zero tokens,
+ used to delete the previous sequence of nonwhitespace characters.
+ Now it deletes the previous token. */
+
+/* { dg-do run } */
+/* { dg-options -w } */
+
+#include <string.h>
+
+#define S(str, args...) " " str "\n", ##args
+
+int
+main()
+{
+ const char *s = S("foo");
+ return strchr (s, '\n') == NULL;
+}
+