This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/81582] -Wimplicit-fallthrough= wrong warning with -save-temps


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81582

--- Comment #9 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
With -fdirectives-only locations go bananas:

#include <stdio.h>

int f1 (int x)
{
    switch (x)
    {
    case 1: x++; // FALLTHRU
    case 2: x--; /* FALLTHRU */
    case 3: x++; // line #9
    case 4: return x;
    default:
        break;
    }
    return 0;
} // line #15

$ gcc foo.c -W -save-temps -S -fdirectives-only
foo.c: In function 'f1':
foo.c:16:14: warning: this statement may fall through [-Wimplicit-fallthrough=]

              ^ 
foo.c:18:5: note: here

     ^   

The case 1/2 warnings are silenced, but the (correct) warning for case 3 is
thrown at lines 16 and 18 for a file with only 15 source lines.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]