On Mon, Jan 29, 2018 at 6:29 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> In r245223 cp_parser_postfix_dot_deref_expression has been changed to
> workaround some buggy template code with a pedwarn instead of error,
> in r245440 Marek tweaked that by adding the && EXPR_P (postfix_expression)
> because we really don't want to clear TREE_TYPE on OVERLOADs or on DECLs
> that have incomplete type.
> There are some expression types where we don't want to clear TREE_TYPE
> either, like *CAST_EXPR, or VIEW_CONVERT_EXPR, these in various spots
> assume they have non-NULL TREE_TYPE.
> So, the following patch extends it by looking at the various
> postfix_expression kinds and deciding what to do by tweaking kind.
> Changing kind from DK_PEDWARN where it pedwarns + clears TREE_TYPE and scope
> to DK_ERROR will result in an error + what we used to do before r245223,
> i.e. scope = error_mark_node and postfix_expression = error_mark_node too.
> Changing kind to DK_IGNORED will do what Marek's patch did, not diagnose
> anything at that point, let other code diagnose incomplete type later on
> or diagnose some other error. For OVERLOAD that seems like a better
> choice, not really sure about other cases. For now the patch uses DK_ERROR
> and thus what we used to do before r245223 for non-OVERLOAD. At least
> when not processing_template_decl I'd say it is better to error right away.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> Or should I change the switch body to do other kind = overrides?
I think we want to avoid clobbering NON_LVALUE_EXPR location wrappers, too.
This has gotten large enough that it should break out into its own function.
OK with those changes.