]> sourceware.org Git - systemtap.git/commitdiff
PR18455: add type mismatch checks in const_folder
authorAbegail Jakop <ajakop@redhat.com>
Wed, 23 Sep 2015 14:14:53 +0000 (10:14 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Wed, 23 Sep 2015 21:39:26 +0000 (17:39 -0400)
elaborate.cxx: in const_folder::visit_binary_expression() if one
side is a literal number and the other is not pe_long or pe_unkown,
produce a type mismatch

elaborate.cxx

index 9387ffd163fdb01f5252a9199323a03a580f00f4..be82e80840bc1ae98049a36af5eb76439ca59d34 100644 (file)
@@ -3731,6 +3731,15 @@ const_folder::visit_binary_expression (binary_expression* e)
       // we'll pass on type=pe_long inference to the expression
       if (other->type == pe_unknown)
         other->type = pe_long;
+      else if (other->type != pe_long)
+        {
+          // this mismatch was not caught in the initial type resolution pass,
+          // generate a mismatch (left doesn't match right) error
+          typeresolution_info ti(session);
+          ti.assert_resolvability = true; // need this to get it throw errors
+          ti.mismatch_complexity = 1; // also needed to throw errors
+          ti.mismatch(e);
+        }
 
       if (left)
         value = left->value;
@@ -3759,6 +3768,15 @@ const_folder::visit_binary_expression (binary_expression* e)
       expression* other = left ? e->right : e->left;
       if (other->type == pe_unknown)
         other->type = pe_long;
+      else if (other->type != pe_long)
+        {
+          // this mismatch was not caught in the initial type resolution pass,
+          // generate a mismatch (left doesn't match right) error
+          typeresolution_info ti(session);
+          ti.assert_resolvability = true; // need this to get it throw errors
+          ti.mismatch_complexity = 1; // also needed to throw errors
+          ti.mismatch(e);
+        }
 
       provide (other);
       return;
This page took 0.03739 seconds and 5 git commands to generate.