https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102088
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- The patch below changes the latest warning to the following without any dg.exp test failures: z.c: In function ‘f’: z.c:9:3: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 9 | return z; | ^~~~~~~~ z.c:3:7: note: declared here, initialized if ‘i == 0’ 3 | int x, y = j, z; | ^ diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 356cf2504d4..73c303b1b4f 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6168,6 +6168,12 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, mark_exp_read (expr.value); stmt = c_finish_return (EXPR_LOC_OR_LOC (expr.value, xloc), expr.value, expr.original_type); + if (stmt) + { + /* Set the statement location to include the operand. */ + xloc = make_location (loc, loc, xloc); + SET_EXPR_LOCATION (stmt, xloc); + } goto expect_semicolon; } break; Though ideally, the warning would point to the uninitialized read, like so: z.c: In function ‘f’: z.c:9:3: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 5 | z = x; | ^ But that's not in the IL at -O2 when the warning runs.