[ Adding Jason and gcc@ ] Jason,
On Tue, Apr 19, 2011 at 22:10, Lawrence Crowl <cr...@google.com> wrote: > For the testcase x1hardlookup.cc, we read in the following from > the pph file. > > namespace :: { > function_decl int <T397> (int, struct D) operator+ > type_decl struct D D > var_decl int V > type_decl struct V V > namespace N { > var_decl int x > var_decl struct V w > function_decl int <T39d> (int) I > var_decl struct C O > function_decl int <T3a1> (int, struct C) operator+ > type_decl struct C C > var_decl int V > } > } > > Then we walk though the global namespace doing > pushdecl_with_scope (t, level, /*is_friend=*/false); > for each symbol in it. > I added recursion, so that nested namespaces get the same treatment. > > pushdecl operator+ onto scope :: > pushdecl D onto scope :: > pushdecl V onto scope :: > pushdecl V onto scope :: > pushdecl x onto scope N > pushdecl w onto scope N > pushdecl I onto scope N > pushdecl O onto scope N > pushdecl operator+ onto scope N > > Looks right, but... > > x1hardlookup.cc:1:0: error: declaration of > 'int N::operator+(int, N::C)' > x1hardlookup.h:17:5: error: conflicts with previous declaration > 'int operator+(int, D)' > > So, somehow it says it's pushing to scope N, > but really it seems to be pushing to scope ::. > The same happens again. > > pushdecl C onto scope N > pushdecl V onto scope N > x1hardlookup.cc:1:0: error: declaration of > 'int N::V' > x1hardlookup.h:15:5: error: conflicts with previous declaration > 'int V' > > Any ideas on what context we're supposed to be changing to get it > to actually push the decl into the right scope? > I don't know. I thought pushdecl_with_scope would be it. Jason, is there any other bookkeeping routine we would need to be calling? Maybe we need to set some global that points to the current namespace before calling pushdecl_with_scope()? There is a 'current_namespace' definition in cp-tree.h. Maybe that needs to be setup? The way I debugged these problems is to set a breakpoint at the error() call and backtrack from there to see which lookup routine took the wrong turn. Thanks. Diego.