tree t = convert_lvalue_to_rvalue (eloc, expr, true, true).value;
t = c_objc_common_truthvalue_conversion (eloc, t);
t = c_fully_fold (t, false, NULL);
- if (is_assume)
+ if (is_assume && t != error_mark_node)
{
- /* FIXME: Emit .ASSUME (t) call here. */
- (void) t;
+ tree fn = build_call_expr_internal_loc (eloc, IFN_ASSUME,
+ void_type_node, 1,
+ t);
+ add_stmt (fn);
}
parens.skip_until_found_close (parser);
}
matching_parens parens;
if (parens.require_open (parser))
{
+ location_t eloc = cp_lexer_peek_token (parser->lexer)->location;
tree t = cp_parser_assignment_expression (parser);
if (!type_dependent_expression_p (t))
t = contextual_conv_bool (t, tf_warning_or_error);
- if (is_assume)
+ if (is_assume && !error_operand_p (t))
{
- /* FIXME: Emit .ASSUME (t) call here. */
- (void) t;
+ t = build_call_expr_internal_loc (eloc, IFN_ASSUME,
+ void_type_node, 1, t);
+ finish_expr_stmt (t);
}
if (!parens.require_close (parser))
cp_parser_skip_to_closing_parenthesis (parser,
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 42;" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "return -1;" "optimized" } } */
+
+int
+foo (int x)
+{
+ int y;
+ #pragma omp assume holds (x == 42)
+ y = x;
+ return y;
+}
+
+int
+bar (int x)
+{
+ #pragma omp assume holds (x < 42)
+ ;
+ if (x == 42)
+ return -1;
+ return 42;
+}