@@ -987,6 +987,10 @@ void cpp_typecheck_resolvet::resolve_scope(
987
987
recursive?cpp_scopet::RECURSIVE:cpp_scopet::QUALIFIED,
988
988
cpp_idt::TEMPLATE,
989
989
id_set);
990
+
991
+ // std::cout << "S: " << cpp_typecheck.cpp_scopes.current_scope().identifier << std::endl;
992
+ // cpp_typecheck.cpp_scopes.current_scope().print(std::cout);
993
+ // std::cout << "X: " << id_set.size() <<std::endl;
990
994
991
995
const symbolt &symb_tmpl=
992
996
disambiguate_template_classes (base_name, id_set, template_args);
@@ -1002,7 +1006,7 @@ void cpp_typecheck_resolvet::resolve_scope(
1002
1006
base_name,
1003
1007
recursive?cpp_scopet::RECURSIVE:cpp_scopet::QUALIFIED,
1004
1008
id_set);
1005
-
1009
+
1006
1010
filter_for_named_scopes (id_set);
1007
1011
1008
1012
if (id_set.empty ())
@@ -1081,7 +1085,8 @@ const symbolt &cpp_typecheck_resolvet::disambiguate_template_classes(
1081
1085
{
1082
1086
cpp_typecheck.show_instantiation_stack (cpp_typecheck.str );
1083
1087
cpp_typecheck.err_location (location);
1084
- cpp_typecheck.str << " template scope `" << base_name << " ' not found" ;
1088
+ cpp_typecheck.str << " template scope `"
1089
+ << base_name << " ' not found" ;
1085
1090
throw 0 ;
1086
1091
}
1087
1092
@@ -2444,22 +2449,30 @@ void cpp_typecheck_resolvet::filter_for_named_scopes(
2444
2449
}
2445
2450
else if (id.id_class ==cpp_scopet::TEMPLATE_ARGUMENT)
2446
2451
{
2447
- // maybe it is a scope
2448
- exprt e = cpp_typecheck.template_map .lookup (id.identifier );
2449
-
2450
- if (e.id () != ID_type)
2451
- continue ; // it's definitively not a scope
2452
+ // a template argument may be a scope: it could
2453
+ // be instantiated with a class/struct
2454
+ exprt e=cpp_typecheck.template_map .lookup (id.identifier );
2455
+
2456
+ if (e.id ()!=ID_type)
2457
+ continue ; // expressions are definitively not a scope
2452
2458
2453
- if (e.type ().id () == ID_symbol)
2459
+ if (e.type ().id ()== ID_symbol)
2454
2460
{
2455
- irep_idt identifier= e.type (). get (ID_identifier );
2461
+ symbol_typet type= to_symbol_type ( e.type ());
2456
2462
2457
2463
while (true )
2458
2464
{
2465
+ irep_idt identifier=type.get_identifier ();
2466
+
2459
2467
const symbolt &symbol=cpp_typecheck.lookup (identifier);
2460
2468
assert (symbol.is_type );
2461
-
2462
- if (symbol.type .id ()==ID_struct)
2469
+
2470
+ if (symbol.type .id ()==ID_symbol)
2471
+ type=to_symbol_type (symbol.type );
2472
+ else if (symbol.type .id ()==ID_struct ||
2473
+ symbol.type .id ()==ID_incomplete_struct ||
2474
+ symbol.type .id ()==ID_union ||
2475
+ symbol.type .id ()==ID_incomplete_union)
2463
2476
{
2464
2477
// this is a scope, too!
2465
2478
cpp_idt &class_id=
@@ -2469,9 +2482,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes(
2469
2482
new_set.insert (&class_id);
2470
2483
break ;
2471
2484
}
2472
- else if (symbol.type .id ()==ID_symbol)
2473
- identifier=symbol.type .get (ID_identifier);
2474
- else
2485
+ else // give up
2475
2486
break ;
2476
2487
}
2477
2488
}
0 commit comments