public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it
@ 2020-03-24 17:55 redi at gcc dot gnu.org
  2020-03-25 17:52 ` [Bug c++/94306] " ppalka at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-24 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94306
           Summary: Improve diagnostic when "requires" used instead of
                    "requires requires" and add fix-it
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<typename T> struct S { };
template<typename T> requires { typename T::type; } struct S<T> { };

This gives:

c.cc:2:31: error: expected primary-expression before '{' token
    2 | template<typename T> requires { typename T::type; } struct S<T> { };
      |                               ^
c.cc:2:31: error: expected unqualified-id before '{' token
c.cc:2:62: error: 'T' was not declared in this scope
    2 | template<typename T> requires { typename T::type; } struct S<T> { };
      |                                                              ^
c.cc:2:63: error: template argument 1 is invalid
    2 | template<typename T> requires { typename T::type; } struct S<T> { };
      |                                                               ^
c.cc:2:53: error: an explicit specialization must be preceded by 'template <>'
    2 | template<typename T> requires { typename T::type; } struct S<T> { };
      |                                                     ^~~~~~~~~~~
      |                                                     template <> 


The first error is right. The second seems redundant with the first.

The rest of the errors seem bogus. T has been declared, the template argument
is valid, and the specialization is preceded by a template-head.

It would be good to suggest that it should say "requires requires {" and show a
fix-it hint.

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

* [Bug c++/94306] Improve diagnostic when "requires" used instead of "requires requires" and add fix-it
  2020-03-24 17:55 [Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it redi at gcc dot gnu.org
@ 2020-03-25 17:52 ` ppalka at gcc dot gnu.org
  2020-03-28 12:59 ` cvs-commit at gcc dot gnu.org
  2020-03-28 13:00 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-03-25 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
   Target Milestone|---                         |10.0
   Last reconfirmed|                            |2020-03-25

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.  Looking into it.

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

* [Bug c++/94306] Improve diagnostic when "requires" used instead of "requires requires" and add fix-it
  2020-03-24 17:55 [Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it redi at gcc dot gnu.org
  2020-03-25 17:52 ` [Bug c++/94306] " ppalka at gcc dot gnu.org
@ 2020-03-28 12:59 ` cvs-commit at gcc dot gnu.org
  2020-03-28 13:00 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-28 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:7981c06ae92548bd66f07121db1802eb6aec73ed

commit r10-7442-g7981c06ae92548bd66f07121db1802eb6aec73ed
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sat Mar 28 08:57:11 2020 -0400

    c++: Diagnose when "requires" is used instead of "requires requires"
[PR94306]

    This adds support to detect and recover from the case where an opening
brace
    immediately follows the start of a requires-clause.  So rather than
emitting the
    error

      error: expected primary-expression before '{' token

    followed by a slew of irrevelant errors, we now assume the user had
intended to
    write "requires requires {" and diagnose and recover accordingly.

    gcc/cp/ChangeLog:

            PR c++/94306
            * parser.c (cp_parser_requires_clause_opt): Diagnose and recover
from
            "requires {" when "requires requires {" was probably intended.

    gcc/testsuite/ChangeLog:

            PR c++/94306
            * g++.dg/concepts/diagnostic8.C: New test.

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

* [Bug c++/94306] Improve diagnostic when "requires" used instead of "requires requires" and add fix-it
  2020-03-24 17:55 [Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it redi at gcc dot gnu.org
  2020-03-25 17:52 ` [Bug c++/94306] " ppalka at gcc dot gnu.org
  2020-03-28 12:59 ` cvs-commit at gcc dot gnu.org
@ 2020-03-28 13:00 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-03-28 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-03-28 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 17:55 [Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it redi at gcc dot gnu.org
2020-03-25 17:52 ` [Bug c++/94306] " ppalka at gcc dot gnu.org
2020-03-28 12:59 ` cvs-commit at gcc dot gnu.org
2020-03-28 13:00 ` ppalka 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).