]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/68001
authorkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Nov 2015 12:58:12 +0000 (12:58 +0000)
committerkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Nov 2015 12:58:12 +0000 (12:58 +0000)
gcc/c-family
PR c++/68001
* c-gimplify.c (c_gimplify_expr): Stop the process if see an error.
* cilk.c (recognize_spawn): Determine location in a more precise
way.
gcc/cp
* cp-gimplify.c (cp_gimplify_expr): Stop the process if see an error.
gcc/testsuite
* g++.dg/cilk-plus/CK/pr68001.cc: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230755 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-gimplify.c
gcc/c-family/cilk.c
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc [new file with mode: 0644]

index c19cafa05f88eab2f02378e10d726ae2d315f73a..6e7b0f761f246a1a9e3a38f45788f2c2d557ab65 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-23  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR c++/68001
+       * c-gimplify.c (c_gimplify_expr): Stop the process if see an error.
+       * cilk.c (recognize_spawn): Determine location in a more precise
+       way.
+
 2015-11-19  Jason Merrill  <jason@redhat.com>
 
        * c-common.c (shorten_compare): But look through macros from
index a3d0025c63bdbb022ef15d718cda18d15d103851..fc4a44a9ebfafb9945b1487e2838e592883ebda0 100644 (file)
@@ -272,16 +272,16 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
       }
 
     case CILK_SPAWN_STMT:
-      gcc_assert
-       (fn_contains_cilk_spawn_p (cfun)
-        && cilk_detect_spawn_and_unwrap (expr_p));
+      gcc_assert(fn_contains_cilk_spawn_p (cfun)
+                && cilk_detect_spawn_and_unwrap (expr_p));
 
-      /* If errors are seen, then just process it as a CALL_EXPR.  */
       if (!seen_error ())
        {
          cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
          return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
        }
+      return GS_ERROR;
+
     case MODIFY_EXPR:
     case INIT_EXPR:
     case CALL_EXPR:
index e75e20c23836dfdd26f5f19a68ee21492876887b..15cce34b33d9f4534e7be57aa1be0aaede8819bd 100644 (file)
@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "tree-iterator.h"
 #include "tree-inline.h"
-#include "toplev.h" 
+#include "toplev.h"
 #include "calls.h"
 #include "cilk.h"
 
@@ -76,6 +76,7 @@ struct wrapper_data
   tree block;
 };
 
+static tree contains_cilk_spawn_stmt_walker (tree *tp, int *, void *);
 static void extract_free_variables (tree, struct wrapper_data *,
                                    enum add_variable_type);
 static HOST_WIDE_INT cilk_wrapper_count;
@@ -235,7 +236,19 @@ recognize_spawn (tree exp, tree *exp0)
     }
   /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR.  */
   else if (contains_cilk_spawn_stmt (exp))
-    error_at (EXPR_LOCATION (exp), "invalid use of %<_Cilk_spawn%>");
+    {
+      location_t loc = EXPR_LOCATION (exp);
+      if (loc == UNKNOWN_LOCATION)
+       {
+         tree stmt = walk_tree (&exp,
+                                contains_cilk_spawn_stmt_walker,
+                                NULL,
+                                NULL);
+         gcc_assert (stmt != NULL_TREE);
+         loc = EXPR_LOCATION (stmt);
+       }
+      error_at (loc, "invalid use of %<_Cilk_spawn%>");
+    }
   return spawn_found;
 }
 
index 4f508bde9a6de16a82f9379f8e5f5fad0f47df60..f401b822bbbf167ae847087c06cc61d5396dc3b2 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-23  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR c++/68001
+       * cp-gimplify.c (cp_gimplify_expr): Stop the process if see an error.
+
 2015-11-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/67354
index 99d0cfb8b9ea96460dffe8aa1da7640ae9736610..8fdcb6d81e06e131c0bda0762fa889a27441e9c6 100644 (file)
@@ -611,12 +611,14 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
         25979.  */
     case INIT_EXPR:
       if (fn_contains_cilk_spawn_p (cfun)
-         && cilk_detect_spawn_and_unwrap (expr_p)
-         && !seen_error ())
+         && cilk_detect_spawn_and_unwrap (expr_p))
        {
          cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
          return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
        }
+      if (seen_error ())
+       return GS_ERROR;
+
       cp_gimplify_init_expr (expr_p);
       if (TREE_CODE (*expr_p) != INIT_EXPR)
        return GS_OK;
@@ -725,16 +727,16 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       break;
 
     case CILK_SPAWN_STMT:
-      gcc_assert 
-       (fn_contains_cilk_spawn_p (cfun) 
-        && cilk_detect_spawn_and_unwrap (expr_p));
+      gcc_assert(fn_contains_cilk_spawn_p (cfun)
+                && cilk_detect_spawn_and_unwrap (expr_p));
 
-      /* If errors are seen, then just process it as a CALL_EXPR.  */
       if (!seen_error ())
        {
          cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
          return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
        }
+      return GS_ERROR;
+
     case CALL_EXPR:
       if (fn_contains_cilk_spawn_p (cfun)
          && cilk_detect_spawn_and_unwrap (expr_p)
index 1c60e503b99273cc0c697951b09909d51a1a2955..ac6f5ef6f8ea6c6ceda081fc531e381ba08da5ee 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-23  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR c++/68001
+       * g++.dg/cilk-plus/CK/pr68001.cc: New test.
+
 2015-11-23  Richard Biener  <rguenther@suse.de>
            Jiong Wang  <jiong.wang@arm.com>
 
diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc
new file mode 100644 (file)
index 0000000..07f7c5f
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR middle-end/68001 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+#include <vector>
+
+std::vector<double> f() {
+  std::vector<double> v;
+  return v;
+}
+
+int main()
+{
+  std::vector<double> x = _Cilk_spawn f(); /* { dg-error "invalid use of" } */
+  std::vector<double> y = f();
+  _Cilk_sync;
+  return 0;
+}