Commit f91f9bab authored by Kenneth Graunke's avatar Kenneth Graunke
Browse files

meson: Add -Werror=return-type when supported.

This warning detects non-void functions with a missing return statement,
return statements with a value in void functions, and functions with an
bogus return type that ends up defaulting to int.  It's already enabled
by default with -Wall.  Generally, these are fairly serious bugs in the
code, which developers would like to notice and fix immediately.  This
patch promotes it from a warning to an error, to help developers catch
such mistakes early.

I would not expect this warning to change much based on the compiler
version, so hopefully it won't become a problem for packagers/builders.

See the GCC documentation or 'man gcc' for more details:

Reviewed-by: default avatarEric Engestrom <>
parent 0d380af8
......@@ -788,7 +788,8 @@ endif
# Check for generic C arguments
c_args = []
foreach a : ['-Wall', '-Werror=implicit-function-declaration',
'-Werror=missing-prototypes', '-fno-math-errno',
'-Werror=missing-prototypes', '-Werror=return-type',
'-fno-trapping-math', '-Qunused-arguments']
if cc.has_argument(a)
c_args += a
......@@ -808,7 +809,8 @@ endif
# Check for generic C++ arguments
cpp_args = []
foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
foreach a : ['-Wall', '-Werror=return-type',
'-fno-math-errno', '-fno-trapping-math',
if cpp.has_argument(a)
cpp_args += a
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment