public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation
@ 2020-07-03 11:05 haoxintu at gmail dot com
  2020-07-08 21:54 ` [Bug c++/96045] [11 Regression] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-03 11:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

            Bug ID: 96045
           Summary: Wrong line and column diagnostic message in a class
                    template instantiation
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This simple code, bug.cc, GCC-trunk can not emit the right diagnostic
information.

$cat bug.cc
template <class> class A {};
struct A <int> 

$g++ -c bug.cc
bug.cc:3: error: expected unqualified-id at end of input

Noted that the number 3 is not a line number nor a column number.

While in Clang
$clang++ -c bug.cc
bug.cc:2:16: error: expected unqualified-id
struct A <int> 
               ^
1 error generated.

$g++ --version
g++ (GCC) 11.0.0 20200630 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
@ 2020-07-08 21:54 ` mpolacek at gcc dot gnu.org
  2020-07-08 21:57 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 21:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-07-08
            Summary|Wrong line and column       |[11 Regression] Wrong line
                   |diagnostic message in a     |and column diagnostic
                   |class template              |message in a class template
                   |instantiation               |instantiation
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Interestingly, GCC 10 was much better:

$ xg++-10 -c 96045.C
96045.C:2:8: error: expected unqualified-id at end of input
    2 | struct A <int>
      |        ^~~~~~~

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
  2020-07-08 21:54 ` [Bug c++/96045] [11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-07-08 21:57 ` mpolacek at gcc dot gnu.org
  2020-10-16 11:54 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 21:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Regressed with r11-338-g2a0225e47868fbfceaecaa5e2de96c1c5a2251ea

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
  2020-07-08 21:54 ` [Bug c++/96045] [11 Regression] " mpolacek at gcc dot gnu.org
  2020-07-08 21:57 ` mpolacek at gcc dot gnu.org
@ 2020-10-16 11:54 ` rguenth at gcc dot gnu.org
  2020-12-22 20:49 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-16 11:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-10-16 11:54 ` rguenth at gcc dot gnu.org
@ 2020-12-22 20:49 ` jason at gcc dot gnu.org
  2020-12-22 21:00 ` nathan at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-22 20:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Nathan, this PR points out that your change to EOF location means that we no
longer show the last line of source to give context for the error.  Why not
give the EOF token a location of the end of the last line?

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2020-12-22 20:49 ` jason at gcc dot gnu.org
@ 2020-12-22 21:00 ` nathan at gcc dot gnu.org
  2020-12-23 22:26 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-22 21:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |nathan at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
There's two conflicting arguments.
a) the end of the file is just after the last \n  (the preprocessor makes sure
the file ends in \n).  That's the first column of a line that doesn't exist.

b) the EOF is just before the last \n (at the \n itself if you like).

IIRC cpplib was taking both positions, and leading to inconsistencies.  My
intent was #a, as that's the more logical position of being after the \n.  But
it may not be the best choice.  We do have to do some rewinding to deal with
that non-existent line #a creates.

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
                   ` (4 preceding siblings ...)
  2020-12-22 21:00 ` nathan at gcc dot gnu.org
@ 2020-12-23 22:26 ` cvs-commit at gcc dot gnu.org
  2020-12-26 19:51 ` cvs-commit at gcc dot gnu.org
  2021-01-28 16:07 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-23 22:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:

https://gcc.gnu.org/g:745f22096c3a2a5e63d5bab1fb079e2c437cf9bc

commit r11-6325-g745f22096c3a2a5e63d5bab1fb079e2c437cf9bc
Author: Nathan Sidwell <nathan@acm.org>
Date:   Wed Dec 23 14:17:17 2020 -0800

    c++: EOF location [PR 96045]

    Setting the EOF token location to be the start of a line just after
    the ending newline is not most helpful.  While that location is
    probably the right place to report preprocessing and lexing issues,
    when parsing, the location just after the last token is better.  That
    way we get to point at some actual text.  Setting the location from
    the previous token has the advantage over just setting the location to
    be the end of the final line, in that any ending comments do not get
    considered, which I think is better.

            PR c++/96045
            gcc/cp/
            * parser.c (cp_lexer_new_main): Adjust EOF token location.
            gcc/testsuite/
            * g++.dg/diagnostic/pr96045-1.C: New.
            * g++.dg/diagnostic/pr96045-2.C: New.
            * g++.dg/diagnostic/pr96045-3.C: New.
            * c-c++-common/goacc/pr79428-1.c: Adjust EOF diagnostic location.
            * c-c++-common/gomp/pr79428-2.c: Likewise
            * c-c++-common/raw-string-6.c: Likewise
            * g++.dg/cpp0x/decltype63.C: Likewise
            * g++.dg/cpp0x/gen-attrs-64.C: Likewise
            * g++.dg/cpp0x/pr68726.C: Likewise
            * g++.dg/cpp0x/pr78341.C: Likewise
            * g++.dg/cpp1y/pr65202.C: Likewise
            * g++.dg/cpp1y/pr65340.C: Likewise
            * g++.dg/cpp1y/pr68578.C: Likewise
            * g++.dg/cpp1z/class-deduction44.C: Likewise
            * g++.dg/diagnostic/unclosed-extern-c.C: Likewise
            * g++.dg/diagnostic/unclosed-function.C: Likewise
            * g++.dg/diagnostic/unclosed-namespace.C: Likewise
            * g++.dg/diagnostic/unclosed-struct.C: Likewise
            * g++.dg/ext/pr84598.C: Likewise
            * g++.dg/other/switch4.C: Likewise
            * g++.dg/parse/attr4.C: Likewise
            * g++.dg/parse/cond4.C: Likewise
            * g++.dg/parse/crash10.C: Likewise
            * g++.dg/parse/crash18.C: Likewise
            * g++.dg/parse/crash27.C: Likewise
            * g++.dg/parse/crash34.C: Likewise
            * g++.dg/parse/crash35.C: Likewise
            * g++.dg/parse/crash52.C: Likewise
            * g++.dg/parse/crash59.C: Likewise
            * g++.dg/parse/crash61.C: Likewise
            * g++.dg/parse/crash67.C: Likewise
            * g++.dg/parse/error14.C: Likewise
            * g++.dg/parse/error56.C: Likewise
            * g++.dg/parse/invalid1.C: Likewise
            * g++.dg/parse/parameter-declaration-1.C: Likewise
            * g++.dg/parse/parser-pr28152-2.C: Likewise
            * g++.dg/parse/parser-pr28152.C: Likewise
            * g++.dg/parse/pr68722.C: Likewise
            * g++.dg/parse/pr96258.C: Likewise
            * g++.dg/pr46852.C: Likewise
            * g++.dg/pr46868.C: Likewise
            * g++.dg/template/crash115.C: Likewise
            * g++.dg/template/crash43.C: Likewise
            * g++.dg/template/crash90.C: Likewise
            * g++.dg/template/error-recovery1.C: Likewise
            * g++.dg/template/error57.C: Likewise
            * g++.old-deja/g++.other/crash31.C: Likewise

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
                   ` (5 preceding siblings ...)
  2020-12-23 22:26 ` cvs-commit at gcc dot gnu.org
@ 2020-12-26 19:51 ` cvs-commit at gcc dot gnu.org
  2021-01-28 16:07 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-26 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:6037ebeff1cd76385e88dd9cbcaf68ada85316fb

commit r11-6343-g6037ebeff1cd76385e88dd9cbcaf68ada85316fb
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Dec 26 19:46:50 2020 +0000

    Objective-C++ : Fix up testcase EOF diagnostics.

    Some Objective-C++ testcases need modification in reponse to the
    solution to PR 96045.

    gcc/testsuite/ChangeLog:

            PR c++/96045
            * obj-c++.dg/property/property-neg-6.mm: Adjust EOF
            diagnostic location.
            * obj-c++.dg/syntax-error-10.mm: Likewise.
            * obj-c++.dg/syntax-error-8.mm: Likewise.
            * obj-c++.dg/syntax-error-9.mm: Likewise.

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

* [Bug c++/96045] [11 Regression] Wrong line and column diagnostic message in a class template instantiation
  2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
                   ` (6 preceding siblings ...)
  2020-12-26 19:51 ` cvs-commit at gcc dot gnu.org
@ 2021-01-28 16:07 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-28 16:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Assuming fixed:
./cc1plus.20200929 -quiet pr96045.C
pr96045.C:3: error: expected unqualified-id at end of input
./cc1plus.20210107 -quiet pr96045.C
pr96045.C:2:15: error: expected unqualified-id at end of input
    2 | struct A <int>
      |               ^

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

end of thread, other threads:[~2021-01-28 16:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 11:05 [Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation haoxintu at gmail dot com
2020-07-08 21:54 ` [Bug c++/96045] [11 Regression] " mpolacek at gcc dot gnu.org
2020-07-08 21:57 ` mpolacek at gcc dot gnu.org
2020-10-16 11:54 ` rguenth at gcc dot gnu.org
2020-12-22 20:49 ` jason at gcc dot gnu.org
2020-12-22 21:00 ` nathan at gcc dot gnu.org
2020-12-23 22:26 ` cvs-commit at gcc dot gnu.org
2020-12-26 19:51 ` cvs-commit at gcc dot gnu.org
2021-01-28 16:07 ` jakub 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).