[Scummvm-git-logs] scummvm master -> 7613a635f61e2ad95944b7055ad82984f1e8c8c4

bluegr noreply at scummvm.org
Fri Apr 25 16:25:54 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
7613a635f6 BUILD: Promote to error any warning about functions lacking a return statement


Commit: 7613a635f61e2ad95944b7055ad82984f1e8c8c4
    https://github.com/scummvm/scummvm/commit/7613a635f61e2ad95944b7055ad82984f1e8c8c4
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-04-25T19:25:51+03:00

Commit Message:
BUILD: Promote to error any warning about functions lacking a return statement

Regarding the `configure` script, we now have:

  * default: add `-Werror=flag-name` for selected warnings where it's
    important to fail early (just `-Werror=return-type` for now)

  * --enable-Werror: use `-Werror` for all warnings

  * --disable-Werror: don't any `-Werror` flag

For Xcode, `-Werror=return-type` is added to default flags.

For MSVC, equivalent flags have been added to the existing
`globalErrors` list.

Suggested by sluicebox.

Changed paths:
    configure
    devtools/create_project/create_project.cpp
    devtools/create_project/xcode.cpp


diff --git a/configure b/configure
index 7cc3adc5482..d2dfa7a072e 100755
--- a/configure
+++ b/configure
@@ -196,7 +196,7 @@ _debug_build=auto
 _release_build=auto
 _optimizations=auto
 _verbose_build=no
-_werror_build=no
+_werror_build=auto
 _text_console=no
 _mt32emu=yes
 _lua=yes
@@ -984,7 +984,8 @@ Optional Features:
   --enable-detection-dynamic build detection features into a library
   --disable-detection-full add detection only for the engines which were enabled
   --disable-debug          disable building with debugging symbols
-  --enable-Werror          treat warnings as errors
+  --enable-Werror          treat all warnings as errors
+  --disable-Werror         disable default promotion of some warnings to errors
   --enable-release         enable building in release mode (this activates
                            optimizations)
   --enable-release-mode    enable building in release mode (without optimizations)
@@ -1543,6 +1544,9 @@ for ac_option in $@; do
 	--enable-Werror)
 		_werror_build=yes
 		;;
+	--disable-Werror)
+		_werror_build=no
+		;;
 	--enable-release-mode)
 		_release_build=yes
 		;;
@@ -7544,7 +7548,7 @@ case $_host_os in
 		;;
 esac
 
-
+# Promote any warning to an error, only if explicitly asked
 if test "$_werror_build" = yes; then
 	# --enable-Werror shouldn't be applied before being done testing all system
 	# features and libraries. Otherwise, some of them could just end up being silently
@@ -7552,6 +7556,14 @@ if test "$_werror_build" = yes; then
 	append_var CXXFLAGS "-Werror"
 fi
 
+# Promote some selected warnings to errors, by default
+#
+# Some warnings can reveal some serious issues that shouldn't remain
+# unnoticed. Flags added here shouldn't trigger false positives, though.
+if test "$_werror_build" != no; then
+	append_var CXXFLAGS "-Werror=return-type"
+fi
+
 #
 # Engine selection
 #
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index 4f8111df45e..f20bd8fbc1b 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -678,6 +678,9 @@ int main(int argc, char *argv[]) {
 		globalErrors.push_back("4305"); // truncation of double to float or int to bool
 		globalErrors.push_back("4366"); // address taken of unaligned field
 		globalErrors.push_back("4315"); // unaligned field has constructor that expects to be aligned
+		globalErrors.push_back("4715"); // not all control paths return a value
+		globalErrors.push_back("4716"); // function must return a value
+
 
 		projectWarnings["agi"].push_back("4510");
 		projectWarnings["agi"].push_back("4610");
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 318d64d4155..e2d876c9d6a 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1342,6 +1342,7 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
 	scummvm_WarningCFlags.push_back("-Wno-undefined-var-template");
 	scummvm_WarningCFlags.push_back("-Wno-pragma-pack");
 	scummvm_WarningCFlags.push_back("-Wc++11-extensions");
+	scummvm_WarningCFlags.push_back("-Werror=return-type");
 	ADD_SETTING_LIST(scummvm_Debug, "WARNING_CFLAGS", scummvm_WarningCFlags, kSettingsQuoteVariable | kSettingsAsList, 5);
 	ValueList scummvm_defines(_defines);
 	REMOVE_DEFINE(scummvm_defines, "MACOSX");




More information about the Scummvm-git-logs mailing list