@@ -666,11 +666,38 @@ void TypeChecker::Visitor::operator()(NoexceptExpressionAST* ast) {
666666 ast->type = control ()->getBoolType ();
667667}
668668
669- void TypeChecker::Visitor::operator ()(NewExpressionAST* ast) {}
669+ void TypeChecker::Visitor::operator ()(NewExpressionAST* ast) {
670+ // TODO: decay
671+ auto objectType = control ()->remove_reference (ast->objectType );
672+
673+ if (auto arrayType = type_cast<BoundedArrayType>(ast->objectType )) {
674+ ast->type = control ()->getPointerType (arrayType->elementType ());
675+ } else if (auto unboundedType =
676+ type_cast<UnboundedArrayType>(ast->objectType )) {
677+ ast->type = control ()->getPointerType (unboundedType->elementType ());
678+ } else {
679+ ast->type = control ()->getPointerType (ast->objectType );
680+ }
681+
682+ ast->valueCategory = ValueCategory::kPrValue ;
683+ }
670684
671- void TypeChecker::Visitor::operator ()(DeleteExpressionAST* ast) {}
685+ void TypeChecker::Visitor::operator ()(DeleteExpressionAST* ast) {
686+ ast->type = control ()->getVoidType ();
687+ ast->valueCategory = ValueCategory::kPrValue ;
688+ }
672689
673- void TypeChecker::Visitor::operator ()(CastExpressionAST* ast) {}
690+ void TypeChecker::Visitor::operator ()(CastExpressionAST* ast) {
691+ if (ast->typeId ) {
692+ ast->type = control ()->remove_reference (ast->typeId ->type );
693+ if (control ()->is_lvalue_reference (ast->typeId ->type ))
694+ ast->valueCategory = ValueCategory::kLValue ;
695+ else if (control ()->is_rvalue_reference (ast->typeId ->type ))
696+ ast->valueCategory = ValueCategory::kXValue ;
697+ else
698+ ast->valueCategory = ValueCategory::kPrValue ;
699+ }
700+ }
674701
675702void TypeChecker::Visitor::operator ()(ImplicitCastExpressionAST* ast) {}
676703
@@ -808,7 +835,11 @@ void TypeChecker::Visitor::operator()(TypeTraitExpressionAST* ast) {
808835
809836void TypeChecker::Visitor::operator ()(ConditionExpressionAST* ast) {}
810837
811- void TypeChecker::Visitor::operator ()(EqualInitializerAST* ast) {}
838+ void TypeChecker::Visitor::operator ()(EqualInitializerAST* ast) {
839+ if (!ast->expression ) return ;
840+ ast->type = ast->expression ->type ;
841+ ast->valueCategory = ast->expression ->valueCategory ;
842+ }
812843
813844void TypeChecker::Visitor::operator ()(BracedInitListAST* ast) {}
814845
0 commit comments