public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions
@ 2020-10-05 19:56 mpolacek at gcc dot gnu.org
  2020-10-05 19:56 ` [Bug c++/97297] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-05 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97297
           Summary: typename wrongly required in out-of-class member
                    function definitions
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This should compile with -std=c++20 due to P0634R3:

template <typename T>
struct S {
    int simple(T::type);

    template <typename U>
    int member(U::type);
};

template <typename T>
int S<T>::simple(T::type) { // we still wrongly require 'typename' here...
    return 1;
}

template <typename T>
template <typename U>
int S<T>::member(U::type) { // ...and here
    return 2;
}

[temp.res]/5.2.4 covers the out-of-class member function definitions.

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

* [Bug c++/97297] typename wrongly required in out-of-class member function definitions
  2020-10-05 19:56 [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions mpolacek at gcc dot gnu.org
@ 2020-10-05 19:56 ` mpolacek at gcc dot gnu.org
  2020-10-05 23:08 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-05 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-10-05
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug c++/97297] typename wrongly required in out-of-class member function definitions
  2020-10-05 19:56 [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions mpolacek at gcc dot gnu.org
  2020-10-05 19:56 ` [Bug c++/97297] " mpolacek at gcc dot gnu.org
@ 2020-10-05 23:08 ` mpolacek at gcc dot gnu.org
  2020-10-06 21:38 ` cvs-commit at gcc dot gnu.org
  2020-10-06 21:39 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-05 23:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555543.html

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

* [Bug c++/97297] typename wrongly required in out-of-class member function definitions
  2020-10-05 19:56 [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions mpolacek at gcc dot gnu.org
  2020-10-05 19:56 ` [Bug c++/97297] " mpolacek at gcc dot gnu.org
  2020-10-05 23:08 ` mpolacek at gcc dot gnu.org
@ 2020-10-06 21:38 ` cvs-commit at gcc dot gnu.org
  2020-10-06 21:39 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-06 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:85307b4e938d42201d6c232f5d9259f91133a303

commit r11-3688-g85307b4e938d42201d6c232f5d9259f91133a303
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Oct 5 17:48:19 2020 -0400

    c++: typename in out-of-class member function definitions [PR97297]

    I was notified that our P0634R3 (Down with typename) implementation has
    a flaw: when we have an out-of-class member function definition, we
    still required 'typename' for its parameters.  For example here:

      template <typename T> struct S {
        int simple(T::type);
      };
      template <typename T>
      int S<T>::simple(/* typename */T::type) { return 0; }

    the 'typename' isn't necessary per [temp.res]/5.2.4.  We have a qualified
    name here ("S<T>::simple") so we know it's already been declared so we
    can look it up to see if it's a function template or a variable
    template.

    In this case, the P0634R3 code in cp_parser_direct_declarator wasn't
    looking into uninstantiated templates and didn't find the member
    function 'simple' -- cp_parser_lookup_name returned a SCOPE_REF which
    means that the qualifying scope was dependent.  With this fix, we find
    the BASELINK for 'simple', don't clear CP_PARSER_FLAGS_TYPENAME_OPTIONAL
    from the flags, and the typename is implicitly assumed.

    gcc/cp/ChangeLog:

            PR c++/97297
            * parser.c (cp_parser_direct_declarator): When checking if a
            name is a function template declaration for the P0634R3 case,
            look in uninstantiated templates too.

    gcc/testsuite/ChangeLog:

            PR c++/97297
            * g++.dg/cpp2a/typename18.C: New test.

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

* [Bug c++/97297] typename wrongly required in out-of-class member function definitions
  2020-10-05 19:56 [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-10-06 21:38 ` cvs-commit at gcc dot gnu.org
@ 2020-10-06 21:39 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-06 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 11.  I could backport it if someone wants me to.

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

end of thread, other threads:[~2020-10-06 21:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 19:56 [Bug c++/97297] New: typename wrongly required in out-of-class member function definitions mpolacek at gcc dot gnu.org
2020-10-05 19:56 ` [Bug c++/97297] " mpolacek at gcc dot gnu.org
2020-10-05 23:08 ` mpolacek at gcc dot gnu.org
2020-10-06 21:38 ` cvs-commit at gcc dot gnu.org
2020-10-06 21:39 ` 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).