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>'

Reply via email to