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

            Bug ID: 94159
           Summary: parse error on a declaration of a dependent class
                    using a class-key instead of typename
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The declaration of the q member below is rejected with a parse error,
suggesting GCC is confused about what's going on. Other compilers (all of
Clang, ICC, and VC++) accept both declarations without a complaint.

No version prior GCC version accepted the code so it's not a regression.

$ cat x.C && gcc -S -Wall -Wextra -Wpedantic x.C

template <class T>
struct A {
  template <class U>
  struct B { };
};

template <class T>
struct C
{
  typename A<T>::template B<T> *p;       // accepted
  struct A<T>::template B<T> *q;         // error

  void f ()
  {
    struct A<T>::template B<T> *r = p;   // accepted
  }
};

x.C:11:30: error: expected identifier before ‘*’ token
   11 |   struct A<T>::template B<T> *q;         // error
      |                              ^

Reply via email to