diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index c80c7bcc70f1626b14ed60277e267679579642ae..ab8b1f1caad927278e1dc04aa59cebaf9730c457 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -13709,7 +13709,7 @@ ordinary_loc_of (line_maps *lmaps, location_t from)
     {
       if (IS_ADHOC_LOC (from))
 	from = get_location_from_adhoc_loc (lmaps, from);
-      if (IS_MACRO_LOC (from))
+      if (from >= LINEMAPS_MACRO_LOWEST_LOCATION (lmaps))
 	{
 	  /* Find the ordinary location nearest FROM.  */
 	  const line_map *map = linemap_lookup (lmaps, from);
@@ -15554,7 +15554,7 @@ module_state::write_location (bytes_out &sec, location_t loc)
       write_location (sec, range.m_start);
       write_location (sec, range.m_finish);
     }
-  else if (IS_MACRO_LOC (loc))
+  else if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (line_table))
     {
       if (const loc_spans::span *span = spans.macro (loc))
 	{
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 40919d088acb3ad4acc6c8f6d5303b82da8ee1db..7d964172469cf7d41421c5ec1c33d40ea238d5c7 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -563,7 +563,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
 #define linemap_assert_fails(EXPR) (! (EXPR))
 #endif
 
-/* Get whether location LOC is an ad-hoc, ordinary or macro location.  */
+/* Get whether location LOC is an ordinary location.  */
 
 inline bool
 IS_ORDINARY_LOC (location_t loc)
@@ -571,18 +571,14 @@ IS_ORDINARY_LOC (location_t loc)
   return loc < LINE_MAP_MAX_LOCATION;
 }
 
+/* Get whether location LOC is an ad-hoc location.  */
+
 inline bool
 IS_ADHOC_LOC (location_t loc)
 {
   return loc > MAX_LOCATION_T;
 }
 
-inline bool
-IS_MACRO_LOC (location_t loc)
-{
-  return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
-}
-
 /* Categorize line map kinds.  */
 
 inline bool
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index a003af8533c1eaf66c20c62588bfccc25dc50abb..1bf0e8211f20f8a4928bc812bcee3cfd9cba3ee2 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -1321,7 +1321,7 @@ linemap_location_from_macro_expansion_p (const class line_maps *set,
   if (IS_ADHOC_LOC (location))
     location = get_location_from_adhoc_loc (set, location);
 
-  return IS_MACRO_LOC (location);
+  return location >= LINEMAPS_MACRO_LOWEST_LOCATION (set);
 }
 
 /* Given two virtual locations *LOC0 and *LOC1, return the first