[cfe-dev] Is -Wno-return-type a warning or error?
Dan Liew via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 29 04:55:38 PDT 2015
Hi,
I was playing with Clang 3.7 on some old code I noticed that
``-Wreturn-type`` seems to be treated as error.
For example
```
int foo() {
int x = 5;
return;
}
int main() {
int x = foo();
return 0;
}
```
Now try building
```
$ clang -std=c99 noret.c
noret.c:3:5: error: non-void function 'foo' should return a value
[-Wreturn-type]
return;
^
1 error generated.
```
It's good that Clang flags up bad code like this but what is confusing
me is the Clang driver is
* Treating this as an error even though I haven't passed ``-Werror``.
* I can suppress this with ``-Wno-return-type``.
So I'm not really sure if this is a "warning" or an "error". I expect
* If it's an "error" then I shouldn't be able to suppress it with the
``-Wno-return-type`` flag.
* If it's a "warning" and I haven't passed ``-Werror`` then Clang
should note the warning but not treat it as an error.
Is Clang's current (and reasonable) behaviour intentional or this a bug?
Thanks,
Dan.
More information about the cfe-dev
mailing list