On 1/17/19 2:09 PM, Marek Polacek wrote:
This patch ought to fix the rest of 78244, a missing narrowing warning in
decltype.
As I explained in Bugzilla, there can be three scenarios:
1) decltype is in a template and it has no dependent expressions, which
is the problematical case. finish_compound_literal just returns the
compound literal without checking narrowing if processing_template_decl.
This is the sort of thing that we've been gradually fixing: if the
compound literal isn't dependent at all, we want to do the normal
processing. And then usually return a result based on the original
trees rather than the result of processing. For instance,
finish_call_expr. Something like that ought to work here, too, and be
more generally applicable; this shouldn't be limited to casting to a
scalar type, casting to a known class type can also involve narrowing.
The check in the other patch that changes instantiation_dependent_r
should be more similar to the one in finish_compound_literal. Or
perhaps you could set a flag here in finish_compound_literal to indicate
that it's instantiation-dependent, and just check that in
instantiation_dependent_r.
Jason