This is the mail archive of the gcc-help@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]

-Wimplicit-fallthrough broken?


Hi, with the following small small test I am getting these warnings:

void test1 (unsigned char c)
{
    switch (c)
    {
        case 1: c++; // fallthrough
        case 2: c--; // FALLTHRU
        case 3: c++; // FALLTHROUGH
        case 4: z = c; break;
    }
}

void test2 (unsigned char c)
{
    switch (c)
    {
        case 1: c++;
        /* fallthrough */
        case 2: c--;
        /* FALLTHRU */
        case 3: c++;
        /* FALLTHROUGH */
        case 4: z = c; break;
    }
}



simple.c: In function 'test1':
simple.c:7:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 1: c++; // fallthrough
                 ~^~
simple.c:8:9: note: here
         case 2: c--; // FALLTHRU
         ^~~~
simple.c:8:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 2: c--; // FALLTHRU
                 ~^~
simple.c:9:9: note: here
         case 3: c++; // FALLTHROUGH
         ^~~~
simple.c:9:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 3: c++; // FALLTHROUGH
                 ~^~
simple.c:10:9: note: here
         case 4: z = c; break;
         ^~~~
simple.c: In function 'test2':
simple.c:18:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 1: c++;
                 ~^~
simple.c:20:9: note: here
         case 2: c--;
         ^~~~
simple.c:20:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 2: c--;
                 ~^~
simple.c:22:9: note: here
         case 3: c++;
         ^~~~
simple.c:22:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case 3: c++;
                 ~^~
simple.c:24:9: note: here
         case 4: z = c; break;
         ^~~~


How do I have to formulate these comments? It's under mingw32, may that be a problem?

Johann


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