This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] [PR13957] Improve diagnostic for missing typename
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: "Giovanni Bajo" <giovannibajo at libero dot it>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: 02 Feb 2004 01:30:28 +0100
- Subject: Re: [C++ PATCH] [PR13957] Improve diagnostic for missing typename
- Organization: Integrable Solutions
- References: <17ec01c3e91f$baa85d80$b3bc2997@bagio>
"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