From e49a1ce810f19e1a147a5fd3b2e539992b81fb55 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 1 Sep 2015 10:43:46 -0400
Subject: [PATCH 45/67] FIXME: Various commented-out debugging hacks and other
 stuff that may or may not be useful

---
 gcc/c-family/c-lex.c |  1 +
 gcc/c/c-parser.c     | 15 ++++++++++++++-
 gcc/c/c-typeck.c     | 20 ++++++++++++++------
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index a96479e..3c7af0a 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -1117,6 +1117,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
 
  retry:
   tok = cpp_get_token (parse_in);
+  //fprintf (stderr, "tok->type: %i\n", tok->type);
   switch (tok->type)
     {
     case CPP_PADDING:
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index c36be6e..e6228f2 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -777,6 +777,11 @@ c_parser_consume_token (c_parser *parser)
   gcc_assert (parser->tokens[0].type != CPP_EOF);
   gcc_assert (!parser->in_pragma || parser->tokens[0].type != CPP_PRAGMA_EOL);
   gcc_assert (parser->error || parser->tokens[0].type != CPP_PRAGMA);
+
+#if 0
+  parser->tokens[0].range.debug ("c_parser_consume_token");
+#endif
+
   if (parser->tokens != &parser->tokens_buf[0])
     parser->tokens++;
   else if (parser->tokens_avail == 2)
@@ -5230,6 +5235,7 @@ c_parser_if_body (c_parser *parser, bool *if_p,
 static tree
 c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo)
 {
+  //fprintf (stderr, "c_parser_else_body\n");
   location_t body_loc = c_parser_peek_token (parser)->location;
   tree block = c_begin_compound_stmt (flag_isoc99);
   token_indent_info body_tinfo
@@ -5251,7 +5257,7 @@ c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo)
   token_indent_info next_tinfo
     = get_token_indent_info (c_parser_peek_token (parser));
   warn_for_misleading_indentation (else_tinfo, body_tinfo, next_tinfo);
-
+  //fprintf (stderr, "end of c_parser_else_body\n");
   return c_end_compound_stmt (body_loc, block, flag_isoc99);
 }
 
@@ -5277,6 +5283,7 @@ c_parser_if_statement (c_parser *parser)
   token_indent_info if_tinfo
     = get_token_indent_info (c_parser_peek_token (parser));
   c_parser_consume_token (parser);
+  //fprintf (stderr, "c_parser_if_statement\n");
   block = c_begin_compound_stmt (flag_isoc99);
   loc = c_parser_peek_token (parser)->location;
   cond = c_parser_paren_condition (parser);
@@ -7964,6 +7971,12 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
 					   &arg_loc, &literal_zero_mask);
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
 				     "expected %<)%>");
+#if 0
+	  {
+	    location_t loc_paren = c_parser_peek_token (parser)->location;
+	    inform (loc_paren, "loc_paren");
+	  }
+#endif
 	  orig_expr = expr;
 	  mark_exp_read (expr.value);
 	  if (warn_sizeof_pointer_memaccess)
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 2567340..80ad2a8 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2910,7 +2910,8 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
   if (params && !params->is_empty ())
     function = objc_rewrite_function_call (function, (*params)[0]);
 
-  function = c_fully_fold (function, false, NULL);
+  // source_range fn_expr_range;
+  function = c_fully_fold (function, false, NULL); //, &fn_expr_range);
 
   fntype = TREE_TYPE (function);
 
@@ -2926,14 +2927,21 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
 		  function);
       else if (DECL_P (function))
 	{
-	  error_at (loc,
-		    "called object %qD is not a function or function pointer",
-		    function);
+	  gcc_rich_location richloc (loc); //fn_expr_range);
+	  error_at_rich_loc
+	    (&richloc,
+	     "called object %qD is not a function or function pointer",
+	     function);
 	  inform_declaration (function);
 	}
       else
-	error_at (loc,
-		  "called object is not a function or function pointer");
+	{
+	  gcc_rich_location richloc (loc);
+	  richloc.add_expr (function);
+	  error_at_rich_loc
+	    (&richloc,
+	     "called object is not a function or function pointer");
+	}
       return error_mark_node;
     }
 
-- 
1.8.5.3

