From f1bbadd412db5f14c48da8d3e91acbec82aaab6a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 17 Sep 2015 15:26:58 -0400
Subject: [PATCH 17/42] FIXME: capture func_range

---
 gcc/c-family/c-common.h |  3 ++-
 gcc/c/c-decl.c          |  2 +-
 gcc/c/c-parser.c        |  1 +
 gcc/c/c-tree.h          |  1 +
 gcc/c/c-typeck.c        | 23 +++++++++++++++--------
 gcc/cp/typeck.c         |  3 ++-
 6 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index bb17fcc..68ab08d 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -961,7 +961,8 @@ extern void c_do_switch_warnings (splay_tree, location_t, tree, tree, bool,
 extern tree build_function_call (location_t, tree, tree);
 
 extern tree build_function_call_vec (location_t, vec<location_t>, tree,
-				     vec<tree, va_gc> *, vec<tree, va_gc> *);
+				     vec<tree, va_gc> *, vec<tree, va_gc> *,
+				     source_range * = NULL);
 
 extern tree resolve_overloaded_builtin (location_t, tree, vec<tree, va_gc> *);
 
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 7161168..b4257b7 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4940,7 +4940,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
 	  vec_alloc (v, 1);
 	  v->quick_push (cleanup);
 	  cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
-					       vNULL, cleanup_decl, v, NULL);
+					       vNULL, cleanup_decl, NULL, v, NULL);
 	  vec_free (v);
 
 	  /* Don't warn about decl unused; the cleanup uses it.  */
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index ed09593..eff7692 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -8016,6 +8016,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
 	  finish = parser->tokens_buf[0].range.m_finish; // FIXME: better access API to last token
 	  expr.value
 	    = c_build_function_call_vec (expr_loc, arg_loc, expr.value,
+					 &expr.src_range,
 					 exprlist, origtypes);
 	  set_c_expr_source_range (&expr, start, finish);
 
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index c2c777c..63219c1 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -657,6 +657,7 @@ extern tree c_build_va_arg (location_t, tree, tree);
 extern tree c_finish_transaction (location_t, tree, int);
 extern bool c_tree_equal (tree, tree);
 extern tree c_build_function_call_vec (location_t, vec<location_t>, tree,
+				       source_range *,
 				       vec<tree, va_gc> *, vec<tree, va_gc> *);
 
 /* Set to 0 at beginning of a function definition, set to 1 if
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index d15852d..3238d8f 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2027,7 +2027,7 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
       params->quick_push (expr_addr);
       params->quick_push (tmp_addr);
       params->quick_push (seq_cst);
-      func_call = c_build_function_call_vec (loc, vNULL, fndecl,
+      func_call = c_build_function_call_vec (loc, vNULL, fndecl, NULL,
 					     params, NULL);
 
       /* EXPR is always read.  */
@@ -2835,7 +2835,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 = c_build_function_call_vec (loc, vNULL, function,
+  ret = c_build_function_call_vec (loc, vNULL, function, NULL,
 				   v, NULL);
   vec_free (v);
   return ret;
@@ -2862,7 +2862,8 @@ tree
 build_function_call_vec (location_t loc, vec<location_t> arg_loc,
 			 tree function,
 			 vec<tree, va_gc> *params,
-			 vec<tree, va_gc> *origtypes)
+			 vec<tree, va_gc> *origtypes,
+			 source_range *func_range_ptr)
 {
   tree fntype, fundecl = 0;
   tree name = NULL_TREE, result;
@@ -2870,6 +2871,12 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
   int nargs;
   tree *argarray;
 
+  source_range func_range;
+  if (func_range_ptr)
+    func_range = *func_range_ptr;
+  else
+    func_range = source_range::from_location (loc);
+
   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   STRIP_TYPE_NOPS (function);
 
@@ -3003,7 +3010,7 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
 
 tree
 c_build_function_call_vec (location_t loc, vec<location_t> arg_loc,
-			   tree function,
+			   tree function, source_range *func_range,
 			   vec<tree, va_gc> *params,
 			   vec<tree, va_gc> *origtypes)
 {
@@ -3022,7 +3029,7 @@ c_build_function_call_vec (location_t loc, vec<location_t> arg_loc,
 	return tem;
     }
   return build_function_call_vec (loc, arg_loc, function,
-				  params, origtypes);
+				  params, origtypes, func_range);
 }
 
 /* Convert the argument expressions in the vector VALUES
@@ -3709,7 +3716,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
       params->quick_push (lhs_addr);
       params->quick_push (rhs);
       params->quick_push (seq_cst);
-      func_call = c_build_function_call_vec (loc, vNULL, fndecl,
+      func_call = c_build_function_call_vec (loc, vNULL, fndecl, NULL,
 					     params, NULL);
       add_stmt (func_call);
 
@@ -3742,7 +3749,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
   params->quick_push (lhs_addr);
   params->quick_push (old_addr);
   params->quick_push (seq_cst);
-  func_call = c_build_function_call_vec (loc, vNULL, fndecl,
+  func_call = c_build_function_call_vec (loc, vNULL, fndecl, NULL,
 					 params, NULL);
   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
 		NULL_TREE);
@@ -3786,7 +3793,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
   params->quick_push (integer_zero_node);
   params->quick_push (seq_cst);
   params->quick_push (seq_cst);
-  func_call = c_build_function_call_vec (loc, vNULL, fndecl,
+  func_call = c_build_function_call_vec (loc, vNULL, fndecl, NULL,
 					 params, NULL);
 
   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 388558c..3263433 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3397,7 +3397,8 @@ build_function_call (location_t /*loc*/,
 tree
 build_function_call_vec (location_t /*loc*/, vec<location_t> /*arg_loc*/,
 			 tree function, vec<tree, va_gc> *params,
-			 vec<tree, va_gc> * /*origtypes*/)
+			 vec<tree, va_gc> * /*origtypes*/,
+			 source_range *)
 {
   vec<tree, va_gc> *orig_params = params;
   tree ret = cp_build_function_call_vec (function, &params,
-- 
1.8.5.3

