+2013-06-04 Balaji V.
authorBalaji V. Iyer <balaji.v.iyer@intel.com>
Wed, 5 Jun 2013 19:43:44 +0000 (19:43 +0000)
committerBalaji V. Iyer <bviyer@gcc.gnu.org>
Wed, 5 Jun 2013 19:43:44 +0000 (12:43 -0700)
+2013-06-04  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+       * c-typeck.c (convert_arguments): Moved checking of builtin cilkplus
+       reduction functions outside the for-loop.  Also, added a check if the
+       fundecl is non-NULL.
+

+2013-06-05  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+       PR C/57457
+       * c-c++-common/cilk-plus/AN/pr57457.c: New test.
+       * c-c++-common/cilk-plus/AN/pr57457-2.c: Likewise.
+

From-SVN: r199709

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c [new file with mode: 0644]

index 48be2fd8a6974cb4800dd3374daf9e40b0feb238..2543f5d6eb55cd1b972ede37f5c417fdf57cb0d4 100644 (file)
@@ -1,3 +1,10 @@
+2013-06-05  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+       * c-typeck.c (convert_arguments): Moved checking of builtin cilkplus
+       reduction functions outside the for-loop.  Added a check if the fundecl
+       is non-NULL.  Finally, removed an unwanted if-statement, and made the
+       body unconditional.
+
 2013-06-03  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        * c-typeck.c (c_finish_if_stmt): Added a check to see if the rank of the
index e5e1455faa1e3709828fac6c07857bd8fe4f8838..3a923111429821b41a0f8b18722d2c547dfdbdaf 100644 (file)
@@ -2942,6 +2942,8 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
          break;
        }
     }
+  if (flag_enable_cilkplus && fundecl && is_cilkplus_reduce_builtin (fundecl))
+    return vec_safe_length (values);
 
   /* Scan the given expressions and types, producing individual
      converted arguments.  */
@@ -2959,17 +2961,6 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
       bool npc;
       tree parmval;
 
-      // FIXME: I assume this code is here to handle the overloaded
-      // behavior of the __sec_reduce* builtins, and avoid giving
-      // argument mismatch warnings/errors.  We should probably handle
-      // this with the resolve_overloaded_builtin infrastructure.
-      /* If the function call is a builtin function call, then we do not
-        worry about it since we break them up into its equivalent later and
-        we do the appropriate checks there.  */
-      if (flag_enable_cilkplus
-         && is_cilkplus_reduce_builtin (fundecl))
-       continue;
-      
       if (type == void_type_node)
        {
          if (selector)
@@ -3207,16 +3198,10 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
 
   if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
     {
-      /* If array notation is used and Cilk Plus is enabled, then we do not
-        worry about this error now.  We will handle them in a later place.  */
-      if (!flag_enable_cilkplus
-         || !is_cilkplus_reduce_builtin (fundecl))
-       {
-         error_at (input_location,
-                   "too few arguments to function %qE", function);
-         inform_declaration (fundecl);
-         return -1;
-       }
+      error_at (input_location,
+               "too few arguments to function %qE", function);
+      inform_declaration (fundecl);
+      return -1;
     }
 
   return error_args ? -1 : (int) parmnum;
index f214b588a88fa4f750e295445c2b9c78f4466c99..71b76ad6cd7773e26b9849903d7e0178b85a9b10 100644 (file)
@@ -1,3 +1,9 @@
+2013-06-05  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+       PR C/57457
+       * c-c++-common/cilk-plus/AN/pr57457.c: New test.
+       * c-c++-common/cilk-plus/AN/pr57457-2.c: Likewise.
+
 2013-06-05  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51908
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c
new file mode 100644 (file)
index 0000000..ac11b92
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+/* Test-case contains no array notation but is compiled with -fcilkplus.  
+   It will still print the too few arguments func, thereby saying the
+   if-statement after the for-loop to check for !flag_enable_cilkplus ||
+   !is_cilkplus_reduce_function (fundecl) is not valid is always taken.  */
+
+int func (int, int); /* { dg-message "declared here" } */
+
+int main (void)
+{
+  int a = 5, b = 2;
+  return func (a); /* { dg-error "too few arguments to function" } */
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c
new file mode 100644 (file)
index 0000000..68a1fd8
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+/* This test has no array notation components in it and thus should compile
+   fine without crashing.  */
+
+typedef unsigned int size_t;
+typedef int (*__compar_fn_t) (const void *, const void *);
+extern void *bsearch (const void *__key, const void *__base,
+                     size_t __nmemb, size_t __size, __compar_fn_t
+                     __compar)
+  __attribute__ ((__nonnull__ (1, 2, 5))) ;
+extern __inline __attribute__ ((__gnu_inline__)) void *
+bsearch (const void *__key, const void *__base, size_t __nmemb, size_t
+        __size,
+        __compar_fn_t __compar)
+{
+  size_t __l, __u, __idx;
+  const void *__p;
+  int __comparison;
+  __l = 0;
+  __u = __nmemb;
+  while (__l < __u)
+    {
+      __idx = (__l + __u) / 2;
+      __p = (void *) (((const char *) __base) +
+                     (__idx * __size));
+      __comparison = (*__compar) (__key,
+                                 __p);
+      if (__comparison < 0)
+       __u = __idx;
+      else if (__comparison > 0)
+       __l = __idx + 1;
+      else
+       return (void *)
+         __p;
+    }
+  return ((void *)0);
+}