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: [patch] Fix PR c++/17609 on the 3.4 branch


Volker Reichelt <reichelt@igpm.rwth-aachen.de> writes:

| The following patch fixes a 3.4 regression:
| We used to give a bogus error message about an undeclared 'i' in bar():
| 
|   namespace N { int i; }
|   void foo() { i; }
| 
|   using namespace N;
|   void bar() { i; }
| 
| The error message is:
| 
|   bug.cc: In function `void foo()':
|   bug.cc:2: error: `i' undeclared (first use this function)
|   bug.cc:2: error: (Each undeclared identifier is reported only once for each function it appears in.)
|   bug.cc: In function `void bar()':
|   bug.cc:5: error: `i' undeclared (first use this function)
| 
| This was silently fixed on mainline (before the 4.0 branch) by Marks patch
| 
| http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00235.html
| 
| Only the patch in lex.c is needed to fix the bug, and for this
| push_local_binding must be made external.
| Since the patch changes the error message a little bit, several
| testcases have to be tweaked. They now match mainline.
| 
| One testcase, however is special: g++.dg/parse/error21.C:
| 
|   struct A { };
| 
|   void foo()
|   {
|     // Check that we do not complain about an unused
|     // compiler-generated variable.
|     A& = a; // { dg-error "token|declarator|undeclared" }
|   }
| 
| It checks that we don't emit a warning about a compiler-generated
| variable "_.0" with -Wall. After the patch to lex.c we'd generate
| a warning about "a" being unused, which is tolerable IMHO.
| (Btw, "a" and "_.0" are completely different beasts - I managed to
| build a compiler that warns about both variables.)
| Therefore I modified the testcase to use "A& = 1" instead of "A& = a".
| For the modified test, gcc 3.4.0 - 3.4.2 also emit a warning about
| "_.0" being unused, but now no message of a variable being unused is
| emitted for current 3.4 branch with the patch above.
| 
| I also added a new testcase (g++.dg/lookup/error1.C) for the
| problem in PR 17609.
| 
| Bootstrapped and regtested on i686-pc-linux-gnu.
| Ok for the 3.4 branch?
| New testcase OK for mainline and 4.0 branch, too?

The testcase is OK for mainline, but I would rather not have the patch
for 3.4.x for the moment.  I'm a bit nervous about patches that touch
the name lookup code.  I eventually convinced myself that the only way
we could introduce a new variable is if the code already contained an
error. 

-- Gaby


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