From f3c0865d9fd9566603de270af464665eb6d78da3 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 25 Oct 2018 10:41:30 -0400
Subject: [PATCH 27/35] FIXME: fixups

---
 gcc/c-family/c-common.c             |  2 ++
 gcc/cp/semantics.c                  |  5 +++--
 gcc/cp/typeck.c                     | 10 +++++++---
 gcc/cp/typeck2.c                    | 19 ++++++++++++-------
 gcc/testsuite/g++.dg/init/array43.C |  2 +-
 5 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 500af05..5c337a4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -1236,6 +1236,8 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, tree result,
 
     loc = expansion_point_location_if_in_system_header (loc);
 
+  STRIP_ANY_LOCATION_WRAPPER (expr);
+
   if (TREE_CODE (expr) == REAL_CST || TREE_CODE (expr) == INTEGER_CST)
     {
       /* If type is complex, we are interested in compatibility with
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 866a67f..bcf79eb 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1803,8 +1803,9 @@ finish_parenthesized_expr (cp_expr expr)
        enclosed in parentheses.  */
     PTRMEM_OK_P (expr) = 0;
 
-  if (TREE_CODE (expr) == STRING_CST)
-    PAREN_STRING_LITERAL_P (expr) = 1;
+  tree stripped_expr = tree_strip_any_location_wrapper (expr);
+  if (TREE_CODE (stripped_expr) == STRING_CST)
+    PAREN_STRING_LITERAL_P (stripped_expr) = 1;
 
   expr = cp_expr (force_paren_expr (expr), expr.get_location ());
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 493cb59..50d1976 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1756,6 +1756,8 @@ cxx_alignof_expr (tree e, tsubst_flags_t complain)
       return e;
     }
 
+  STRIP_ANY_LOCATION_WRAPPER (e);
+
   e = mark_type_use (e);
 
   if (VAR_P (e))
@@ -6086,8 +6088,9 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
      so we can just form an ADDR_EXPR with the correct type.  */
   if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF)
     {
-      if (TREE_CODE (arg) == FUNCTION_DECL
-	  && !mark_used (arg, complain) && !(complain & tf_error))
+      tree stripped_arg = tree_strip_any_location_wrapper (arg);
+      if (TREE_CODE (stripped_arg) == FUNCTION_DECL
+	  && !mark_used (stripped_arg, complain) && !(complain & tf_error))
 	return error_mark_node;
       val = build_address (arg);
       if (TREE_CODE (arg) == OFFSET_REF)
@@ -8297,7 +8300,8 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
       /* C++11 8.5/17: "If the destination type is an array of characters,
 	 an array of char16_t, an array of char32_t, or an array of wchar_t,
 	 and the initializer is a string literal...".  */
-      else if (TREE_CODE (newrhs) == STRING_CST
+      else if ((TREE_CODE (tree_strip_any_location_wrapper (newrhs))
+		== STRING_CST)
 	       && char_type_p (TREE_TYPE (TYPE_MAIN_VARIANT (lhstype)))
 	       && modifycode == INIT_EXPR)
 	{
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 48e33fe..6feabde 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -459,14 +459,19 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
   if (TREE_CODE (type) == ERROR_MARK)
     return;
 
-  if (value != 0 && (VAR_P (value)
-		     || TREE_CODE (value) == PARM_DECL
-		     || TREE_CODE (value) == FIELD_DECL))
+  if (value)
     {
-      complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), 0,
-				    "%qD has incomplete type", value);
-      is_decl = true;
-    } 
+      STRIP_ANY_LOCATION_WRAPPER (value);
+
+      if (VAR_P (value)
+	  || TREE_CODE (value) == PARM_DECL
+	  || TREE_CODE (value) == FIELD_DECL)
+	{
+	  complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), 0,
+					"%qD has incomplete type", value);
+	  is_decl = true;
+	}
+    }
  retry:
   /* We must print an error message.  Be clever about what it says.  */
 
diff --git a/gcc/testsuite/g++.dg/init/array43.C b/gcc/testsuite/g++.dg/init/array43.C
index b4e6512..0078784 100644
--- a/gcc/testsuite/g++.dg/init/array43.C
+++ b/gcc/testsuite/g++.dg/init/array43.C
@@ -1,2 +1,2 @@
-int a[] = 0;  // { dg-error "5:initializer fails to determine size" }
+int a[] = 0;  // { dg-error "11:initializer fails to determine size" }
 // { dg-error "11:array must be initialized" "" { target *-*-* } .-1 }
-- 
1.8.5.3

