Commit ad5bc324 by Jan Hubicka Committed by Jan Hubicka

ipa-devirt.c (warn_types_mismatch): Do not ICE when warning about mismatch…

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
parent 15296d46
2015-05-09 Jan Hubicka <hubicka@ucw.cz> 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 * tree.c (free_lang_data_in_type): Free TREE_PURPOSE of
TYPE_ARG_TYPES list. TYPE_ARG_TYPES list.
(verify_type): Permit non-NULL TREE_PURPOSE in non-LTO builds. (verify_type): Permit non-NULL TREE_PURPOSE in non-LTO builds.
......
...@@ -1028,7 +1028,9 @@ warn_types_mismatch (tree t1, tree t2) ...@@ -1028,7 +1028,9 @@ warn_types_mismatch (tree t1, tree t2)
t1 = t2; t1 = t2;
t2 = tmp; 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)), inform (DECL_SOURCE_LOCATION (TYPE_NAME (t1)),
"type %qT defined in anonymous namespace can not match " "type %qT defined in anonymous namespace can not match "
...@@ -1079,7 +1081,7 @@ warn_types_mismatch (tree t1, tree t2) ...@@ -1079,7 +1081,7 @@ warn_types_mismatch (tree t1, tree t2)
else if (TREE_CODE (t1) == METHOD_TYPE else if (TREE_CODE (t1) == METHOD_TYPE
|| TREE_CODE (t1) == FUNCTION_TYPE) || TREE_CODE (t1) == FUNCTION_TYPE)
{ {
tree parms1, parms2; tree parms1 = NULL, parms2 = NULL;
int count = 1; int count = 1;
if (!odr_subtypes_equivalent_p (TREE_TYPE (t1), TREE_TYPE (t2), if (!odr_subtypes_equivalent_p (TREE_TYPE (t1), TREE_TYPE (t2),
...@@ -1089,21 +1091,27 @@ warn_types_mismatch (tree t1, tree t2) ...@@ -1089,21 +1091,27 @@ warn_types_mismatch (tree t1, tree t2)
warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2)); warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2));
return; return;
} }
for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2); if (prototype_p (t1) && prototype_p (t2))
parms1 && parms2; for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2), parms1 && parms2;
count++) parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2),
{ count++)
if (!odr_subtypes_equivalent_p {
(TREE_VALUE (parms1), TREE_VALUE (parms2), &visited)) if (!odr_subtypes_equivalent_p
{ (TREE_VALUE (parms1), TREE_VALUE (parms2), &visited))
inform (UNKNOWN_LOCATION, {
"type mismatch in parameter %i", count); if (count == 1 && TREE_CODE (t1) == METHOD_TYPE)
warn_types_mismatch (TREE_VALUE (parms1), inform (UNKNOWN_LOCATION,
TREE_VALUE (parms2)); "implicit this pointer type mismatch");
return; 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) if (parms1 || parms2)
{ {
inform (UNKNOWN_LOCATION, inform (UNKNOWN_LOCATION,
...@@ -1180,7 +1188,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned, ...@@ -1180,7 +1188,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
if (comp_type_attributes (t1, t2) != 1) if (comp_type_attributes (t1, t2) != 1)
{ {
warn_odr (t1, t2, NULL, NULL, warn, warned, 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")); "is defined in another translation unit"));
return false; return false;
} }
...@@ -1348,7 +1356,8 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned, ...@@ -1348,7 +1356,8 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
return false; 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; return true;
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment