c-family: Fix error-recovery ICE on __builtin_speculation_safe_value [PR94968]
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 May 2020 12:54:20 +0000 (14:54 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 7 May 2020 12:54:20 +0000 (14:54 +0200)
If the second argument of __builtin_speculation_safe_value is
error_mark_node (or has such a type), we ICE during
useless_typ_conversion_p.

202-05-07  Jakub Jelinek  <jakub@redhat.com>

PR c/94968
* c-common.c (speculation_safe_value_resolve_params): Return false if
error_operand_p (val2).
(resolve_overloaded_builtin) <case BUILT_IN_SPECULATION_SAFE_VALUE_N>:
Remove extraneous semicolon.

* gcc.dg/pr94968.c: New test.

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr94968.c [new file with mode: 0644]

index a7faf829bd6ddf96e4b4d9341ddda41faa8aa64f..2e3eb0868316d6768d39a6c13bb6af5b30303d99 100644 (file)
@@ -1,3 +1,11 @@
+202-05-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/94968
+       * c-common.c (speculation_safe_value_resolve_params): Return false if
+       error_operand_p (val2).
+       (resolve_overloaded_builtin) <case BUILT_IN_SPECULATION_SAFE_VALUE_N>:
+       Remove extraneous semicolon.
+
 2020-05-06  qing zhao  <qing.zhao@oracle.com>
 
        PR c/94230
index 4e46178d595d33ea7b447bb5eceb8eaae1921317..d164f1e2f1ff3f314ea8ba2cb67c12ff7075470a 100644 (file)
@@ -6716,6 +6716,8 @@ speculation_safe_value_resolve_params (location_t loc, tree orig_function,
       tree val2 = (*params)[1];
       if (TREE_CODE (TREE_TYPE (val2)) == ARRAY_TYPE)
        val2 = default_conversion (val2);
+      if (error_operand_p (val2))
+       return false;
       if (!(TREE_TYPE (val) == TREE_TYPE (val2)
            || useless_type_conversion_p (TREE_TYPE (val), TREE_TYPE (val2))))
        {
@@ -7400,7 +7402,7 @@ resolve_overloaded_builtin (location_t loc, tree function,
       {
        tree new_function, first_param, result;
        enum built_in_function fncode
-         = speculation_safe_value_resolve_call (function, params);;
+         = speculation_safe_value_resolve_call (function, params);
 
        if (fncode == BUILT_IN_NONE)
          return error_mark_node;
index e226435f159ac603bb22e31ca73c904d40aa2c9b..227aa639f74736f769e2c247ace8cfc61a8beb12 100644 (file)
@@ -1,3 +1,8 @@
+202-05-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/94968
+       * gcc.dg/pr94968.c: New test.
+
 2020-05-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/57359
diff --git a/gcc/testsuite/gcc.dg/pr94968.c b/gcc/testsuite/gcc.dg/pr94968.c
new file mode 100644 (file)
index 0000000..e8b2821
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR c/94968 */
+/* { dg-do compile } */
+
+int
+foo (void)
+{ 
+  __builtin_speculation_safe_value (1, x);     /* { dg-error "undeclared" } */
+}                                              /* { dg-message "each undeclared identifier is reported only once" "" { target *-*-* } .-1 } */