aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-06-14 17:37:43 -0400
committerJason Merrill <jason@redhat.com>2021-06-16 11:41:08 -0400
commit9e64426dae129cca5b62355ef6c5a3bd6137e830 (patch)
tree743aef1e7b4ba903473889568e8f79aedd136b35 /gcc
parentdd835ec24be9b1a89c6b0c78673de88c81a23966 (diff)
downloadgcc-9e64426dae129cca5b62355ef6c5a3bd6137e830.zip
gcc-9e64426dae129cca5b62355ef6c5a3bd6137e830.tar.gz
gcc-9e64426dae129cca5b62355ef6c5a3bd6137e830.tar.bz2
libcpp: location comparison within macro [PR100796]
The patch for 96391 changed linemap_compare_locations to give up on comparing locations from macro expansions if we don't have column information. But in this testcase, the BOILERPLATE macro is multiple lines long, so we do want to compare locations within the macro. So this patch moves the LINE_MAP_MAX_LOCATION_WITH_COLS check inside the block, to use it for failing gracefully. PR c++/100796 PR preprocessor/96391 libcpp/ChangeLog: * line-map.c (linemap_compare_locations): Only use comparison with LINE_MAP_MAX_LOCATION_WITH_COLS to avoid abort. gcc/testsuite/ChangeLog: * g++.dg/plugin/location-overflow-test-pr100796.c: New test. * g++.dg/plugin/plugin.exp: Run it.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/plugin/location-overflow-test-pr100796.c25
-rw-r--r--gcc/testsuite/g++.dg/plugin/plugin.exp3
2 files changed, 27 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/plugin/location-overflow-test-pr100796.c b/gcc/testsuite/g++.dg/plugin/location-overflow-test-pr100796.c
new file mode 100644
index 0000000..7fa964c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/plugin/location-overflow-test-pr100796.c
@@ -0,0 +1,25 @@
+// PR c++/100796
+// { dg-additional-options "-Wsuggest-override -fplugin-arg-location_overflow_plugin-value=0x60000001" }
+// Passing LINE_MAP_MAX_LOCATION_WITH_COLS meant we stopped distinguishing between lines in a macro.
+
+#define DO_PRAGMA(text) _Pragma(#text)
+#define WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
+#define WARNING_POP DO_PRAGMA(GCC diagnostic pop)
+#define WARNING_DISABLE(text) DO_PRAGMA(GCC diagnostic ignored text)
+#define NO_OVERRIDE_WARNING WARNING_DISABLE("-Wsuggest-override")
+
+#define BOILERPLATE \
+ WARNING_PUSH \
+ NO_OVERRIDE_WARNING \
+ void f(); \
+ WARNING_POP
+
+struct B
+{
+ virtual void f();
+};
+
+struct D: B
+{
+ BOILERPLATE
+};
diff --git a/gcc/testsuite/g++.dg/plugin/plugin.exp b/gcc/testsuite/g++.dg/plugin/plugin.exp
index 5cd4b4b..74e12df 100644
--- a/gcc/testsuite/g++.dg/plugin/plugin.exp
+++ b/gcc/testsuite/g++.dg/plugin/plugin.exp
@@ -73,7 +73,8 @@ set plugin_test_list [list \
../../gcc.dg/plugin/diagnostic-test-string-literals-3.c \
../../gcc.dg/plugin/diagnostic-test-string-literals-4.c } \
{ ../../gcc.dg/plugin/location_overflow_plugin.c \
- location-overflow-test-pr96391.c } \
+ location-overflow-test-pr96391.c \
+ location-overflow-test-pr100796.c } \
{ show_template_tree_color_plugin.c \
show-template-tree-color.C \
show-template-tree-color-labels.C \