Correctly handle "all integer" types.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 24 Aug 2010 20:03:22 +0000 (16:03 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 24 Aug 2010 20:03:22 +0000 (16:03 -0400)
Every integer value matched with aop_t_all_signed() or
aop_t_all_unsigned() now gets cast to long long integer or long long
unsigned (respectively).

src/aop-weave.c

index 995251e728e5ce40d5a42ff37b91ba7513c01e09..6235a41e4b9b5e1954008da49124fa44a7bb0e35 100644 (file)
@@ -42,6 +42,7 @@
 #include "aop-duplicate.h"
 #include "aop-dynval.h"
 #include "aop-pointcut.h"
+#include "aop-type.h"
 
 /* Throw a fatal error if a dynval is not allowed in a before-advice
    call. */
@@ -88,10 +89,48 @@ build_string_ptr (const char *string)
   return ret;
 }
 
+/* Whenver InterAspect matches an "all signed" or "all unsigned"
+   value, it needs to cast it up to a long long before passing it. */
+static tree
+cast_to_all_integer (tree val)
+{
+  tree gcc_type;
+  HOST_WIDE_INT size;
+
+  gcc_type = TREE_TYPE (val);
+  aop_assert (TREE_CODE (gcc_type) == INTEGER_TYPE);
+
+  size = int_size_in_bytes (gcc_type);
+  aop_assert (size > 0 && size <= 8);
+
+  if (size < 8)
+    {
+      tree cast_type = TYPE_UNSIGNED (gcc_type) ? long_long_unsigned_type_node
+       : long_long_integer_type_node;
+
+      val = build1 (CONVERT_EXPR, cast_type, val);
+      return val;
+    }
+  else
+    {
+      /* No cast necessary. */
+      return val;
+    }
+}
+
 static tree
 build_dynval (struct aop_dynval *dv)
 {
-  return dv->get_dynval (dv);
+  const struct aop_type *type;
+  tree val;
+
+  val = dv->get_dynval (dv);
+  type = dv->type;
+
+  if (type->kind == ATK_ALL_SIGNED || type->kind == ATK_ALL_UNSIGNED)
+    val = cast_to_all_integer (val);
+
+  return val;
 }
 
 /* Weaving functions all take varags parameters that represent the