re PR middle-end/57541 ([Cilkplus]: internal compiler error: in gimplify_expr, at...
authorIgor Zamyatin <igor.zamyatin@intel.com>
Mon, 30 Jun 2014 08:14:39 +0000 (08:14 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Mon, 30 Jun 2014 08:14:39 +0000 (08:14 +0000)
PR middle-end/57541
gcc/c/
* c-array-notation.c (fix_builtin_array_notation_fn):
Check for 0 arguments in builtin call. Check that bultin argument is
correct.
* c-parser.c (c_parser_array_notation): Check for incorrect initial
index.

gcc/cpp/
* cp-array-notation.c (expand_sec_reduce_builtin):
Check that bultin argument is correct.
* call.c (build_cxx_call): Check for 0 arguments in builtin call.

gcc/testsuite/
* c-c++-common/cilk-plus/AN/pr57541.c: New case added.
* c-c++-common/cilk-plus/AN/pr57541-2.c: New test.

From-SVN: r212138

gcc/c/ChangeLog
gcc/c/c-array-notation.c
gcc/c/c-parser.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-array-notation.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c

index fa7caacc422a4f0cf95b8aae4de458a846fcfeb7..02a0f2f676ac6828fc815619c5de2ff996a6c9b3 100644 (file)
@@ -1,3 +1,12 @@
+2014-06-30  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/57541
+       * c-array-notation.c (fix_builtin_array_notation_fn):
+       Check for 0 arguments in builtin call. Check that bultin argument is
+       correct.
+       * c-parser.c (c_parser_array_notation): Check for incorrect initial
+       index.
+
 2014-06-27  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        * c-parser.c (c_parser_declaration_or_fndef): Discard all type
index b4015b84ee92009d34a0d6eb1829f2b3bb0aa0f1..67a89315e9cf592ee4ff6975c24123646d7aa906 100644 (file)
@@ -214,6 +214,13 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
   if (an_type == BUILT_IN_NONE)
     return NULL_TREE;
 
+  /* Builtin call should contain at least one argument.  */
+  if (call_expr_nargs (an_builtin_fn) == 0)
+    {
+      error_at (EXPR_LOCATION (an_builtin_fn), "Invalid builtin arguments");
+      return error_mark_node;
+    }
+
   if (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE
       || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)
     {
@@ -238,7 +245,10 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
     return error_mark_node;
  
   if (rank == 0)
-    return an_builtin_fn;
+    {
+      error_at (location, "Invalid builtin arguments");
+      return error_mark_node;
+    }
   else if (rank > 1 
           && (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND
               || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND))
index 797d1bc526c0f5f1b0221f0cf054a9c71012698c..99e7fc8694c2afedc82e7e46c20e65c1125604c7 100644 (file)
@@ -14098,7 +14098,7 @@ c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index,
   tree value_tree = NULL_TREE, type = NULL_TREE, array_type = NULL_TREE;
   tree array_type_domain = NULL_TREE; 
 
-  if (array_value == error_mark_node)
+  if (array_value == error_mark_node || initial_index == error_mark_node)
     {
       /* No need to continue.  If either of these 2 were true, then an error
         must be emitted already.  Thus, no need to emit them twice.  */
index c7a0ccbfedb5778ef0e4a0424848ae3cd50d36b2..edf79e7d526dddaf8a0e5b36796baa63fca8dffe 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-30  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/57541
+       * cp-array-notation.c (expand_sec_reduce_builtin):
+       Check that bultin argument is correct.
+       * call.c (build_cxx_call): Check for 0 arguments in builtin call.
+
 2014-06-28  Jonathan Wakely  <jwakely@redhat.com>
 
        DR 1579
index 4847c3a2c2bf23fae63a7f7c51451f52d0f7daf2..e002d0180df91598e184bc0636f38bbbfd9b7958 100644 (file)
@@ -7414,6 +7414,11 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
          || bif == BUILT_IN_CILKPLUS_SEC_REDUCE
          || bif == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)
        { 
+         if (call_expr_nargs (fn) == 0)
+           {
+             error_at (EXPR_LOCATION (fn), "Invalid builtin arguments");
+             return error_mark_node;
+           }
          /* for bif == BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO or
             BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO or
             BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO or 
index 0538e559f85339d8b904d89b84ad32a8d4a7bbf7..b45449bc44df5998bd729d9844bb9d32157f2c8d 100644 (file)
@@ -250,7 +250,10 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var)
   if (!find_rank (location, an_builtin_fn, an_builtin_fn, true, &rank))
       return error_mark_node;
   if (rank == 0)
-    return an_builtin_fn;
+    {
+      error_at (location, "Invalid builtin arguments");
+      return error_mark_node;
+    }
   else if (rank > 1 
           && (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND
               || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND))
index 5a9d73a49638a5f36e9ee3b6276056ba88e81b15..c2ed2736f152f603e9c1c761480ff02a846fe218 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-30  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/57541
+       * c-c++-common/cilk-plus/AN/pr57541.c: New case added.
+       * c-c++-common/cilk-plus/AN/pr57541-2.c: New test.
+
 2014-06-30  Zhenqiang Chen  <zhenqiang.chen@linaro.org>
 
        * ira-loop-pressure.c: New test.
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541-2.c
new file mode 100644 (file)
index 0000000..83325a7
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR middle-end/57541 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int foo1 ()
+{
+  int a;
+  a = __sec_reduce_add (1); /* { dg-error "Invalid builtin arguments" } */
+}
+
+int foo2 ()
+{
+  int a;
+  a = __sec_reduce_add (); /* { dg-error "Invalid builtin arguments" } */
+}
index 9bff07991a93bcf434343a194cad80afa2ccbf5c..f379e461c5a8251f2f4db9e6903ee191722fa47c 100755 (executable)
@@ -1,9 +1,10 @@
+/* PR middle-end/57541 */
 /* { dg-do compile } */
 /* { dg-options "-fcilkplus" } */
 
 int A[10];
 
-int main () {
+int foo () {
 
   /* C compiler uses the term "undeclared" whereas C++ compiler uses
     "not declared".  Thus, grepping for declared seem to be the easiest.  */
@@ -13,5 +14,13 @@ int main () {
   A[l:s:c];
 }
 
-/* { dg-message "note: each" "defined" { target c }  10 } */
+int foo1 (int N) {
+
+  char c = (char)N;
+  short s = (short)N;
+  A[l:s:c]; /* { dg-error "declared" } */
+}
+
+
+/* { dg-message "note: each" "defined" { target c }  11 } */