[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 06:18:34 PST 2025


Sirraide wrote:

> What I'm asking is: is `-Wreturn-type` more susceptible to FPs than other typical Clang warnings

There definitely are cases where we currently can’t figure out that a function always returns if the control flow is very convoluted, e.g. #111509 has this horrible example
```c
int foo(int x) {
    bool matched = false;
    do {
      if (matched) {
        label: return 0;
      }

      if (matched || x == 1) {
        matched = true;
        return 123;
      }
      if (matched || x == 2) {
        matched = true;
        return 456;
      }

      if (matched) {
        break;
      }
      goto label;
    } while(false);
}
```

https://github.com/llvm/llvm-project/pull/123470


More information about the llvm-commits mailing list