===================================================================
@@ -83,6 +83,18 @@
#if GCC_VERSION >= 4001
__attribute__((format (printf, 2, 3)))
#endif
+fatal_at (source_location src_loc, const char *msg, ...)
+{
+ va_list ap;
+ va_start (ap, msg);
+ error_cb (0, CPP_DL_FATAL, 0, src_loc, 0, msg, &ap);
+ va_end (ap);
+}
+
+static void
+#if GCC_VERSION >= 4001
+__attribute__((format (printf, 2, 3)))
+#endif
fatal_at (const cpp_token *tk, const char *msg, ...)
{
va_list ap;
@@ -877,11 +889,46 @@
simplifiers.safe_push (worklist[i]);
}
+bool
+has_opt_convert_or_commutative_ops (operand *o)
+{
+ if (!o)
+ return false;
+
+ if (capture *c = dyn_cast<capture *> (o))
+ {
+ if (c->what)
+ return has_opt_convert_or_commutative_ops (c->what);
+ else
+ return false;
+ }
+
+ expr *e = dyn_cast<expr *> (o);
+ if (!e)
+ return false;
+
+ if (*e->operation == CONVERT0 || *e->operation == CONVERT1
+ || *e->operation == CONVERT2 || e->is_commutative)
+ return true;
+
+ for (unsigned i = 0; i < e->ops.length (); ++i)
+ if (has_opt_convert_or_commutative_ops (e->ops[i]))
+ return true;
+
+ return false;
+}
+
+
+
/* Lower the AST for everything in SIMPLIFIERS. */
static void
lower (vec<simplify *>& simplifiers)
{
+ for (unsigned i = 0; i < simplifiers.length (); ++i)
+ if (has_opt_convert_or_commutative_ops (simplifiers[i]->result))
+ fatal_at (simplifiers[i]->result_location, "result operand cannot contain conditional convert or commutative operator");
+
auto_vec<simplify *> out_simplifiers0;
for (unsigned i = 0; i < simplifiers.length (); ++i)
lower_opt_convert (simplifiers[i], out_simplifiers0);