[C++ PATCH for 3.4/4.0/4.1] Fix PR20240 (Accepting invalid using decl involving variable declaration)

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Mar 21 03:01:00 GMT 2005

Mark Mitchell <mark@codesourcery.com> writes:

| Kriang Lerdsuwanakij wrote:
| > Hi
| > This patch fixes PR20240, a regression on 3.3 up to mainline.
| > There is a problem deciding whether name from using declaration
| > and locally declared name conflicts.  That check relies on
| > decls_match.  Unlike typedef (no conflict if both refer to the
| > same type), it is always a conflict when they are variable
| > declaration.  The patch adds a missing check inside decls_match.
| > Tested on i686-pc-linux-gnu.  OK for mainline, 3.4 and 4.0 branches?
| I'm not convinced this is the right place to detect the error.
| Why aren't we issuing an error in supplement_binding, when we try to
| add the USING_DECL for "a" to the existing binding for "a"?

A traditional invariant of supplement_binding() is that it does not
issue diagnostic and caller is supposed to check.  I have no idea of
why that invariant was put in the first place:

   It's the responsibility of the caller to check that
   inserting this name is valid here.  Returns nonzero if the new binding
   was successful.  */

but I think that we may get duplicate diagnostics.

-- Gaby

More information about the Gcc-patches mailing list