This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix #line generation in cpp
- To: Zack Weinberg <zack at wolery dot cumb dot org>
- Subject: [PATCH] Fix #line generation in cpp
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 28 Jun 2000 16:25:49 +0200
- Cc: gcc-patches at gcc dot gnu dot org
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
If a header includes itself and is not fully protected against multiple
inclusion, cpp ommits one of the needed #line commands, which has the result
that gcc ends with error:
[jakub@tucnak /tmp]$ gcc -c k.c
k.c:0: #-lines for entering and leaving files don't match
Example (should I make a testcase from it):
[jakub@tucnak /tmp]$ cat k.c
#include "k.h"
[jakub@tucnak /tmp]$ cat k.h
/* Self including unprotected header */
#include "l.h"
#ifndef K_H
#define K_H 1
#include "k.h"
#include "l.h"
#endif
[jakub@tucnak /tmp]$ cat l.h
asm ("");
Ok to commit?
2000-06-28 Jakub Jelinek <jakub@redhat.com>
* cpplex.c (output_line_command): Output correct #line if a header
is including itself and is not protected against multiple inclusion.
--- gcc/cpplex.c.jj Thu Jun 22 13:47:17 2000
+++ gcc/cpplex.c Wed Jun 28 15:51:09 2000
@@ -289,25 +289,26 @@ output_line_command (pfile, print, line)
if (CPP_OPTION (pfile, no_line_commands))
return;
- /* Determine whether the current filename has changed, and if so,
- how. 'nominal_fname' values are unique, so they can be compared
- by comparing pointers. */
- if (ip->nominal_fname == print->last_fname)
- change = same;
- else
+ if (pfile->buffer_stack_depth == print->last_bsd)
{
- if (pfile->buffer_stack_depth == print->last_bsd)
+ /* Determine whether the current filename has changed, and if so,
+ how. 'nominal_fname' values are unique, so they can be compared
+ by comparing pointers. */
+ if (ip->nominal_fname == print->last_fname)
+ change = same;
+ else
change = rname;
+ }
+ else
+ {
+ if (pfile->buffer_stack_depth > print->last_bsd)
+ change = enter;
else
- {
- if (pfile->buffer_stack_depth > print->last_bsd)
- change = enter;
- else
- change = leave;
- print->last_bsd = pfile->buffer_stack_depth;
- }
- print->last_fname = ip->nominal_fname;
+ change = leave;
+ print->last_bsd = pfile->buffer_stack_depth;
}
+ print->last_fname = ip->nominal_fname;
+
/* If the current file has not changed, we can output a few newlines
instead if we want to increase the line number by a small amount.
We cannot do this if print->lineno is zero, because that means we
Jakub