aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-05-10 23:58:53 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2015-05-10 21:58:53 +0000
commitad5bc3248e147212a972d5d4a7fe4d202abebf27 (patch)
treeda7dcb0b5504106093eec4cca9a7a1df5e8ec8c5 /gcc
parent15296d46dec964f4f2fea572c183462dbd96e576 (diff)
downloadgcc-ad5bc3248e147212a972d5d4a7fe4d202abebf27.zip
gcc-ad5bc3248e147212a972d5d4a7fe4d202abebf27.tar.gz
gcc-ad5bc3248e147212a972d5d4a7fe4d202abebf27.tar.bz2
ipa-devirt.c (warn_types_mismatch): Do not ICE when warning about mismatch between C and C++ type...
* ipa-devirt.c (warn_types_mismatch): Do not ICE when warning about mismatch between C and C++ type; compoare correctly ARG_TYPES for non-prototypes and output correctly parameter index for METHOD_TYPE. (odr_types_equivalent_p): Fix wording of warning about attributes; it is OK to match prototype and non-prototype. From-SVN: r222985
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ipa-devirt.c47
2 files changed, 36 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2a43fe95..73f6be6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2015-05-09 Jan Hubicka <hubicka@ucw.cz>
+ * ipa-devirt.c (warn_types_mismatch): Do not ICE when warning about
+ mismatch between C and C++ type; compoare correctly ARG_TYPES
+ for non-prototypes and output correctly parameter index for METHOD_TYPE.
+ (odr_types_equivalent_p): Fix wording of warning about attributes;
+ it is OK to match prototype and non-prototype.
+
+2015-05-09 Jan Hubicka <hubicka@ucw.cz>
+
* tree.c (free_lang_data_in_type): Free TREE_PURPOSE of
TYPE_ARG_TYPES list.
(verify_type): Permit non-NULL TREE_PURPOSE in non-LTO builds.
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index e878bc1..f19503b 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1028,7 +1028,9 @@ warn_types_mismatch (tree t1, tree t2)
t1 = t2;
t2 = tmp;
}
- if (TYPE_NAME (t1) && TYPE_NAME (t2))
+ if (TYPE_NAME (t1) && TYPE_NAME (t2)
+ && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL
+ && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL)
{
inform (DECL_SOURCE_LOCATION (TYPE_NAME (t1)),
"type %qT defined in anonymous namespace can not match "
@@ -1079,7 +1081,7 @@ warn_types_mismatch (tree t1, tree t2)
else if (TREE_CODE (t1) == METHOD_TYPE
|| TREE_CODE (t1) == FUNCTION_TYPE)
{
- tree parms1, parms2;
+ tree parms1 = NULL, parms2 = NULL;
int count = 1;
if (!odr_subtypes_equivalent_p (TREE_TYPE (t1), TREE_TYPE (t2),
@@ -1089,21 +1091,27 @@ warn_types_mismatch (tree t1, tree t2)
warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2));
return;
}
- for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
- parms1 && parms2;
- parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2),
- count++)
- {
- if (!odr_subtypes_equivalent_p
- (TREE_VALUE (parms1), TREE_VALUE (parms2), &visited))
- {
- inform (UNKNOWN_LOCATION,
- "type mismatch in parameter %i", count);
- warn_types_mismatch (TREE_VALUE (parms1),
- TREE_VALUE (parms2));
- return;
- }
- }
+ if (prototype_p (t1) && prototype_p (t2))
+ for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
+ parms1 && parms2;
+ parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2),
+ count++)
+ {
+ if (!odr_subtypes_equivalent_p
+ (TREE_VALUE (parms1), TREE_VALUE (parms2), &visited))
+ {
+ if (count == 1 && TREE_CODE (t1) == METHOD_TYPE)
+ inform (UNKNOWN_LOCATION,
+ "implicit this pointer type mismatch");
+ else
+ inform (UNKNOWN_LOCATION,
+ "type mismatch in parameter %i",
+ count - (TREE_CODE (t1) == METHOD_TYPE));
+ warn_types_mismatch (TREE_VALUE (parms1),
+ TREE_VALUE (parms2));
+ return;
+ }
+ }
if (parms1 || parms2)
{
inform (UNKNOWN_LOCATION,
@@ -1180,7 +1188,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
if (comp_type_attributes (t1, t2) != 1)
{
warn_odr (t1, t2, NULL, NULL, warn, warned,
- G_("a type with attributes "
+ G_("a type with different attributes "
"is defined in another translation unit"));
return false;
}
@@ -1348,7 +1356,8 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
return false;
}
- if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2))
+ if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2)
+ || !prototype_p (t1) || !prototype_p (t2))
return true;
else
{