http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54164

             Bug #: 54164
           Summary: C++11: confusion error messages for spurious
                    "typename"
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: akim.demai...@gmail.com


Hi all,

The error message on the following input is really confusing, as G++ seems to
complain about the left-hand side of the declaration.  And then its error
recovery triggers another error pretending we should be in a namespace.

$ cat foo.cc
struct base
{};

struct derived
{
  using type = typename base;
};

$ g++-mp-4.8 -std=c++11 -Wall foo.cc
foo.cc:6:9: error: expected nested-name-specifier before 'type'
   using type = typename base;
         ^
foo.cc:6:9: error: using-declaration for non-member at class scope
foo.cc:6:14: error: expected ';' before '=' token
   using type = typename base;
              ^
foo.cc:6:14: error: expected unqualified-id before '=' token
$ g++-mp-4.8 --version
g++-mp-4.8 (MacPorts gcc48 4.8-20120729_0) 4.8.0 20120729 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ clang++ -std=c++11 -Wall foo.cc
foo.cc:6:25: error: expected a qualified name after 'typename'
  using type = typename base;
                        ^
foo.cc:6:24: error: expected ';' after alias declaration
  using type = typename base;
                       ^
                       ;
2 errors generated.

Reply via email to