2727#include < cxx/control.h>
2828#include < cxx/decl.h>
2929#include < cxx/decl_specs.h>
30+ #include < cxx/scope.h>
3031#include < cxx/symbols.h>
3132#include < cxx/translation_unit.h>
3233#include < cxx/type_checker.h>
@@ -1055,9 +1056,24 @@ auto ASTRewriter::operator()(InitDeclaratorAST* ast, const DeclSpecs& declSpecs)
10551056 auto copy = make_node<InitDeclaratorAST>(arena ());
10561057
10571058 copy->declarator = operator ()(ast->declarator );
1059+
1060+ auto decl = Decl{declSpecs, copy->declarator };
1061+
1062+ auto type = getDeclaratorType (translationUnit (), copy->declarator ,
1063+ declSpecs.getType ());
1064+
1065+ // ### fix scope
1066+ if (binder_.scope () && binder_.scope ()->isClassScope ()) {
1067+ auto symbol = binder_.declareMemberSymbol (ast->declarator , decl);
1068+ copy->symbol = symbol;
1069+ } else {
1070+ // ### TODO
1071+ copy->symbol = ast->symbol ;
1072+ }
1073+
10581074 copy->requiresClause = operator ()(ast->requiresClause );
10591075 copy->initializer = operator ()(ast->initializer );
1060- copy->symbol = ast->symbol ;
1076+ // copy->symbol = ast->symbol; // TODO remove, done above
10611077
10621078 return copy;
10631079}
@@ -3751,6 +3767,18 @@ auto ASTRewriter::SpecifierVisitor::operator()(ClassSpecifierAST* ast)
37513767 copy->finalLoc = ast->finalLoc ;
37523768 copy->colonLoc = ast->colonLoc ;
37533769
3770+ // ### TODO: use Binder::bind()
3771+ auto _ = Binder::ScopeGuard{binder ()};
3772+ auto location = ast->symbol ->location ();
3773+ auto className = ast->symbol ->name ();
3774+ auto classSymbol = control ()->newClassSymbol (binder ()->scope (), location);
3775+ classSymbol->setName (className);
3776+ classSymbol->setIsUnion (ast->symbol ->isUnion ());
3777+ classSymbol->setFinal (ast->isFinal );
3778+ binder ()->setScope (classSymbol);
3779+
3780+ copy->symbol = classSymbol;
3781+
37543782 for (auto baseSpecifierList = ©->baseSpecifierList ;
37553783 auto node : ListView{ast->baseSpecifierList }) {
37563784 auto value = rewrite (node);
@@ -3769,7 +3797,7 @@ auto ASTRewriter::SpecifierVisitor::operator()(ClassSpecifierAST* ast)
37693797
37703798 copy->rbraceLoc = ast->rbraceLoc ;
37713799 copy->classKey = ast->classKey ;
3772- copy->symbol = ast->symbol ;
3800+ // copy->symbol = ast->symbol; // TODO: remove done by the binder
37733801 copy->isFinal = ast->isFinal ;
37743802
37753803 return copy;
0 commit comments