]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/60689 (Bogus error with atomic::exchange)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Apr 2014 07:54:08 +0000 (09:54 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Apr 2014 07:54:08 +0000 (09:54 +0200)
Backport from mainline
2014-03-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/60689
* c-tree.h (c_build_function_call_vec): New prototype.
* c-typeck.c (build_function_call_vec): Don't call
resolve_overloaded_builtin here.
(c_build_function_call_vec): New wrapper function around
build_function_call_vec.  Call resolve_overloaded_builtin here.
(convert_lvalue_to_rvalue, build_function_call, build_atomic_assign):
Call c_build_function_call_vec instead of build_function_call_vec.
* c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
* c-decl.c (finish_decl): Likewise.

* c-common.c (add_atomic_size_parameter): When creating new
params vector, push the size argument first.

* c-c++-common/pr60689.c: New test.

From-SVN: r209267

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/c/c-parser.c
gcc/c/c-tree.h
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr60689.c [new file with mode: 0644]

index 81c7e43e994d9a84632f0c07a6e622ae6f70862a..78a939a54ff3d182dcc0ad70b4c1058dc5fc3073 100644 (file)
@@ -1,6 +1,12 @@
 2014-04-10  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-03-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/60689
+       * c-common.c (add_atomic_size_parameter): When creating new
+       params vector, push the size argument first.
+
        2014-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/60603
index b7c68d7c0695f02c30775e32802482c1676f4d7d..86f64ec60e80c1a7269da9cdf5589879d2a05223 100644 (file)
@@ -10202,6 +10202,7 @@ add_atomic_size_parameter (unsigned n, location_t loc, tree function,
 
       len = params->length ();
       vec_alloc (v, len + 1);
+      v->quick_push (build_int_cst (size_type_node, n));
       for (z = 0; z < len; z++)
        v->quick_push ((*params)[z]);
       f = build_function_call_vec (loc, function, v, NULL);
index d1502d18744cc44800edadafe9aee45a3ee448f2..6a72aebc227b49ad4ad7ba10d39e67455b31274b 100644 (file)
@@ -1,3 +1,19 @@
+2014-04-10  Jakub Jelinek  <jakub@redhat.com>
+
+       Backport from mainline
+       2014-03-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/60689
+       * c-tree.h (c_build_function_call_vec): New prototype.
+       * c-typeck.c (build_function_call_vec): Don't call
+       resolve_overloaded_builtin here.
+       (c_build_function_call_vec): New wrapper function around
+       build_function_call_vec.  Call resolve_overloaded_builtin here.
+       (convert_lvalue_to_rvalue, build_function_call, build_atomic_assign):
+       Call c_build_function_call_vec instead of build_function_call_vec.
+       * c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
+       * c-decl.c (finish_decl): Likewise.
+
 2014-01-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/58809
index 7e4ba134e44dd193bdc21e55596bb01a47b8a768..a9108e79001df9262a7ff40adab3f2d65f839708 100644 (file)
@@ -4507,8 +4507,8 @@ finish_decl (tree decl, location_t init_loc, tree init,
          cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0);
          vec_alloc (v, 1);
          v->quick_push (cleanup);
-         cleanup = build_function_call_vec (DECL_SOURCE_LOCATION (decl),
-                                            cleanup_decl, v, NULL);
+         cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
+                                              cleanup_decl, v, NULL);
          vec_free (v);
 
          /* Don't warn about decl unused; the cleanup uses it.  */
index 2ae46220ac14cd6a52f3686e6ebd8e6710e12184..215327356cb0643b93115454b4b3e3017bd1c98a 100644 (file)
@@ -6904,8 +6904,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
                                              sizeof_ptr_memacc_comptypes);
          /* FIXME diagnostics: Ideally we want the FUNCNAME, not the
             "(" after the FUNCNAME, which is what we have now.    */
-         expr.value = build_function_call_vec (op_loc, expr.value, exprlist,
-                                               origtypes);
+         expr.value = c_build_function_call_vec (op_loc, expr.value, exprlist,
+                                                 origtypes);
          expr.original_code = ERROR_MARK;
          if (TREE_CODE (expr.value) == INTEGER_CST
              && TREE_CODE (orig_expr.value) == FUNCTION_DECL
index d1a871daa683c3b1ebe20cf7157a4ba7965656f9..1e6e68acb80a47766b2a4117d59cdefe1f24a2f3 100644 (file)
@@ -640,6 +640,8 @@ extern tree c_finish_omp_task (location_t, tree, tree);
 extern tree c_finish_omp_clauses (tree);
 extern tree c_build_va_arg (location_t, tree, tree);
 extern tree c_finish_transaction (location_t, tree, int);
+extern tree c_build_function_call_vec (location_t, tree, vec<tree, va_gc> *,
+                                      vec<tree, va_gc> *);
 
 /* Set to 0 at beginning of a function definition, set to 1 if
    a return statement that specifies a return value is seen.  */
index b0ef90a58690cc3bf4ddc7fe91847be962c3abc6..e47c2e5a45395161206d2b406726be5eac7ec789 100644 (file)
@@ -2666,7 +2666,7 @@ build_function_call (location_t loc, tree function, tree params)
   vec_alloc (v, list_length (params));
   for (; params; params = TREE_CHAIN (params))
     v->quick_push (TREE_VALUE (params));
-  ret = build_function_call_vec (loc, function, v, NULL);
+  ret = c_build_function_call_vec (loc, function, v, NULL);
   vec_free (v);
   return ret;
 }
@@ -2705,14 +2705,6 @@ build_function_call_vec (location_t loc, tree function,
   /* Convert anything with function type to a pointer-to-function.  */
   if (TREE_CODE (function) == FUNCTION_DECL)
     {
-      /* Implement type-directed function overloading for builtins.
-        resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
-        handle all the type checking.  The result is a complete expression
-        that implements this function call.  */
-      tem = resolve_overloaded_builtin (loc, function, params);
-      if (tem)
-       return tem;
-
       name = DECL_NAME (function);
 
       if (flag_tm)
@@ -2863,6 +2855,30 @@ build_function_call_vec (location_t loc, tree function,
     }
   return require_complete_type (result);
 }
+
+/* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
+
+tree
+c_build_function_call_vec (location_t loc, tree function,
+                          vec<tree, va_gc> *params,
+                          vec<tree, va_gc> *origtypes)
+{
+  /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
+  STRIP_TYPE_NOPS (function);
+
+  /* Convert anything with function type to a pointer-to-function.  */
+  if (TREE_CODE (function) == FUNCTION_DECL)
+    {
+      /* Implement type-directed function overloading for builtins.
+        resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
+        handle all the type checking.  The result is a complete expression
+        that implements this function call.  */
+      tree tem = resolve_overloaded_builtin (loc, function, params);
+      if (tem)
+       return tem;
+    }
+  return build_function_call_vec (loc, function, params, origtypes);
+}
 \f
 /* Convert the argument expressions in the vector VALUES
    to the types in the list TYPELIST.
index 7cafc5406a61e0711650b0e1732d739255463db2..dc3201cb8c16e083acd941544b21ba53d4372cbc 100644 (file)
@@ -1,6 +1,11 @@
 2014-04-10  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-03-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/60689
+       * c-c++-common/pr60689.c: New test.
+
        2014-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/60603
diff --git a/gcc/testsuite/c-c++-common/pr60689.c b/gcc/testsuite/c-c++-common/pr60689.c
new file mode 100644 (file)
index 0000000..9475bd8
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c++/60689 */
+/* { dg-do compile } */
+
+struct S { char x[9]; };
+
+void
+foo (struct S *x, struct S *y, struct S *z)
+{
+  __atomic_exchange (x, y, z, __ATOMIC_SEQ_CST);
+}