From 94926fade0fd06ff78c53d248bd19c3df632ca43 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 3 Nov 2015 16:07:43 -0500
Subject: [PATCH 25/27] FIXME: function calls

---
 gcc/cp/parser.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3c97cdd..cebd564 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1782,9 +1782,6 @@ struct cp_parser_binary_operations_map_node
 
 struct cp_parser_expression_stack_entry
 {
-  cp_parser_expression_stack_entry ()
-    : lhs (NULL) {}
-
   /* Left hand side of the binary operation we are currently
      parsing.  */
   cp_expr lhs;
@@ -1978,7 +1975,7 @@ static tree cp_parser_postfix_open_square_expression
 static tree cp_parser_postfix_dot_deref_expression
   (cp_parser *, enum cpp_ttype, tree, bool, cp_id_kind *, location_t);
 static vec<tree, va_gc> *cp_parser_parenthesized_expression_list
-  (cp_parser *, int, bool, bool, bool *, bool = false);
+  (cp_parser *, int, bool, bool, bool *, bool = false, location_t * = NULL);
 /* Values for the second parameter of cp_parser_parenthesized_expression_list.  */
 enum { non_attr = 0, normal_attr = 1, id_attr = 2 };
 static void cp_parser_pseudo_destructor_name
@@ -4934,8 +4931,8 @@ cp_parser_primary_expression (cp_parser *parser,
     case CPP_NESTED_NAME_SPECIFIER:
       {
       id_expression:
-	cp_expr id_expression (NULL);
-	cp_expr decl (NULL);
+	cp_expr id_expression;
+	cp_expr decl;
 	const char *error_msg;
 	bool template_p;
 	bool done;
@@ -6125,13 +6122,16 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
   location_t loc;
   enum rid keyword;
   cp_id_kind idk = CP_ID_KIND_NONE;
-  cp_expr postfix_expression (NULL_TREE);
+  cp_expr postfix_expression;
   bool is_member_access = false;
   int saved_in_statement = -1;
 
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
   loc = token->location;
+  //inform (loc, "initial loc in cp_parser_postfix_expression: %i", loc);
+  location_t start_loc = get_range_from_loc (line_table, loc).m_start;
+
   /* Some of the productions are determined by keywords.  */
   keyword = token->keyword;
   switch (keyword)
@@ -6454,6 +6454,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
       break;
     }
 
+#if 0
+  location_t before_while_location = postfix_expression.get_location ();
+  inform (before_while_location, "before_while_location: %i", before_while_location);
+#endif
+
   /* Note that we don't need to worry about calling build_cplus_new on a
      class-valued CALL_EXPR in decltype when it isn't the end of the
      postfix-expression; unary_complex_lvalue will take care of that for
@@ -6469,6 +6474,11 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
 	postfix_expression
 	  = unqualified_name_lookup_error (postfix_expression);
 
+#if 0
+      location_t postfix_expression_loc = postfix_expression.get_location ();
+      inform (postfix_expression_loc, "postfix_expression_loc: %i", postfix_expression_loc);
+#endif
+
       /* Peek at the next token.  */
       token = cp_lexer_peek_token (parser->lexer);
 
@@ -6500,6 +6510,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
 	    bool saved_non_integral_constant_expression_p = false;
 	    tsubst_flags_t complain = complain_flags (decltype_p);
 	    vec<tree, va_gc> *args;
+	    location_t close_paren_loc;
 
             is_member_access = false;
 
@@ -6519,7 +6530,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
 		    (parser, non_attr,
 		     /*cast_p=*/false, /*allow_expansion_p=*/true,
 		     /*non_constant_p=*/NULL,
-		     /*want_literal_zero_p=*/warn_memset_transposed_args));
+		     /*want_literal_zero_p=*/warn_memset_transposed_args,
+		     /*close_paren_loc=*/&close_paren_loc));
 	    if (is_builtin_constant_p)
 	      {
 		parser->integral_constant_expression_p
@@ -6669,7 +6681,15 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
 				    koenig_p,
 				    complain);
 
-	    protected_set_expr_location (postfix_expression, token->location);
+            source_range src_range;
+            src_range.m_start = start_loc;
+            src_range.m_finish = close_paren_loc;
+            location_t pure_loc = get_pure_location (token->location);
+            location_t combined_loc = COMBINE_LOCATION_DATA (line_table,
+                                                             pure_loc,
+                                                             src_range,
+                                                             NULL);
+	    protected_set_expr_location (postfix_expression, combined_loc);
 
 	    /* The POSTFIX_EXPRESSION is certainly no longer an id.  */
 	    idk = CP_ID_KIND_NONE;
@@ -7142,7 +7162,8 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
 					 bool cast_p,
                                          bool allow_expansion_p,
 					 bool *non_constant_p,
-					 bool want_literal_zero_p)
+					 bool want_literal_zero_p,
+					 location_t *close_paren_loc)
 {
   vec<tree, va_gc> *expression_list;
   bool fold_expr_p = is_attribute_list != non_attr;
@@ -7289,6 +7310,9 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
 	cp_lexer_consume_token (parser->lexer);
       }
 
+  if (close_paren_loc)
+    *close_paren_loc = cp_lexer_peek_token (parser->lexer)->location;
+
   if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
     {
       int ending;
-- 
1.8.5.3

