This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] [PR13957] Improve diagnostic for missing typename


"Giovanni Bajo" <giovannibajo@libero.it> writes:

| Hello,
| 
| for the attacched testcase, we used to emit this diagnostic:
| 
| nontype4.C: In function `void func() [with T = float]':
| nontype4.C:19:   instantiated from here
| template/nontype4.C:15: error: `A<T>::type' names a type, but a non-type is
| expected

I would suggest you change the wording to:

  error: dependent-name 'A<T>::type' is parsed as a non-type, but
    instantiation yields a type

That enlightens more about the programmed "expectation".


| This patch adds the following note:
| 
| nontype4.C:15: note: if a type was really intended, use `typename A<T>::type'

I like informative diagnostics; but, short is simple; short is good.
What about

   note: say 'typename A<T>::type' if a type is meant

?

In real-life codes, the template-name is not spelt "A" nor "foo", it
tends to have more characters; the key information (the advise to stick
a 'typename' in front of the qualified-id) should not be lost in
the "noise".  That advise should come first.

| which makes clearer for the user what to do to fix the code.
| 
| Tested on i686-pc-linux-gnu, OK for mainline? OK for 3.4, since it's our first
| compiler which enforces 'typename'?

With the changes, it is OK for mainline.  You'll need Mark's approval
for 3_4 (but I would strongly recommend it).

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]