aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-07-31 23:47:19 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-07-31 23:47:19 +0000
commit6ead1e9971df29c9e71b19d3f2faae33c78e13e0 (patch)
tree09f352803e0788fc35ed3daa9f4930ebd0f0d29b /gcc/cpplex.c
parented39843b4149642ce7cabec509db61ef46e34b70 (diff)
downloadgcc-6ead1e9971df29c9e71b19d3f2faae33c78e13e0.zip
gcc-6ead1e9971df29c9e71b19d3f2faae33c78e13e0.tar.gz
gcc-6ead1e9971df29c9e71b19d3f2faae33c78e13e0.tar.bz2
[multiple changes]
2000-07-31 Jakub Jelinek <jakub@redhat.com> * cpplex.c (_cpp_get_line): If index is 0, return line 0 col 0. (_cpp_get_token): Don't macro expand a just pasted token if it was pasted at no_expand_level. * testsuite/gcc.dg/cpp/paste7.c: New test. 2000-07-31 Zack Weinberg <zack@wolery.cumb.org> * cppmacro.c (find_param, count_params, save_expansion): Permit 'defined' as a macro parameter name. From-SVN: r35394
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index bbe6f35..0ee0a3d 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -3082,7 +3082,7 @@ const cpp_token *
_cpp_get_token (pfile)
cpp_reader *pfile;
{
- const cpp_token *token;
+ const cpp_token *token, *old_token;
cpp_hashnode *node;
/* Loop until we hit a non-macro token. */
@@ -3111,6 +3111,8 @@ _cpp_get_token (pfile)
be taken as a control macro. */
pfile->potential_control_macro = 0;
+ old_token = token;
+
/* See if there's a token to paste with this one. */
if (!pfile->paste_level)
token = maybe_paste_with_next (pfile, token);
@@ -3120,10 +3122,17 @@ _cpp_get_token (pfile)
return token;
/* Is macro expansion disabled in general, or are we in the
- middle of a token paste? */
- if (pfile->no_expand_level == pfile->cur_context || pfile->paste_level)
+ middle of a token paste, or was this token just pasted?
+ (Note we don't check token->flags & PASTED, because that
+ counts tokens that were pasted at some point in the past,
+ we're only interested in tokens that were pasted by this call
+ to maybe_paste_with_next.) */
+ if (pfile->no_expand_level == pfile->cur_context
+ || pfile->paste_level
+ || (token != old_token
+ && pfile->no_expand_level + 1 == pfile->cur_context))
return token;
-
+
node = token->val.node;
if (node->type != T_MACRO)
return special_symbol (pfile, node, token);
@@ -3337,6 +3346,13 @@ _cpp_get_line (pfile, pcol)
else
index = pfile->contexts[0].posn;
+ if (index == 0)
+ {
+ if (pcol)
+ *pcol = 0;
+ return 0;
+ }
+
cur_token = &pfile->token_list.tokens[index - 1];
if (pcol)
*pcol = cur_token->col;