public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95742] New: Bad error message in parsing a function with "decltype()"
@ 2020-06-18 13:02 haoxintu at gmail dot com
  2020-06-18 13:11 ` [Bug c++/95742] " mpolacek at gcc dot gnu.org
  2020-06-18 13:25 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-18 13:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95742
           Summary: Bad error message in parsing a function with
                    "decltype()"
           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
                CC: redi at gcc dot gnu.org
  Target Milestone: ---

This code test.cc, I think it's not a garbage input for GCC, but it parses
badly and emits some confusing error messages.

$cat test.cc

int foo( decltype(),int) { } 

$g++-trunk -c -w test.cc
test.cc:1:19: error: expected primary-expression before ‘)’ token
    1 | int foo( decltype(),int)  { }
      |                   ^
test.cc:1:10: error: expected primary-expression before ‘decltype’
    1 | int foo( decltype(),int)  { }
      |          ^~~~~~~~~~
test.cc:1:21: error: expected primary-expression before ‘int’
    1 | int foo( decltype(),int)  { }
      |                     ^~~
test.cc:1:24: error: expression list treated as compound expression in
initializer [-fpermissive]
    1 | int foo( decltype(),int)  { }
      |                        ^

While in Clang
$clang++ -c -w test.cc
test.cc:1:19: error: expected expression
int foo( decltype(),int)  { } 
                  ^
1 error generated.


When I change the code into test1.cc, GCC get following results:

$cat test1.cc
void foo( decltype(),int) { } 

$g++-trunk -c -w test1.cc
test1.cc:1:6: error: variable or field ‘foo’ declared void
    1 | void foo( decltype(),int)  { }
      |      ^~~
test1.cc:1:20: error: expected primary-expression before ‘)’ token
    1 | void foo( decltype(),int)  { }
      |                    ^
test1.cc:1:11: error: expected primary-expression before ‘decltype’
    1 | void foo( decltype(),int)  { }
      |           ^~~~~~~~~~
test1.cc:1:22: error: expected primary-expression before ‘int’
    1 | void foo( decltype(),int)  { }

This time GCC emits "error: variable or field ‘foo’ declared void"?

Also in Clang

$clang++ -c -w test1.cc
test1.cc:1:20: error: expected expression
void foo( decltype(),int)  { } 
                   ^
1 error generated.

I guess GCC might can not recognize the function definition correctly?

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

* [Bug c++/95742] Bad error message in parsing a function with "decltype()"
  2020-06-18 13:02 [Bug c++/95742] New: Bad error message in parsing a function with "decltype()" haoxintu at gmail dot com
@ 2020-06-18 13:11 ` mpolacek at gcc dot gnu.org
  2020-06-18 13:25 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Priority|P3                          |P5
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-06-18

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I suppose in this case there's some room for improvement, but very low prio.

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

* [Bug c++/95742] Bad error message in parsing a function with "decltype()"
  2020-06-18 13:02 [Bug c++/95742] New: Bad error message in parsing a function with "decltype()" haoxintu at gmail dot com
  2020-06-18 13:11 ` [Bug c++/95742] " mpolacek at gcc dot gnu.org
@ 2020-06-18 13:25 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-18 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Haoxin Tu from comment #0)
> This code test.cc, I think it's not a garbage input for GCC,

That's debatable.

> I guess GCC might can not recognize the function definition correctly?

That's not a valid function definition though, that's why GCC doesn't recognize
it.

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

end of thread, other threads:[~2020-06-18 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 13:02 [Bug c++/95742] New: Bad error message in parsing a function with "decltype()" haoxintu at gmail dot com
2020-06-18 13:11 ` [Bug c++/95742] " mpolacek at gcc dot gnu.org
2020-06-18 13:25 ` redi 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).