public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-12 11:58 ` jakub at gcc dot gnu.org
  2020-03-12 17:27 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-12 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.3                         |9.4

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 9.3.0 has been released, adjusting target milestone.

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

* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
  2020-03-12 11:58 ` [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536 jakub at gcc dot gnu.org
@ 2020-03-12 17:27 ` mpolacek at gcc dot gnu.org
  2020-03-12 17:43 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-12 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Not relate to parameter packs.  Also happens with normal member functions:

template <typename T> class A {
  template <typename U> class B {
    B(A<T>::B<U>&);
    void fn(A<T>::B<U> &);
  };
};

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

* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
  2020-03-12 11:58 ` [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536 jakub at gcc dot gnu.org
  2020-03-12 17:27 ` mpolacek at gcc dot gnu.org
@ 2020-03-12 17:43 ` mpolacek at gcc dot gnu.org
  2020-03-12 23:16 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-12 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The root cause isn't the C++20 feature it seems.  The following version with
explicit 'typename' is rejected, but compiles fine with clang/icc:

template <typename T> class A {
  template <typename U> class B {
    B(typename A<T>::B<U>&);
    void fn(typename A<T>::B<U> &);
  };
};

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

* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-03-12 17:43 ` mpolacek at gcc dot gnu.org
@ 2020-03-12 23:16 ` mpolacek at gcc dot gnu.org
  2020-03-26 22:47 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-12 23:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(We accept it when the template keyword is added: "typename A<T>::template
B<U>".)

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

* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-03-12 23:16 ` mpolacek at gcc dot gnu.org
@ 2020-03-26 22:47 ` cvs-commit at gcc dot gnu.org
  2020-03-26 22:50 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-26 22:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:517f5356bb0ca717f51e937be880e38a828edbf7

commit r10-7403-g517f5356bb0ca717f51e937be880e38a828edbf7
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Mar 18 19:28:14 2020 -0400

    c++: DR1710, template keyword in a typename-specifier [PR94057]

    Consider

      template <typename T> class A {
        template <typename U> class B {
          void fn(typename A<T>::B<U>);
        };
      };

    which is rejected with
    error: 'typename A<T>::B' names 'template<class T> template<class U> class
A<T>::B', which is not a type
    whereas clang/icc/msvc accept it.

    "typename A<T>::B<U>" is a typename-specifier.  Sadly, our comments
    don't mention it anywhere, because the typename-specifier wasn't in C++11;
    it was only added to the language in N1376.  Instead, we handle it as
    an elaborated-type-specifier (not a problem thus far).   So we get to
    cp_parser_nested_name_specifier_opt which has a loop that breaks if we
    don't see a < or ::, but that means we can -- tentatively -- parse even
    B<U> which is not a nested-name-specifier (it doesn't end with a ::).

    I think this should compile because [temp.names]/4 says: "In a qualified-id
    used as the name in a typename-specifier, elaborated-type-specifier,
    using-declaration, or class-or-decltype, an optional keyword template
    appearing at the top level is ignored.", added in DR 1710.  Also see
    DR 1812.

    This issue on its own is not a significant problem or a regression.
    However, in C++20, the typename here becomes optional, and so this test
    is rejected in C++20, but accepted in C++17:

      template <typename T> class A {
        template <typename U> class B {
          void fn(A<T>::B<U>);
        };
      };

    Here we morph A<T>::B<U> into a typename-specifier, but that happens
    in cp_parser_simple_type_specifier and we never handle it as above.
    To fake the template keyword I'm afraid we need to use
cp_parser_template_id
    with template_keyword_p=true as in the patch below.  The tricky thing
    is to avoid breaking concepts.

    To handle DR 1710, I made cp_parser_nested_name_specifier_opt assume that
    when we're naming a type, the template keyword is present, too.  That
    revealed a bug: DR 1710 also says that the template keyword can be followed
    by an alias template, but we weren't prepared to handle that. 
alias-decl?.C
    exercise this.

    gcc/cp:

            DR 1710
            PR c++/94057 - template keyword in a typename-specifier.
            * parser.c (check_template_keyword_in_nested_name_spec): New.
            (cp_parser_nested_name_specifier_opt): Implement DR1710, optional
            'template'.  Call check_template_keyword_in_nested_name_spec.
            (cp_parser_simple_type_specifier): Assume that a <
            following a qualified-id in a typename-specifier begins
            a template argument list.

    gcc/testsuite:

            DR 1710
            PR c++/94057 - template keyword in a typename-specifier.
            * g++.dg/cpp1y/alias-decl1.C: New test.
            * g++.dg/cpp1y/alias-decl2.C: New test.
            * g++.dg/cpp1y/alias-decl3.C: New test.
            * g++.dg/parse/missing-template1.C: Update dg-error.
            * g++.dg/parse/template3.C: Likewise.
            * g++.dg/template/error4.C: Likewise.
            * g++.dg/template/meminit2.C: Likewise.
            * g++.dg/template/dependent-name5.C: Likewise.
            * g++.dg/template/dependent-name7.C: New test.
            * g++.dg/template/dependent-name8.C: New test.
            * g++.dg/template/dependent-name9.C: New test.
            * g++.dg/template/dependent-name10.C: New test.
            * g++.dg/template/dependent-name11.C: New test.
            * g++.dg/template/dependent-name12.C: New test.
            * g++.dg/template/dependent-name13.C: New test.
            * g++.dg/template/dr1794.C: New test.
            * g++.dg/template/dr314.C: New test.
            * g++.dg/template/dr1710.C: New test.
            * g++.dg/template/dr1710-2.C: New test.
            * g++.old-deja/g++.pt/crash38.C: Update dg-error.

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

* [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-03-26 22:47 ` cvs-commit at gcc dot gnu.org
@ 2020-03-26 22:50 ` mpolacek at gcc dot gnu.org
  2020-11-10 17:38 ` [Bug c++/94057] [9 " redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-26 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.  I don't think I want to backport this one.  To make it work with G++ 9,
add the template keyword.

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

* [Bug c++/94057] [9 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-03-26 22:50 ` mpolacek at gcc dot gnu.org
@ 2020-11-10 17:38 ` redi at gcc dot gnu.org
  2021-08-23  0:13 ` pinskia at gcc dot gnu.org
  2021-08-23 10:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-10 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu.org

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 65943 has been marked as a duplicate of this bug. ***

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

* [Bug c++/94057] [9 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2020-11-10 17:38 ` [Bug c++/94057] [9 " redi at gcc dot gnu.org
@ 2021-08-23  0:13 ` pinskia at gcc dot gnu.org
  2021-08-23 10:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |10.0

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

* [Bug c++/94057] [9 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536
       [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2021-08-23  0:13 ` pinskia at gcc dot gnu.org
@ 2021-08-23 10:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 10:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smw at gcc dot gnu.org

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 84186 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-08-23 10:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-94057-4@http.gcc.gnu.org/bugzilla/>
2020-03-12 11:58 ` [Bug c++/94057] [9/10 Regression] -std=gnu++20 causes failure naming nested templated class since r9-4536 jakub at gcc dot gnu.org
2020-03-12 17:27 ` mpolacek at gcc dot gnu.org
2020-03-12 17:43 ` mpolacek at gcc dot gnu.org
2020-03-12 23:16 ` mpolacek at gcc dot gnu.org
2020-03-26 22:47 ` cvs-commit at gcc dot gnu.org
2020-03-26 22:50 ` mpolacek at gcc dot gnu.org
2020-11-10 17:38 ` [Bug c++/94057] [9 " redi at gcc dot gnu.org
2021-08-23  0:13 ` pinskia at gcc dot gnu.org
2021-08-23 10:34 ` 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).