diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-09-24 22:53:12 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-09-24 22:53:12 +0000 |
commit | 4ed5bcfb1ed415c32bdd8735b2cd0ea0ed37e8b6 (patch) | |
tree | f2b5dd04bb961bbe8dac8d988d52d574f0cb2b47 /gcc/testsuite/gcc.dg/cpp | |
parent | ad43d46f3abe6f4d9b41f5b1d7b46a0c320efda8 (diff) | |
download | gcc-4ed5bcfb1ed415c32bdd8735b2cd0ea0ed37e8b6.zip gcc-4ed5bcfb1ed415c32bdd8735b2cd0ea0ed37e8b6.tar.gz gcc-4ed5bcfb1ed415c32bdd8735b2cd0ea0ed37e8b6.tar.bz2 |
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/19990703-1.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/20000625-2.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/macro10.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/spacing1.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/strify3.c | 29 |
5 files changed, 66 insertions, 28 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/19990703-1.c b/gcc/testsuite/gcc.dg/cpp/19990703-1.c deleted file mode 100644 index c3ac233..0000000 --- a/gcc/testsuite/gcc.dg/cpp/19990703-1.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ - -/* Test of obscure case in token pasting in the preprocessor. - I can't think of any way to make this problem provoke a syntax error. - Based on a bug report by Manfred Hollstein. */ - -#include <string.h> - -#define SP1(x, y) SP2(x, y) -#define SP2(x, y) SP3(x##y) -#define SP3(x) #x -#define MZ -0 - -int -main(void) -{ - char *x = SP1(0,MZ); /* { dg-warning "valid preprocessing token" "" } */ - char *y = "0-0"; /* should be the expansion of SP1(0,MZ) */ - - if(strcmp(x, y)) - return 1; - else - return 0; -} diff --git a/gcc/testsuite/gcc.dg/cpp/20000625-2.c b/gcc/testsuite/gcc.dg/cpp/20000625-2.c index fb45898..c9e3fe2 100644 --- a/gcc/testsuite/gcc.dg/cpp/20000625-2.c +++ b/gcc/testsuite/gcc.dg/cpp/20000625-2.c @@ -8,7 +8,10 @@ #define str(x) xstr(x) #define xstr(x) #x -const char a[] = str(symbol_version(getrlimit, GLIBC_2.0)); +/* This testcase is bogus, as it testing undefined behaviour. We can + get the behaviour GLIBC desires by removing the space before + GCLIB_2.0 in this line. */ +const char a[] = str(symbol_version(getrlimit,GLIBC_2.0)); /* { dg-warning "valid preprocessing token" "" { target *-*-* } 11 } */ const char b[] = str(getrlimit@GLIBC_2.0); const char c[] = "getrlimit@GLIBC_2.0"; diff --git a/gcc/testsuite/gcc.dg/cpp/macro10.c b/gcc/testsuite/gcc.dg/cpp/macro10.c new file mode 100644 index 0000000..20d4911 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/macro10.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ + +/* Source: Neil Booth, 23 Sep 2001. + + A tricky, pathological corner case we used to get wrong. Expansion + should go as follows. The asterisk indicates the token has "blue + paint" can no longer be macro expanded. We used to lose that + information when parsing arguments and dropping to the lexer to get + the ')'. + + foo ) + bar foo* ) + func (foo* ) + foo* + + If we try and expand the final foo, we get an "unterminated + argument list invoking macro <func>" error. If we do the right + thing and leave it as is, no diagnostics are emitted. */ + +#define func(x) x +#define bar func( +#define foo bar foo +foo ) diff --git a/gcc/testsuite/gcc.dg/cpp/spacing1.c b/gcc/testsuite/gcc.dg/cpp/spacing1.c index 55a8f96..9a3933b 100644 --- a/gcc/testsuite/gcc.dg/cpp/spacing1.c +++ b/gcc/testsuite/gcc.dg/cpp/spacing1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 Free Software Foundation, Inc. */ +/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ @@ -8,20 +8,24 @@ not be a macro invocation. Also, multiple macro invocations spread across many lines. - Neil Booth, 1 Dec 2000. */ + Neil Booth, 1 Dec 2000, 23 Sep 2001. */ #define str(x) #x #define f(x) x +#define glue(x, y) x ## y +#define EMPTY /* The correct output is shown here. Note the spaces, and the way everything after the invocation of f appears on the same line. + 44 ; f bar g "1 2" bam baz */ +glue (EMPTY 4, 4) EMPTY; f bar f (g) str @@ -33,9 +37,10 @@ f (g) str /* { dg-final { if ![file exists spacing1.i] { return } } } + { dg-final { if \{ [grep spacing1.i " 44 ;"] != "" \} \{ } } { dg-final { if \{ [grep spacing1.i "f.*bar"] == "" \} \{ } } { dg-final { if \{ [grep spacing1.i "^bar"] != "" \} \{ } } { dg-final { if \{ [grep spacing1.i "g \"1 2\" bam baz"] != "" \} \{ } } - { dg-final { return \} \} \} } } + { dg-final { return \} \} \} \} } } { dg-final { fail "spacing1.c: spacing and new-line preservation" } } */ diff --git a/gcc/testsuite/gcc.dg/cpp/strify3.c b/gcc/testsuite/gcc.dg/cpp/strify3.c new file mode 100644 index 0000000..5d76b5e --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/strify3.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do run } */ + +/* Tests we stringify without inserting a space. GCC 2.95.x and + earlier would insert a bogus space before bar in the string, simply + because a space was there in the invocation. + + Neil Booth, 24 Sep 2001. */ + +extern int strcmp (const char *, const char *); +extern int puts (const char *); +extern void abort (void); +#define err(str) do { puts(str); abort(); } while (0) + +#define str(x) #x +#define xstr(x) str(x) +#define glibc_hack(x, y) x@y + +int main (int argc, char *argv[]) +{ + /* The space before "bar" here is vital. */ + char a[] = xstr(glibc_hack(foo, bar)); + + if (strcmp (a, "foo@bar")) + err ("stringification without spaces"); + + return 0; +} |