Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/gcc-frr-format: fix ICE in gcc-10 #7443

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tools/gcc-plugins/frr-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,16 @@ tree type_normalize (tree type, tree *cousin, tree target = NULL)
return type;
}

/* gcc-10 asserts when you give a TYPE_DECL instead of the actual TYPE */
static tree
decl_deref(tree typ)
{
while (TREE_CODE (typ) == TYPE_DECL)
typ = DECL_ORIGINAL_TYPE (typ);

return typ;
}

static void
check_format_types (const substring_loc &fmt_loc,
format_wanted_type *types, const format_kind_info *fki,
Expand All @@ -2750,6 +2760,8 @@ check_format_types (const substring_loc &fmt_loc,
wanted_type = types->wanted_type;
arg_num = types->arg_num;

wanted_type = decl_deref(wanted_type);

/* The following should not occur here. */
gcc_assert (wanted_type);
gcc_assert (wanted_type != void_type_node || types->pointer_count);
Expand Down Expand Up @@ -2873,7 +2885,7 @@ check_format_types (const substring_loc &fmt_loc,
|| cur_type == signed_char_type_node
|| cur_type == unsigned_char_type_node);

int compat = lang_hooks.types_compatible_p (wanted_type, cur_type);
int compat = lang_hooks.types_compatible_p (decl_deref (wanted_type), decl_deref (cur_type));
/* Check the type of the "real" argument, if there's a type we want. */
if ((TREE_CODE (wanted_type) != INTEGER_TYPE || types->pointer_count)
&& compat)
Expand Down Expand Up @@ -3180,6 +3192,9 @@ matching_type_p (tree spec_type, tree arg_type)
gcc_assert (spec_type);
gcc_assert (arg_type);

spec_type = decl_deref (spec_type);
arg_type = decl_deref (arg_type);

/* If any of the types requires structural equality, we can't compare
their canonical types. */
if (TYPE_STRUCTURAL_EQUALITY_P (spec_type)
Expand Down