@@ -87,6 +87,11 @@ void Semantics::name(NameAST* ast, NameSem* nameSem) {
8787
8888void Semantics::nestedNameSpecifier (
8989 NestedNameSpecifierAST* ast, NestedNameSpecifierSem* nestedNameSpecifier) {
90+ if (!ast) return ;
91+ if (ast->symbol ) {
92+ nestedNameSpecifier->symbol = ast->symbol ;
93+ return ;
94+ }
9095 std::swap (nestedNameSpecifier_, nestedNameSpecifier);
9196 accept (ast);
9297 std::swap (nestedNameSpecifier_, nestedNameSpecifier);
@@ -274,18 +279,20 @@ void Semantics::visit(NestedNameSpecifierAST* ast) {
274279 for (auto it = ast->nameList ; it; it = it->next ) {
275280 NameSem name;
276281 this ->name (it->value , &name);
277- if (checkTypes_ && scope) {
278- Symbol* sym = nullptr ;
279- if (unqualifiedLookup) {
280- sym = scope->lookup (name.name , LookupOptions::kTypeOrNamespace );
281- unqualifiedLookup = false ;
282- } else {
283- sym = scope->find (name.name , LookupOptions::kTypeOrNamespace );
284- }
285- scope = sym ? sym->scope () : nullptr ;
282+ if (!scope) continue ;
283+ Symbol* sym = nullptr ;
284+ if (unqualifiedLookup) {
285+ sym = scope->lookup (name.name , LookupOptions::kTypeOrNamespace );
286+ unqualifiedLookup = false ;
287+ } else {
288+ sym = scope->find (name.name , LookupOptions::kTypeOrNamespace );
286289 }
290+ scope = sym ? sym->scope () : nullptr ;
287291 }
292+
288293 if (scope) ast->symbol = scope->owner ();
294+
295+ nestedNameSpecifier_->symbol = ast->symbol ;
289296}
290297
291298void Semantics::visit (UsingDeclaratorAST* ast) {
@@ -742,6 +749,20 @@ void Semantics::visit(TypeTraitsExpressionAST* ast) {
742749 break ;
743750 }
744751
752+ case TokenKind::T___IS_MEMBER_OBJECT_POINTER: {
753+ bool isMemberObjectPointer = false ;
754+
755+ const auto ty = ast->typeIdList ->value ->type ;
756+
757+ if (auto ptrTy = Type::cast<PointerToMemberType>(ty);
758+ ptrTy && !Type::is<FunctionType>(ptrTy->elementType ())) {
759+ isMemberObjectPointer = true ;
760+ }
761+
762+ ast->constValue = std::uint64_t (isMemberObjectPointer);
763+ break ;
764+ }
765+
745766 case TokenKind::T___IS_SIGNED: {
746767 if (auto intTy = Type::cast<IntegerType>(ast->typeIdList ->value ->type )) {
747768 const auto isSigned = !intTy->isUnsigned ();
@@ -1619,9 +1640,26 @@ void Semantics::visit(ReferenceOperatorAST* ast) {
16191640void Semantics::visit (PtrToMemberOperatorAST* ast) {
16201641 NestedNameSpecifierSem nestedNameSpecifierSem;
16211642 nestedNameSpecifier (ast->nestedNameSpecifier , &nestedNameSpecifierSem);
1643+
16221644 for (auto it = ast->attributeList ; it; it = it->next ) attribute (it->value );
1645+
16231646 SpecifiersSem specifiers;
16241647 this ->specifiers (ast->cvQualifierList , &specifiers);
1648+
1649+ auto qualifiers = specifiers.type .qualifiers ();
1650+
1651+ auto classSymbol = dynamic_cast <ClassSymbol*>(nestedNameSpecifierSem.symbol );
1652+
1653+ if (!classSymbol) {
1654+ return ;
1655+ }
1656+
1657+ const auto classTy = types_->classType (classSymbol);
1658+
1659+ QualifiedType ptrTy (
1660+ types_->pointerToMemberType (classTy, declarator_->type , qualifiers));
1661+
1662+ declarator_->type = ptrTy;
16251663}
16261664
16271665void Semantics::visit (FunctionDeclaratorAST* ast) {
0 commit comments