public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class
       [not found] <bug-93807-4@http.gcc.gnu.org/bugzilla/>
@ 2020-04-21 22:05 ` mpolacek at gcc dot gnu.org
  2020-04-21 22:18 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-21 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|accepts-invalid             |
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-04-21
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think this is valid code: C++20 [temp.names]/2 says "A name is also
considered to refer to a template if it is an unqualified-id followed by a <
and name lookup either finds one or more functions or finds nothing." so when
we're parsing
constexpr friend bool operator==<T>(T lhs, const Foo& rhs);
we treat "operator==" as a template name, because name lookup of "operator=="
found nothing and we have an operator-function-id, which is an unqualified-id. 
So the declaration isn't needed to treat "operator==<T>" as a template-id.

I'll add the test.

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

* [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class
       [not found] <bug-93807-4@http.gcc.gnu.org/bugzilla/>
  2020-04-21 22:05 ` [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class mpolacek at gcc dot gnu.org
@ 2020-04-21 22:18 ` mpolacek at gcc dot gnu.org
  2020-04-22 19:54 ` cvs-commit at gcc dot gnu.org
  2020-04-22 19:55 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-21 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(Clang doesn't accept this code because it doesn't implement P0846R0 yet.)

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

* [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class
       [not found] <bug-93807-4@http.gcc.gnu.org/bugzilla/>
  2020-04-21 22:05 ` [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class mpolacek at gcc dot gnu.org
  2020-04-21 22:18 ` mpolacek at gcc dot gnu.org
@ 2020-04-22 19:54 ` cvs-commit at gcc dot gnu.org
  2020-04-22 19:55 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-22 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:edfa7c684d329708dcee733fcb552bed9d931621

commit r10-7894-gedfa7c684d329708dcee733fcb552bed9d931621
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 21 18:11:33 2020 -0400

    c++: Add test for c++/93807

    This PR was initially accepts-invalid, but I think it's actually valid
    C++20 code.  My reasoning is that in C++20 we no longer require the
    declaration of operator== (#if-defed in the test), because C++20's
    [temp.names]/2 says "A name is also considered to refer to a template
    if it is an unqualified-id followed by a < and name lookup either finds
    one or more functions or finds nothing." so when we're parsing

      constexpr friend bool operator==<T>(T lhs, const Foo& rhs);

    we treat "operator==" as a template name, because name lookup of
    "operator==" found nothing and we have an operator-function-id, which is
    an unqualified-id, and it's followed by a <.  So the declaration isn't
    needed to treat "operator==<T>" as a template-id.

            PR c++/93807
            * g++.dg/cpp2a/fn-template20.C: New test.

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

* [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class
       [not found] <bug-93807-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-04-22 19:54 ` cvs-commit at gcc dot gnu.org
@ 2020-04-22 19:55 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-22 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Test added.

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

end of thread, other threads:[~2020-04-22 19:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93807-4@http.gcc.gnu.org/bugzilla/>
2020-04-21 22:05 ` [Bug c++/93807] -std=c++2a allows to omit out-of-class declaration in template class mpolacek at gcc dot gnu.org
2020-04-21 22:18 ` mpolacek at gcc dot gnu.org
2020-04-22 19:54 ` cvs-commit at gcc dot gnu.org
2020-04-22 19:55 ` mpolacek 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).