public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code
@ 2011-03-23  9:27 joerg.richter@pdv-fs.de
  2011-03-23 10:05 ` [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: joerg.richter@pdv-fs.de @ 2011-03-23  9:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

           Summary: Wrong error message location when compiling
                    preprocessed code
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: joerg.richter@pdv-fs.de


$ cat > foobar.h << EOF
enum Foo
{
  BAR
};
#define BAR(x) 
#define BARBAR BAR
EOF

$ cat > main.cc << EOF
#include "foobar.h"



void func()
{
  (void)BARBAR;
  aaa;
}
EOF

$ g++ -c main.cc
main.cc: In function 'void func()':
main.cc:8:3: error: 'aaa' was not declared in this scope

$ g++ -E main.cc > main.ii
$ g++ -c main.ii
foobar.h: In function 'void func()':
foobar.h:8:3: error: 'aaa' was not declared in this scope

Please notice the wrong filename when compiling the preprocessed source.

GCC 4.4 doesn't have this problem.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
@ 2011-03-23 10:05 ` rguenth at gcc dot gnu.org
  2011-03-28 14:05 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-23 10:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.03.23 09:41:27
                 CC|                            |tromey at gcc dot gnu.org
   Target Milestone|---                         |4.5.3
            Summary|Wrong error message         |[4.5/4.6/4.7 Regression]
                   |location when compiling     |Wrong error message
                   |preprocessed code           |location when compiling
                   |                            |preprocessed code
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-23 09:41:27 UTC ---
Confirmed.

> g++-4.5 -S foo.c -save-temps
foobar.h: In function ‘void func()’:
foobar.h:8:3: error: ‘aaa’ was not declared in this scope

and preprocessed source looks like

# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "foo.c"
# 1 "foobar.h" 1
enum Foo
{
    BAR
};
# 2 "foo.c" 2



void func()
{
  (void)
# 6 "foobar.h"
               BAR
              ;
  aaa;
}

we miss to switch back to foo.c.  4.4 does not switch to foobar.h at all.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
  2011-03-23 10:05 ` [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
@ 2011-03-28 14:05 ` jakub at gcc dot gnu.org
  2011-03-28 14:26 ` joerg.richter@pdv-fs.de
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-28 14:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-28 13:47:05 UTC ---
Can't reproduce this, neither with g++ 4.5, nor trunk.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
  2011-03-23 10:05 ` [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
  2011-03-28 14:05 ` jakub at gcc dot gnu.org
@ 2011-03-28 14:26 ` joerg.richter@pdv-fs.de
  2011-03-28 16:40 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: joerg.richter@pdv-fs.de @ 2011-03-28 14:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #3 from joerg.richter@pdv-fs.de 2011-03-28 13:51:55 UTC ---
(In reply to comment #2)
> Can't reproduce this, neither with g++ 4.5, nor trunk.

Did you delete the empty lines?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (2 preceding siblings ...)
  2011-03-28 14:26 ` joerg.richter@pdv-fs.de
@ 2011-03-28 16:40 ` jakub at gcc dot gnu.org
  2011-03-28 19:46 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-28 16:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-28 16:15:52 UTC ---
Ah, I can reproduce with those lines.
Apparently caused by my PR41445 fix.

To fix this, I think we should remember not just src_line, but also filename
in print variable in c-ppoutput.c.  And, either we should avoid calling
do_line_change for avoid_paste resp. PREV_WHITE in scan_translation_unit if
file is different, or maybe_print_line should do the
if (src_line >= print.src_line && src_line < print.src_line + 8)
optimization only if it is the same file.

As PR41445 has been in already in 4.5 and nobody complained about e.g.
# 1 "pr48248-2.C"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "pr48248-2.C"
# 1 "pr48248.h" 1
enum E { B };
# 2 "pr48248-2.C" 2
# 17 "pr48248-2.C"
void
foo ()
{
  (void)
# 3 "pr48248.h"
           B
# 20 "pr48248-2.C"
          ;
  a;
}

(where # 3 "pr48248.h" doesn't say that the header is being entered, just
temporarily jumps to it), I'd probably prefer the latter choice, as it gives
more correct locus info.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (3 preceding siblings ...)
  2011-03-28 16:40 ` jakub at gcc dot gnu.org
@ 2011-03-28 19:46 ` jakub at gcc dot gnu.org
  2011-03-29 20:31 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-28 19:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-28 18:49:06 UTC ---
Created attachment 23792
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23792
gcc46-pr48248.patch

Untested fix (the second alternative).


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (4 preceding siblings ...)
  2011-03-28 19:46 ` jakub at gcc dot gnu.org
@ 2011-03-29 20:31 ` jakub at gcc dot gnu.org
  2011-03-29 20:39 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-29 20:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-29 20:25:32 UTC ---
Author: jakub
Date: Tue Mar 29 20:25:27 2011
New Revision: 171693

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171693
Log:
    PR preprocessor/48248
    * c-ppoutput.c (print): Add src_file field.
    (init_pp_output): Initialize it.
    (maybe_print_line): Don't optimize by adding up to 8 newlines
    if map->to_file and print.src_file are different file.
    (print_line): Update print.src_file.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/c-ppoutput.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (5 preceding siblings ...)
  2011-03-29 20:31 ` jakub at gcc dot gnu.org
@ 2011-03-29 20:39 ` jakub at gcc dot gnu.org
  2011-03-29 21:14 ` [Bug preprocessor/48248] [4.5 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-29 20:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-29 20:30:14 UTC ---
Author: jakub
Date: Tue Mar 29 20:30:06 2011
New Revision: 171697

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171697
Log:
    PR preprocessor/48248
    * c-ppoutput.c (print): Add src_file field.
    (init_pp_output): Initialize it.
    (maybe_print_line): Don't optimize by adding up to 8 newlines
    if map->to_file and print.src_file are different file.
    (print_line): Update print.src_file.

Modified:
    branches/gcc-4_6-branch/gcc/c-family/ChangeLog
    branches/gcc-4_6-branch/gcc/c-family/c-ppoutput.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (6 preceding siblings ...)
  2011-03-29 20:39 ` jakub at gcc dot gnu.org
@ 2011-03-29 21:14 ` jakub at gcc dot gnu.org
  2011-04-10 10:45 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-29 21:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.5/4.6/4.7 Regression]    |[4.5 Regression] Wrong
                   |Wrong error message         |error message location when
                   |location when compiling     |compiling preprocessed code
                   |preprocessed code           |

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-29 20:42:32 UTC ---
Fixed for 4.6.1+ so far.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (7 preceding siblings ...)
  2011-03-29 21:14 ` [Bug preprocessor/48248] [4.5 " jakub at gcc dot gnu.org
@ 2011-04-10 10:45 ` rguenth at gcc dot gnu.org
  2011-04-19  9:14 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-10 10:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (8 preceding siblings ...)
  2011-04-10 10:45 ` rguenth at gcc dot gnu.org
@ 2011-04-19  9:14 ` rguenth at gcc dot gnu.org
  2011-04-19  9:21 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-19  9:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-19 09:14:08 UTC ---
Author: rguenth
Date: Tue Apr 19 09:14:05 2011
New Revision: 172701

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172701
Log:
2011-04-18  Richard Guenther  <rguenther@suse.de>

    PR preprocessor/48248
    * c-ppoutput.c (maybe_print_line): Avoid changing -P behavior.

Modified:
    branches/gcc-4_6-branch/gcc/c-family/ChangeLog
    branches/gcc-4_6-branch/gcc/c-family/c-ppoutput.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (9 preceding siblings ...)
  2011-04-19  9:14 ` rguenth at gcc dot gnu.org
@ 2011-04-19  9:21 ` rguenth at gcc dot gnu.org
  2011-04-19  9:36 ` rguenth at gcc dot gnu.org
  2011-04-26 10:17 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-19  9:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #10 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-19 09:19:35 UTC ---
Author: rguenth
Date: Tue Apr 19 09:19:33 2011
New Revision: 172703

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172703
Log:
2011-04-19  Richard Guenther  <rguenther@suse.de>

    Backported from 4.6 branch
    2011-03-29  Jakub Jelinek  <jakub@redhat.com>

    PR preprocessor/48248
    * c-ppoutput.c (print): Add src_file field.
    (init_pp_output): Initialize it.
    (maybe_print_line): Don't optimize by adding up to 8 newlines
    if map->to_file and print.src_file are different file.
    (print_line): Update print.src_file.

    2011-04-18  Richard Guenther  <rguenther@suse.de>

    PR preprocessor/48248
    * c-ppoutput.c (maybe_print_line): Avoid changing -P behavior.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/c-ppoutput.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (10 preceding siblings ...)
  2011-04-19  9:21 ` rguenth at gcc dot gnu.org
@ 2011-04-19  9:36 ` rguenth at gcc dot gnu.org
  2011-04-26 10:17 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-19  9:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
      Known to fail|                            |4.5.2

--- Comment #11 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-19 09:36:01 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug preprocessor/48248] [4.5 Regression] Wrong error message location when compiling preprocessed code
  2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
                   ` (11 preceding siblings ...)
  2011-04-19  9:36 ` rguenth at gcc dot gnu.org
@ 2011-04-26 10:17 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-26 10:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48248

--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-26 10:14:37 UTC ---
Author: rguenth
Date: Tue Apr 26 10:14:34 2011
New Revision: 172959

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172959
Log:
2011-04-26  Richard Guenther  <rguenther@suse.de>

    PR preprocessor/48248
    * c-ppoutput.c (maybe_print_line): Always optimize newlines
    for output size with -P.

Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-ppoutput.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-04-26 10:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23  9:27 [Bug preprocessor/48248] New: Wrong error message location when compiling preprocessed code joerg.richter@pdv-fs.de
2011-03-23 10:05 ` [Bug preprocessor/48248] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-03-28 14:05 ` jakub at gcc dot gnu.org
2011-03-28 14:26 ` joerg.richter@pdv-fs.de
2011-03-28 16:40 ` jakub at gcc dot gnu.org
2011-03-28 19:46 ` jakub at gcc dot gnu.org
2011-03-29 20:31 ` jakub at gcc dot gnu.org
2011-03-29 20:39 ` jakub at gcc dot gnu.org
2011-03-29 21:14 ` [Bug preprocessor/48248] [4.5 " jakub at gcc dot gnu.org
2011-04-10 10:45 ` rguenth at gcc dot gnu.org
2011-04-19  9:14 ` rguenth at gcc dot gnu.org
2011-04-19  9:21 ` rguenth at gcc dot gnu.org
2011-04-19  9:36 ` rguenth at gcc dot gnu.org
2011-04-26 10:17 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).