From 565cd9a89a80a465887619acdb53e8b6205f5845 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 1 Sep 2015 16:15:29 -0400
Subject: [PATCH 41/67] FIXME: C: capture some tree *decl* ranges

---
 gcc/c/c-decl.c   | 18 +++++++++---------
 gcc/c/c-parser.c |  2 +-
 gcc/c/c-tree.h   |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 1e1c056..8d6b2a0 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4279,7 +4279,7 @@ build_array_declarator (location_t loc,
 {
   struct c_declarator *declarator = XOBNEW (&parser_obstack,
 					    struct c_declarator);
-  declarator->id_loc = loc;
+  declarator->id_range = source_range::from_location (loc);
   declarator->kind = cdk_array;
   declarator->declarator = 0;
   declarator->u.array.dimen = expr;
@@ -5381,7 +5381,7 @@ grokdeclarator (const struct c_declarator *declarator,
       switch (decl->kind)
 	{
 	case cdk_array:
-	  loc = decl->id_loc;
+	  loc = decl->id_range.m_start;
 	  /* FALL THRU.  */
 
 	case cdk_function:
@@ -5397,7 +5397,7 @@ grokdeclarator (const struct c_declarator *declarator,
 	  break;
 
 	case cdk_id:
-	  loc = decl->id_loc;
+	  loc = decl->id_range.m_start;
 	  if (decl->u.id)
 	    name = decl->u.id;
 	  if (first_non_attr_kind == cdk_attrs)
@@ -6315,7 +6315,7 @@ grokdeclarator (const struct c_declarator *declarator,
 		 "ISO C forbids qualified function types");
       if (type_quals)
 	type = c_build_qualified_type (type, type_quals);
-      decl = build_decl (declarator->id_loc,
+      decl = build_decl (declarator->id_range,
 			 TYPE_DECL, declarator->u.id, type);
       if (declspecs->explicit_signed_p)
 	C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
@@ -6448,7 +6448,7 @@ grokdeclarator (const struct c_declarator *declarator,
 	else if (type_quals)
 	  type = c_build_qualified_type (type, type_quals);
 
-	decl = build_decl (declarator->id_loc,
+	decl = build_decl (declarator->id_range,
 			   PARM_DECL, declarator->u.id, type);
 	if (size_varies)
 	  C_DECL_VARIABLE_SIZE (decl) = 1;
@@ -6507,7 +6507,7 @@ grokdeclarator (const struct c_declarator *declarator,
 						   NULL_TREE);
 	  }
 	type = c_build_qualified_type (type, type_quals);
-	decl = build_decl (declarator->id_loc,
+	decl = build_decl (declarator->id_range,
 			   FIELD_DECL, declarator->u.id, type);
 	DECL_NONADDRESSABLE_P (decl) = bitfield;
 	if (bitfield && !declarator->u.id)
@@ -6542,7 +6542,7 @@ grokdeclarator (const struct c_declarator *declarator,
 	      }
 	  }
 
-	decl = build_decl (declarator->id_loc,
+	decl = build_decl (declarator->id_range,
 			   FUNCTION_DECL, declarator->u.id, type);
 	decl = build_decl_attribute_variant (decl, decl_attr);
 
@@ -6639,7 +6639,7 @@ grokdeclarator (const struct c_declarator *declarator,
 			"redeclared %<extern%>");
 	  }
 
-	decl = build_decl (declarator->id_loc,
+	decl = build_decl (declarator->id_range,
 			   VAR_DECL, declarator->u.id, type);
 	if (size_varies)
 	  C_DECL_VARIABLE_SIZE (decl) = 1;
@@ -9366,7 +9366,7 @@ build_id_declarator (tree ident)
   ret->declarator = 0;
   ret->u.id = ident;
   /* Default value - may get reset to a more precise location. */
-  ret->id_loc = input_location;
+  ret->id_range = source_range::from_location (input_location);
   return ret;
 }
 
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 6defb29..c36be6e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -3278,7 +3278,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
       struct c_declarator *inner
 	= build_id_declarator (c_parser_peek_token (parser)->value);
       *seen_id = true;
-      inner->id_loc = c_parser_peek_token (parser)->location;
+      inner->id_range = c_parser_peek_token (parser)->range;
       c_parser_consume_token (parser);
       return c_parser_direct_declarator_inner (parser, *seen_id, inner);
     }
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 25e14db..1366025 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -388,7 +388,7 @@ struct c_arg_info {
 struct c_declarator {
   /* The kind of declarator.  */
   enum c_declarator_kind kind;
-  location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
+  source_range id_range; /* Currently only set for cdk_id, cdk_array. */
   /* Except for cdk_id, the contained declarator.  For cdk_id, NULL.  */
   struct c_declarator *declarator;
   union {
-- 
1.8.5.3

