- Non-null checking is triggered during prototype substitution from a template instantiation, if expressions in decltype contains nullptr chcking. Skip non-null checking in that case as the protype is not finalized yet. Also, the nullptr checking in decltype is only used for type inspection instead of codegen. Ignoring that is harmless.
just explain what's the issue is and hope that help reviewers to get this fix quick.
- In Sema::DiagnoseAlwaysNonNullPointer, we issue warnings if a nonnull parameter is used in null checking. It need the function declaration to check parameter attributes. That usually works but fails if that function decl is not ready yet.
- In template instantiation, we first create the function prototype followed by instantiating the function body. When the function prototype is being formed, we may create binary or other expressions for semantic checking. But, in that phase, i.e. Sema::SubstFunctionDeclType, we don't have a fully specialized function prototype yet to check the parameter number and run into the assertion @ line 11596.
Hope that help to get the picture of this fix. Thanks.
|1 ↗||(On Diff #192514)|
test/SemaCXX/nonnull.cpp tests attribute((nonnull)). Placing this test there would be... odd.
The test could use a more descriptive name, though. Just decltype is way too generic. early-func-template-decltype? Or PR-somthing-something, if there's a bug for this crasher.