PR middle-end/44738 * tree-ssa.c (warn_uninit): Avoid emitting an unnecessary message. PR middle-end/44738 * c-c++-common/uninit-17.c: Correct expected error. Index: testsuite/c-c++-common/uninit-17.c =================================================================== --- testsuite/c-c++-common/uninit-17.c (revision 162146) +++ testsuite/c-c++-common/uninit-17.c (working copy) @@ -9,9 +9,9 @@ static void bar(int a, int *ptr) { do { - int b; /* { dg-message "note: 'b' was declared here" } */ + int b; /* { dg-warning "is used uninitialized" } */ if (b < 40) { - ptr[0] = b; /* { dg-warning "may be used uninitialized" } */ + ptr[0] = b; } b += 1; ptr++; Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 162146) +++ tree-ssa.c (working copy) @@ -1631,6 +1631,8 @@ warn_uninit (tree t, const char *gmsgid, { TREE_NO_WARNING (var) = 1; + if (location == DECL_SOURCE_LOCATION (var)) + return; if (xloc.file != floc.file || xloc.line < floc.line || xloc.line > LOCATION_LINE (cfun->function_end_locus))