Add support to the testsuite for effective target "large_location_t"
indicating if 64-bit location support has been configured. Adjust the tests
that are sensitive to location_t internals so they can test large locations
too.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_no_compiler_messages_nocache):
Refactor the code for retrieving compiler messages to...
(get_compiler_messages_nocache) ...here. New function.
(get_compiler_messages): New function.
(check_effective_target_large_location_t): New function.
* g++.dg/diagnostic/pr77949.C: Adapt the test for 64-bit location_t,
when the expected failure doesn't actually happen.
* g++.dg/modules/loc-prune-4.C: Adjust the expected output for the
64-bit location_t case
* gcc.dg/plugin/expensive_selftests_plugin.c: Don't try to test
the maximum supported column number in 64-bit location_t mode.
* gcc.dg/plugin/location_overflow_plugin.c: Adjust the base_location
so it can effectively test 64-bit location_t as well.
---
gcc/testsuite/g++.dg/diagnostic/pr77949.C | 5 ++-
gcc/testsuite/g++.dg/modules/loc-prune-4.C | 11 ++++--
.../plugin/expensive_selftests_plugin.c | 7 ++--
.../gcc.dg/plugin/location_overflow_plugin.c | 7 ++++
gcc/testsuite/lib/target-supports.exp | 34 +++++++++++++++++--
5 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr77949.C
b/gcc/testsuite/g++.dg/diagnostic/pr77949.C
index b81d6e2bb46..35922e9bb23 100644
--- a/gcc/testsuite/g++.dg/diagnostic/pr77949.C
+++ b/gcc/testsuite/g++.dg/diagnostic/pr77949.C
@@ -1,7 +1,10 @@
-// Ensure that no fix-it hints are emitted
+// Ensure that no fix-it hints are emitted unless large locations are
available.
// { dg-options "-fdiagnostics-parseable-fixits" }
/* Very long line, where a missing semicolon would be suggested for
insertion at column 4097. */
class test {
}
// { dg-error "-: expected .;. after class definition" "" { target *-*-* } .-1
}
+/* { dg-begin-multiline-output "" }
+fix-it:
+{ dg-end-multiline-output "" { target large_location_t } } */
diff --git a/gcc/testsuite/g++.dg/modules/loc-prune-4.C
b/gcc/testsuite/g++.dg/modules/loc-prune-4.C
index aa8f248b52b..a6c62a3385c 100644
--- a/gcc/testsuite/g++.dg/modules/loc-prune-4.C
+++ b/gcc/testsuite/g++.dg/modules/loc-prune-4.C
@@ -16,7 +16,12 @@ int bar (int); // merge lines
int baz (int);
-// { dg-final { scan-lang-dump {Ordinary maps:2 locs:12288 range_bits:5}
module } }
// { dg-final { scan-lang-dump { 1 source file names\n Source
file...=[^\n]*loc-prune-4.C\n} module } }
-// { dg-final { scan-lang-dump { Span:0 ordinary
\[[0-9]+\+12288,\+4096\)->\[0,\+4096\)} module } }
-// { dg-final { scan-lang-dump { Span:1 ordinary
\[[0-9]+\+40960,\+8192\)->\[4096,\+8192\)} module } }
+
+// { dg-final { scan-lang-dump {Ordinary maps:2 locs:12288 range_bits:5}
module { target { ! large_location_t } } } }
+// { dg-final { scan-lang-dump { Span:0 ordinary
\[[0-9]+\+12288,\+4096\)->\[0,\+4096\)} module { target { ! large_location_t }
} } }
+// { dg-final { scan-lang-dump { Span:1 ordinary
\[[0-9]+\+40960,\+8192\)->\[4096,\+8192\)} module { target { ! large_location_t
} } } }
+
+// { dg-final { scan-lang-dump {Ordinary maps:2 locs:49152 range_bits:7}
module { target large_location_t } } }
+// { dg-final { scan-lang-dump { Span:0 ordinary
\[[0-9]+\+49152,\+16384\)->\[0,\+16384\)} module { target large_location_t } } }
+// { dg-final { scan-lang-dump { Span:1 ordinary
\[[0-9]+\+163840,\+32768\)->\[16384,\+32768\)} module { target large_location_t
} } }
diff --git a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c
b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c
index e96efe0bed5..1b487ad63b6 100644
--- a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c
@@ -63,17 +63,20 @@ test_richloc (rich_location *richloc)
static void
test_fixit_on_very_long_line (const line_table_case &case_)
{
- /* Various interesting column/line-width values, to try to tickle
- out bugs. */
+ /* Various interesting column/line-width values, to try to tickle out bugs.
In
+ 64-bit location mode, we can't test the max because the maximum supported
+ column is unreasonably large. */
const int VERY_LONG_LINE = 8192;
const int columns[] = {0,
1,
80,
+#ifndef ENABLE_LARGE_SOURCE_LOCATIONS
LINE_MAP_MAX_COLUMN_NUMBER - 2,
LINE_MAP_MAX_COLUMN_NUMBER - 1,
LINE_MAP_MAX_COLUMN_NUMBER,
LINE_MAP_MAX_COLUMN_NUMBER + 1,
LINE_MAP_MAX_COLUMN_NUMBER + 2,
+#endif
VERY_LONG_LINE,
VERY_LONG_LINE + 5};
for (unsigned int width_idx = 0; width_idx < ARRAY_SIZE (columns);
diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
index 45a01b5f917..f7d7ca4b57c 100644
--- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
@@ -84,6 +84,13 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!base_location)
error_at (UNKNOWN_LOCATION, "missing plugin argument");
+ /* With 64-bit sources, the thresholds are larger, so shift the base
+ location argument accordingly. */
+#ifdef ENABLE_LARGE_SOURCE_LOCATIONS
+ gcc_assert (sizeof (location_t) == sizeof (uint64_t));
+ base_location = 1 + ((base_location - 1) << 31);
+#endif
+
register_callback (plugin_info->base_name,
PLUGIN_PRAGMAS,
on_pragma_registration,
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index 75703ddca60..f92dda583b1 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -180,13 +180,27 @@ proc clear_effective_target_cache { } {
array unset et_cache
}
-# Like check_compile, but delete the output file and return true if the
-# compiler printed no messages.
-proc check_no_compiler_messages_nocache {args} {
+# Like check_compile, but delete the output file and return just the
+# compiler output as a string.
+proc get_compiler_messages_nocache {args} {
set result [eval check_compile $args]
set lines [lindex $result 0]
set output [lindex $result 1]
remote_file build delete $output
+ return $lines
+}
+
+# And the cached version.
+proc get_compiler_messages {prop args} {
+ return [check_cached_effective_target $prop {
+ eval [list get_compiler_messages_nocache $prop] $args
+ }]
+}
+
+# Like check_compile, but delete the output file and return true if the
+# compiler printed no messages.
+proc check_no_compiler_messages_nocache {args} {
+ set lines [eval get_compiler_messages_nocache $args ]
return [string match "" $lines]
}
@@ -13939,3 +13953,17 @@ proc add_options_for_nvptx_alias_ptx { flags } {
return $flags
}
+
+
+# Return 1 if GCC was configured with large (64-bit) location_t.
+
+proc check_effective_target_large_location_t { } {
+ set lines [get_compiler_messages large_location_t assembly ";"
"-fdump-internal-locations" ]
+ if ![ regexp {\nMAX_LOCATION_T\s*location_t interval: (\d*)} $lines dummy
max_loc ] {
+ verbose "Could not parse output of -fdump-internal-locations. Assuming
small location_t." 2
+ return 0
+ }
+ # No need to rely on 64-bit capable TCL here. The max for 32-bit locations
+ # is 2147483647, which is 10 characters long.
+ return [ expr { [string length $max_loc] > 10 } ]
+}