[gcc/devel/c++-modules] Fix macro locs on darwin and ppc-linux (and probably others)
Nathan Sidwell
nathan@gcc.gnu.org
Mon Oct 19 16:19:20 GMT 2020
https://gcc.gnu.org/g:cf8ab1c0a4bd685361272657fb76d1b3a1ed4836
commit cf8ab1c0a4bd685361272657fb76d1b3a1ed4836
Author: Nathan Sidwell <nathan@acm.org>
Date: Mon Oct 19 09:18:43 2020 -0700
Fix macro locs on darwin and ppc-linux (and probably others)
gcc/cp/
* module.cc (module_state::write_macro_locs): Macro loc count is a
count.
(module_state::read_prepare_maps): Adjust.
gcc/testsuite/
* g++.dg/modules/macloc-2_[ab].[HC]: New.
Diff:
---
ChangeLog.modules | 9 +++++++++
gcc/cp/module.cc | 4 ++--
gcc/testsuite/g++.dg/modules/macloc-2_a.H | 9 +++++++++
gcc/testsuite/g++.dg/modules/macloc-2_b.C | 14 ++++++++++++++
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/ChangeLog.modules b/ChangeLog.modules
index f082c3bfbc9..24ccac30304 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -1,3 +1,12 @@
+2020-10-19 Nathan Sidwell <nathan@acm.org>
+
+ gcc/cp/
+ * module.cc (module_state::write_macro_locs): Macro loc count is a
+ count.
+ (module_state::read_prepare_maps): Adjust.
+ gcc/testsuite/
+ * g++.dg/modules/macloc-2_[ab].[HC]: New.
+
2020-10-16 Nathan Sidwell <nathan@acm.org>
Merge trunk ccb4f20cbee
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index f1230690c50..de9fd984235 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -15689,7 +15689,7 @@ module_state::read_prepare_maps (const module_state_config *cfg)
ordinary += cfg->ordinary_locs;
location_t macro = LINEMAPS_MACRO_LOWEST_LOCATION (line_table);
- macro += cfg->macro_locs;
+ macro -= cfg->macro_locs;
if (ordinary < LINE_MAP_MAX_LOCATION_WITH_COLS
&& macro >= LINE_MAP_MAX_LOCATION)
@@ -15943,7 +15943,7 @@ module_state::write_macro_maps (elf_out *to, location_map_info &info,
sec.u (offset);
gcc_assert (macro_num == info.num_maps.second);
- cfg->macro_locs = offset;
+ cfg->macro_locs = MAX_LOCATION_T + 1 - offset;
sec.end (to, to->name (MOD_SNAME_PFX ".mlm"), crc_p);
dump.outdent ();
diff --git a/gcc/testsuite/g++.dg/modules/macloc-2_a.H b/gcc/testsuite/g++.dg/modules/macloc-2_a.H
new file mode 100644
index 00000000000..99f08840280
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/macloc-2_a.H
@@ -0,0 +1,9 @@
+// { dg-additional-options {-fmodule-header -nostdinc} }
+// { dg-module-cmi {} }
+
+#define MACRO(X) X
+
+inline int frob (int x)
+{
+ return x + 2;
+}
diff --git a/gcc/testsuite/g++.dg/modules/macloc-2_b.C b/gcc/testsuite/g++.dg/modules/macloc-2_b.C
new file mode 100644
index 00000000000..601a4779c28
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/macloc-2_b.C
@@ -0,0 +1,14 @@
+// { dg-additional-options {-fmodules-ts -nostdinc} }
+module;
+
+import "macloc-2_a.H";
+
+export module Foo;
+// { dg-module-cmi Foo }
+
+export inline int MACRO (fn) (int i)
+{
+ return frob (i);
+}
+
+export int (MACRO) (int i);
More information about the Gcc-cvs
mailing list