bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple LLVM 10 and `__fallthrough__`


From: Werner LEMBERG
Subject: Apple LLVM 10 and `__fallthrough__`
Date: Wed, 22 Feb 2023 18:53:45 +0000 (UTC)

This snippet

```
#include<stdio.h>

int main(int argc, char* argv[])
{
    switch(argc)
    {
    case 3:
        puts(argv[2]);
        __attribute__((fallthrough));
    case 2:
        puts(argv[1]);
        __attribute__((__fallthrough__));
    case 1:
        puts(argv[0]);
        /* fall through */
    default:
        puts("done");
    }
}
```

if compiled with

```
$ llvm-gcc --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
```

yields

```
nicola@Quark:freetype $ clang main.c
main.c:9:9: warning: declaration does not declare anything 
[-Wmissing-declarations]
        __attribute__((fallthrough));
        ^
main.c:12:9: warning: declaration does not declare anything 
[-Wmissing-declarations]
        __attribute__((__fallthrough__));
        ^
2 warnings generated.
```

In `lib/dfa.c` I see

```
...
# elif (__GNUC__ >= 7) || (__clang_major__ >= 10)
#  define FALLTHROUGH __attribute__ ((__fallthrough__))
...
```

I now wonder whether it would be better to have a special case for
Apple LLVM to avoid this warning.


    Werner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]