@@ -1568,6 +1568,33 @@ class cppfront
1568
1568
if (!decl || !decl->declaration )
1569
1569
return addr_cnt > deref_cnt;
1570
1570
1571
+ if (auto * fun = std::get_if<declaration_node::function>(&decl->declaration ->type )) {
1572
+ if (auto * ret_id_expr = std::get_if<function_type_node::id>(&(*fun)->returns )) {
1573
+ if (auto * unqual = std::get_if<id_expression_node::unqualified>(&(*ret_id_expr)->id )){
1574
+ return is_it_pointer_declaration (*unqual, deref_cnt, addr_cnt);
1575
+ }
1576
+ }
1577
+ }
1578
+
1579
+ if (auto * obj_id_expr = std::get_if<declaration_node::object>(&decl->declaration ->type )) {
1580
+ if (auto * unqual = std::get_if<id_expression_node::unqualified>(&(*obj_id_expr)->id )){
1581
+ return is_it_pointer_declaration (*unqual, deref_cnt, addr_cnt);
1582
+ }
1583
+ }
1584
+
1585
+ if (decl->initializer && decl->initializer ->suspicious_initialization ) {
1586
+ auto init_decl = sema.get_declaration_of (*decl->initializer ->suspicious_initialization , true );
1587
+ if (init_decl && init_decl->declaration ) {
1588
+ if (auto * fun = std::get_if<declaration_node::function>(&init_decl->declaration ->type )) {
1589
+ if (auto * ret_id_expr = std::get_if<function_type_node::id>(&(*fun)->returns )) {
1590
+ if (auto * unqual = std::get_if<id_expression_node::unqualified>(&(*ret_id_expr)->id )){
1591
+ return is_it_pointer_declaration (*unqual, deref_cnt, addr_cnt);
1592
+ }
1593
+ }
1594
+ }
1595
+ }
1596
+ }
1597
+
1571
1598
if (decl->declaration ->dereference ) {
1572
1599
auto deref = sema.get_declaration_of (*decl->declaration ->dereference , true );
1573
1600
assert (deref && deref->declaration );
@@ -1604,18 +1631,9 @@ class cppfront
1604
1631
assert (unqual);
1605
1632
auto decl = sema.get_declaration_of (*unqual->identifier , true );
1606
1633
1607
- bool is_pointer = false ;
1608
- if (decl && decl->declaration ) {
1609
- if (auto * obj_id_expr = std::get_if<declaration_node::object>(&decl->declaration ->type )) {
1610
- if (auto * unqual = std::get_if<id_expression_node::unqualified>(&(*obj_id_expr)->id )){
1611
- is_pointer = !(*unqual)->pointer_declarators .empty ();
1612
- }
1613
- }
1614
- }
1615
-
1616
1634
// if initialized by something suspicious (that we have no information about) we need to add cpp1 safety checks
1617
1635
add_safetycheck = !decl && needs_safetycheck;
1618
- if (is_it_pointer_declaration (unqual) || !unqual-> pointer_declarators . empty () || is_pointer ) {
1636
+ if (is_it_pointer_declaration (unqual)) {
1619
1637
if (n.ops .empty ()) {
1620
1638
last_postfix_expr_was_pointer = true ;
1621
1639
}
0 commit comments