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,23 @@ 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+ if (binder_.scope ()->isClassScope ()) {
1066+ auto symbol = binder_.declareMemberSymbol (ast->declarator , decl);
1067+ copy->symbol = symbol;
1068+ } else {
1069+ // ## TODO
1070+ copy->symbol = ast->symbol ;
1071+ }
1072+
10581073 copy->requiresClause = operator ()(ast->requiresClause );
10591074 copy->initializer = operator ()(ast->initializer );
1060- copy->symbol = ast->symbol ;
1075+ // copy->symbol = ast->symbol; // TODO remove, done above
10611076
10621077 return copy;
10631078}
@@ -3751,6 +3766,18 @@ auto ASTRewriter::SpecifierVisitor::operator()(ClassSpecifierAST* ast)
37513766 copy->finalLoc = ast->finalLoc ;
37523767 copy->colonLoc = ast->colonLoc ;
37533768
3769+ // ### TODO: use Binder::bind()
3770+ auto _ = Binder::ScopeGuard{binder ()};
3771+ auto location = ast->symbol ->location ();
3772+ auto className = ast->symbol ->name ();
3773+ auto classSymbol = control ()->newClassSymbol (binder ()->scope (), location);
3774+ classSymbol->setName (className);
3775+ classSymbol->setIsUnion (ast->symbol ->isUnion ());
3776+ classSymbol->setFinal (ast->isFinal );
3777+ binder ()->setScope (classSymbol);
3778+
3779+ copy->symbol = classSymbol;
3780+
37543781 for (auto baseSpecifierList = ©->baseSpecifierList ;
37553782 auto node : ListView{ast->baseSpecifierList }) {
37563783 auto value = rewrite (node);
@@ -3769,7 +3796,7 @@ auto ASTRewriter::SpecifierVisitor::operator()(ClassSpecifierAST* ast)
37693796
37703797 copy->rbraceLoc = ast->rbraceLoc ;
37713798 copy->classKey = ast->classKey ;
3772- copy->symbol = ast->symbol ;
3799+ // copy->symbol = ast->symbol; // TODO: remove done by the binder
37733800 copy->isFinal = ast->isFinal ;
37743801
37753802 return copy;
0 commit comments