diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-01 20:21:13 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-01 20:21:13 +0000 |
commit | 4d0e15b57727d61d144460956869d3b260149dde (patch) | |
tree | ad692a7f6210d539ee8ff1304361b204914f4b9e /gcc/cpplib.c | |
parent | cc849a386ce30817f8a3cc9e5c15e8cc37839bf8 (diff) | |
download | gcc-4d0e15b57727d61d144460956869d3b260149dde.tar.gz |
* cpplib.c (run_directive): Use correct line number for output
of _Pragma. Remember any in-progress directive.
* gcc.dg/cpp/vararg2.c, gcc.dg/cpp/_Pragm1.c: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37194 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index cd14ba4e83a..738b1ba2d3b 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -349,9 +349,12 @@ run_directive (pfile, dir_no, buf, count, name) size_t count; const char *name; { + unsigned int output_line = pfile->lexer_pos.output_line; + if (cpp_push_buffer (pfile, (const U_CHAR *) buf, count) != NULL) { - const struct directive *dir = &dtable[dir_no]; + const struct directive *dir = &dtable[dir_no], *orig_dir; + unsigned char orig_in_directive; if (name) CPP_BUFFER (pfile)->nominal_fname = name; @@ -360,7 +363,11 @@ run_directive (pfile, dir_no, buf, count, name) /* A kludge to avoid line markers for _Pragma. */ if (dir_no == T_PRAGMA) - pfile->lexer_pos.output_line = CPP_BUFFER (pfile)->prev->lineno; + pfile->lexer_pos.output_line = output_line; + + /* Save any in-process directive; _Pragma can appear in one. */ + orig_dir = pfile->directive; + orig_in_directive = pfile->state.in_directive; /* For _Pragma, the text is passed through preprocessing stage 3 only, i.e. no trigraphs, no escaped newline removal, and no @@ -371,8 +378,8 @@ run_directive (pfile, dir_no, buf, count, name) pfile->state.prevent_expansion++; (void) (*dir->handler) (pfile); pfile->state.prevent_expansion--; - pfile->directive = 0; - pfile->state.in_directive = 0; + pfile->directive = orig_dir; + pfile->state.in_directive = orig_in_directive; skip_rest_of_line (pfile); if (pfile->buffer->cur != pfile->buffer->rlimit) |