public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "akim.demaille at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/54164] New: C++11: confusion error messages for spurious "typename"
Date: Fri, 03 Aug 2012 10:23:00 -0000	[thread overview]
Message-ID: <bug-54164-4@http.gcc.gnu.org/bugzilla/> (raw)

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: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@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	other threads:[~2012-08-03 10:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03 10:23 akim.demaille at gmail dot com [this message]
2020-03-12 18:17 ` [Bug c++/54164] C++11: confusing " mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54164-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).