On 5/27/2021 10:00 AM, Martin Sebor via Gcc-patches wrote:
When attribute nonnull is applied to an argument of an erroneous
type the attribute positional argument validation function ICEs
while printing a warning that mentions the invalid type.

The attached patch changes the validation function to ignore
erroneous types on the assumption that they must have already
been diagnosed.  It also enhances the pretty-printer to detect
erroneous types and print "{erroneous}" instead of causing
an ICE.  There already is code in the pretty printer that tries
to be robust in thew presence of erroneous types without actually
printing them, and this extends the detection to also print them.
(With the first part of this patch I don't have a test case for
it but handling the condition gracefully feels preferable to
waiting for another bug report with invalid code triggering
an ICE).

Martin

gcc-100783.diff

PR c/100783 - ICE on -Wnonnull and erroneous type

gcc/c-family/ChangeLog:

        PR c/100783
        * c-attribs.c (positional_argument): Bail on erroneous types.

gcc/c/ChangeLog:

        PR c/100783
        * c-objc-common.c (print_type): Handle erroneous types.

gcc/testsuite/ChangeLog:

        PR c/100783
        * gcc.dg/nonnull-6.c: New test.
OK
jeff

Reply via email to