aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2018-01-30 14:17:40 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2018-01-30 13:17:40 +0000
commit44c945e62c87d9e01156c9cd6da93f69b984be37 (patch)
tree2454d2d5f9eefccf53c515d30f9b23f948f986f0 /gcc
parent6439c358063d3660e08a7931d720b901282879f8 (diff)
downloadgcc-44c945e62c87d9e01156c9cd6da93f69b984be37.zip
gcc-44c945e62c87d9e01156c9cd6da93f69b984be37.tar.gz
gcc-44c945e62c87d9e01156c9cd6da93f69b984be37.tar.bz2
re PR lto/83954 (LTO: Bogus -Wlto-type-mismatch warning for array of pointer to incomplete type)
PR lto/83954 * lto-symtab.c (warn_type_compatibility_p): Silence false positive for type match warning on arrays of pointers. * gcc.dg/lto/pr83954.h: New testcase. * gcc.dg/lto/pr83954_0.c: New testcase. * gcc.dg/lto/pr83954_1.c: New testcase. From-SVN: r257183
Diffstat (limited to 'gcc')
-rw-r--r--gcc/lto/ChangeLog6
-rw-r--r--gcc/lto/lto-symtab.c19
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr83954.h3
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr83954_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr83954_1.c7
6 files changed, 46 insertions, 4 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 67679bc..7265b76 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-30 Jan Hubicka <hubicka@ucw.cz>
+
+ PR lto/83954
+ * lto-symtab.c (warn_type_compatibility_p): Silence false positive
+ for type match warning on arrays of pointers.
+
2018-01-23 Martin Liska <mliska@suse.cz>
PR lto/81440
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 0f0b958..0508c5e 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -284,11 +284,22 @@ warn_type_compatibility_p (tree prevailing_type, tree type,
alias_set_type set1 = get_alias_set (type);
alias_set_type set2 = get_alias_set (prevailing_type);
- if (set1 && set2 && set1 != set2
- && (!POINTER_TYPE_P (type) || !POINTER_TYPE_P (prevailing_type)
+ if (set1 && set2 && set1 != set2)
+ {
+ tree t1 = type, t2 = prevailing_type;
+
+ /* Alias sets of arrays are the same as alias sets of the inner
+ types. */
+ while (TREE_CODE (t1) == ARRAY_TYPE && TREE_CODE (t2) == ARRAY_TYPE)
+ {
+ t1 = TREE_TYPE (t1);
+ t2 = TREE_TYPE (t2);
+ }
+ if ((!POINTER_TYPE_P (t1) || !POINTER_TYPE_P (t2))
|| (set1 != TYPE_ALIAS_SET (ptr_type_node)
- && set2 != TYPE_ALIAS_SET (ptr_type_node))))
- lev |= 5;
+ && set2 != TYPE_ALIAS_SET (ptr_type_node)))
+ lev |= 5;
+ }
}
return lev;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bfc849e..10cc5e8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-30 Jan Hubicka <hubicka@ucw.cz>
+
+ PR lto/83954
+ * gcc.dg/lto/pr83954.h: New testcase.
+ * gcc.dg/lto/pr83954_0.c: New testcase.
+ * gcc.dg/lto/pr83954_1.c: New testcase.
+
2018-01-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR bootstrap/84017
diff --git a/gcc/testsuite/gcc.dg/lto/pr83954.h b/gcc/testsuite/gcc.dg/lto/pr83954.h
new file mode 100644
index 0000000..e015540
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr83954.h
@@ -0,0 +1,3 @@
+struct foo;
+extern struct foo *FOO_PTR_ARR[1];
+
diff --git a/gcc/testsuite/gcc.dg/lto/pr83954_0.c b/gcc/testsuite/gcc.dg/lto/pr83954_0.c
new file mode 100644
index 0000000..5fb7f76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr83954_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do link } */
+#include "pr83954.h"
+
+int main() {
+ // just to prevent symbol removal
+ FOO_PTR_ARR[1] = 0;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr83954_1.c b/gcc/testsuite/gcc.dg/lto/pr83954_1.c
new file mode 100644
index 0000000..61b40fc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr83954_1.c
@@ -0,0 +1,7 @@
+#include "pr83954.h"
+
+struct foo {
+ int x;
+};
+struct foo *FOO_PTR_ARR[1] = { 0 };
+