public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/10618] Error message for function declarations with invalid return type could be improved
Date: Wed, 21 Sep 2011 15:03:00 -0000	[thread overview]
Message-ID: <bug-10618-4-iMZHBdWb7t@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-10618-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-21 14:56:03 UTC ---
(In reply to comment #7)
> (In reply to comment #5)
> > The second part (the non-template case) of the bug is already fixed in 3.5.0:
> > pr10618.cc:15: error: `k' in class `B' does not name a type
> 
> I would say it got broken again (GCC 4.5.2)

That's not the current version, 4.6 and 4.7 have a lot of C++ diagnostic
improvements (although they don't affect this case.)

> test.cc:12:1: error: need ‘typename’ before ‘A<T>::k’ because ‘A<T>’ is a
> dependent scope
> test.cc:14:6: error: expected constructor, destructor, or type conversion
> before ‘func2’
> 
> If one adds the typename as suggested, it gets better but the first part is not
> even reported:
> 
> test.cc:14:1: error: ‘k’ in class ‘B’ does not name a type

That's because you didn't instantiate the function template 'func1'

> Clang gives the correct output:
> 
> /tmp/webcompile/_10395_0.cc:12:1: error: missing 'typename' prior to dependent
> type name 'A<T>::k'
> A<T>::k func1(); 
> ^~~~~~~
> typename 
> /tmp/webcompile/_10395_0.cc:14:4: error: no type named 'k' in 'B'
> B::k func2();
> ~~~^
> 2 errors generated.

Huh? This is the same as G++'s output

If you instantiate the function template G++ trunk gives a better diagnostic
than clang 3.0

t.cc:12:18: error: no type named 'k' in 'struct A<int>'


  parent reply	other threads:[~2011-09-21 14:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-10618-4@http.gcc.gnu.org/bugzilla/>
2011-09-21 14:56 ` manu at gcc dot gnu.org
2011-09-21 15:03 ` redi at gcc dot gnu.org [this message]
2011-09-21 15:39 ` manu at gcc dot gnu.org
2011-09-21 15:48 ` redi at gcc dot gnu.org
2011-09-21 16:00 ` manu at gcc dot gnu.org
2011-09-21 16:09 ` manu at gcc dot gnu.org
     [not found] <20030504101600.10618.giovannibajo@libero.it>
2003-08-04  0:39 ` pinskia at physics dot uc dot edu
2004-02-26 12:55 ` giovannibajo at libero dot it
2004-04-28  2:17 ` pinskia at gcc dot gnu dot org
2004-08-16 10:56 ` giovannibajo at libero dot it

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-10618-4-iMZHBdWb7t@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).