]> sourceware.org Git - systemtap.git/commitdiff
PR18455: suggest type in const_folder binary expr
authorAbegail Jakop <ajakop@redhat.com>
Tue, 25 Aug 2015 15:00:51 +0000 (11:00 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Wed, 23 Sep 2015 20:09:11 +0000 (16:09 -0400)
elaborate.cxx: within const_folder::visit_binary_expression(), for cases
like {println(i+0)} where part of the binary expression is elided, suggest
what the type (pe_long) should be to the remaining part of the expression.

elaborate.cxx

index 087efed3e5fc44e90f76236c3aa18b67d4074471..9cfcd09a6090f530006bbab8048c6da2e760586c 100644 (file)
@@ -3728,6 +3728,17 @@ const_folder::visit_binary_expression (binary_expression* e)
           return;
         }
 
+      // if other is a symbol, we'll pass on type=pe_long to the vardecl to avoid
+      // any issue with an unresolved type if the symbol is not used elsewhere
+      // dont need to set the other's type since it'll be ignored in future
+      // visitors
+      symbol* other_sym = NULL;
+      other->is_symbol(other_sym);
+      if (other_sym && other->type == pe_unknown)
+        {
+          other_sym->referent->type = pe_long;
+        }
+
       if (left)
         value = left->value;
       else if (e->op == "%")
@@ -3751,7 +3762,12 @@ const_folder::visit_binary_expression (binary_expression* e)
         clog << _("Collapsing constant-identity binary operator ") << *e->tok << endl;
       relaxed_p = false;
 
-      provide (left ? e->right : e->left);
+      // we'll pass on type=pe_long to the expression
+      expression* other = left ? e->right : e->left;
+      if (other->type == pe_unknown)
+        other->type = pe_long;
+
+      provide (other);
       return;
     }
 
This page took 0.038347 seconds and 5 git commands to generate.