From 19952c8320c1fb64b693e3e616f5891ee1984e62 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 28 Aug 2015 11:42:08 -0400
Subject: [PATCH 14/66] FIXME: C/C family: various uses of token ranges that
 don't yet have test explicit coverage

---
 gcc/c-family/c-common.c |  5 +++--
 gcc/c-family/c-common.h |  2 +-
 gcc/c/c-parser.c        | 25 +++++++++++++------------
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 22cd2de..5dcc112 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5454,9 +5454,10 @@ c_sizeof_or_alignof_type (location_t loc,
    location of the ALIGNOF operator.  */
 
 tree
-c_alignof_expr (location_t loc, tree expr)
+c_alignof_expr (source_range tok_range, tree expr)
 {
   tree t;
+  location_t loc = tok_range.m_start;
 
   if (VAR_OR_FUNCTION_DECL_P (expr))
     t = size_int (DECL_ALIGN_UNIT (expr));
@@ -5464,7 +5465,7 @@ c_alignof_expr (location_t loc, tree expr)
   else if (TREE_CODE (expr) == COMPONENT_REF
 	   && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
     {
-      error_at (loc, "%<__alignof%> applied to a bit-field");
+      error_at (tok_range, "%<__alignof%> applied to a bit-field");
       t = size_one_node;
     }
   else if (TREE_CODE (expr) == COMPONENT_REF
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 9f37f92..bb7c3ed 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -794,7 +794,7 @@ extern tree c_save_expr (tree);
 extern tree c_common_truthvalue_conversion (location_t, tree);
 extern void c_apply_type_quals_to_decl (int, tree);
 extern tree c_sizeof_or_alignof_type (location_t, tree, bool, bool, int);
-extern tree c_alignof_expr (location_t, tree);
+extern tree c_alignof_expr (source_range, tree);
 /* Print an error message for invalid operands to arith operation CODE.
    NOP_EXPR is used as a special case (see truthvalue_conversion).  */
 extern void binary_op_error (location_t, enum tree_code, tree, tree);
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index f6bf948..5946376 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -4246,7 +4246,7 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack)
 		      c_parser_peek_token (parser)->value,
 		      braced_init_obstack);
       /* Use the colon as the error location.  */
-      pedwarn (c_parser_peek_2nd_token (parser)->location, OPT_Wpedantic,
+      pedwarn (c_parser_peek_2nd_token (parser)->range, OPT_Wpedantic,
 	       "obsolete use of designated initializer with %<:%>");
       c_parser_consume_token (parser);
       c_parser_consume_token (parser);
@@ -4410,7 +4410,7 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack)
 	  else
 	    {
 	      if (des_seen == 1)
-		pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
+		pedwarn (c_parser_peek_token (parser)->range, OPT_Wpedantic,
 			 "obsolete use of designated initializer without %<=%>");
 	      else
 		{
@@ -4990,7 +4990,7 @@ c_parser_statement_after_labels (c_parser *parser)
 	case RID_CILK_FOR:
 	  if (!flag_cilkplus)
 	    {
-	      error_at (c_parser_peek_token (parser)->location,
+	      error_at (c_parser_peek_token (parser)->range,
 			"-fcilkplus must be enabled to use %<_Cilk_for%>");
 	      c_parser_skip_to_end_of_block_or_statement (parser);
 	    }
@@ -5001,7 +5001,8 @@ c_parser_statement_after_labels (c_parser *parser)
 	  c_parser_consume_token (parser);
 	  c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
 	  if (!flag_cilkplus) 
-	    error_at (loc, "-fcilkplus must be enabled to use %<_Cilk_sync%>");
+	    error_at (tok_range,
+		      "-fcilkplus must be enabled to use %<_Cilk_sync%>");
 	  else 
 	    add_stmt (build_cilk_sync ());
 	  break;
@@ -5738,7 +5739,7 @@ c_parser_asm_statement (c_parser *parser)
   else if (c_parser_next_token_is_keyword (parser, RID_CONST)
 	   || c_parser_next_token_is_keyword (parser, RID_RESTRICT))
     {
-      warning_at (c_parser_peek_token (parser)->location,
+      warning_at (c_parser_peek_token (parser)->range,
 		  0,
 		  "%E qualifier ignored on asm",
 		  c_parser_peek_token (parser)->value);
@@ -6715,7 +6716,7 @@ static struct c_expr
 c_parser_alignof_expression (c_parser *parser)
 {
   struct c_expr expr;
-  location_t loc = c_parser_peek_token (parser)->location;
+  source_range tok_range = c_parser_peek_token (parser)->range;
   tree alignof_spelling = c_parser_peek_token (parser)->value;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF));
   bool is_c11_alignof = strcmp (IDENTIFIER_POINTER (alignof_spelling),
@@ -6726,10 +6727,10 @@ c_parser_alignof_expression (c_parser *parser)
   if (is_c11_alignof)
     {
       if (flag_isoc99)
-	pedwarn_c99 (loc, OPT_Wpedantic, "ISO C99 does not support %qE",
+	pedwarn_c99 (tok_range, OPT_Wpedantic, "ISO C99 does not support %qE",
 		     alignof_spelling);
       else
-	pedwarn_c99 (loc, OPT_Wpedantic, "ISO C90 does not support %qE",
+	pedwarn_c99 (tok_range, OPT_Wpedantic, "ISO C90 does not support %qE",
 		     alignof_spelling);
     }
   c_parser_consume_token (parser);
@@ -6782,9 +6783,9 @@ c_parser_alignof_expression (c_parser *parser)
       mark_exp_read (expr.value);
       c_inhibit_evaluation_warnings--;
       in_alignof--;
-      pedwarn (loc, OPT_Wpedantic, "ISO C does not allow %<%E (expression)%>",
+      pedwarn (tok_range, OPT_Wpedantic, "ISO C does not allow %<%E (expression)%>",
 	       alignof_spelling);
-      ret.value = c_alignof_expr (loc, expr.value);
+      ret.value = c_alignof_expr (tok_range, expr.value);
       ret.original_code = ERROR_MARK;
       ret.original_type = NULL;
       return ret;
@@ -9754,7 +9755,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context)
       return false;
 
     case PRAGMA_OMP_SECTION:
-      error_at (c_parser_peek_token (parser)->location,
+      error_at (c_parser_peek_token (parser)->range,
 		"%<#pragma omp section%> may only be used in "
 		"%<#pragma omp sections%> construct");
       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
@@ -9802,7 +9803,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context)
 	}
       if (context == pragma_external)
 	{
-	  error_at (c_parser_peek_token (parser)->location,
+	  error_at (c_parser_peek_token (parser)->range,
 		    "%<#pragma grainsize%> must be inside a function");
 	  c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
 	  return false;
-- 
1.8.5.3

