浏览代码

SCons: Cleanup GCC warnings configuration

- Outright disable spammy warnings due to past or present GCC bugs:
  * `-Wno-strict-overflow` for GCC 7.
  * `-Wno-type-limits` for GCC before 11 (regressed in 9/10, might work in
    earlier releases but at this stage we don't care).
  * `-Wno-return-type` for GCC 12/13 (regression, still not fixed).
- Enable extra warnings conditionally when broken on earlier GCC:
  * `-Wnoexcept` was removed due to an upstream regression in GCC 9, could
    be re-enabled (but commented out for now as we actually have `-Wnoexcept`
    warnings to fix.
  * `-Wlogical-op` was broken on our variadic templates before GCC 11, now
    seems fine.
Rémi Verschelde 2 年之前
父节点
当前提交
4e4e16f9a9
共有 3 个文件被更改,包括 16 次插入56 次删除
  1. 14 6
      SConstruct
  2. 0 48
      core/object/method_bind.h
  3. 2 2
      drivers/unix/net_socket_posix.cpp

+ 14 - 6
SConstruct

@@ -687,6 +687,14 @@ if selected_platform in platform_list:
 
 
         if methods.using_gcc(env):
         if methods.using_gcc(env):
             common_warnings += ["-Wshadow-local", "-Wno-misleading-indentation"]
             common_warnings += ["-Wshadow-local", "-Wno-misleading-indentation"]
+            if cc_version_major == 7:  # Bogus warning fixed in 8+.
+                common_warnings += ["-Wno-strict-overflow"]
+            if cc_version_major < 11:
+                # Regression in GCC 9/10, spams so much in our variadic templates
+                # that we need to outright disable it.
+                common_warnings += ["-Wno-type-limits"]
+            if cc_version_major >= 12:  # False positives in our error macros, see GH-58747.
+                common_warnings += ["-Wno-return-type"]
         elif methods.using_clang(env) or methods.using_emcc(env):
         elif methods.using_clang(env) or methods.using_emcc(env):
             # We often implement `operator<` for structs of pointers as a requirement
             # We often implement `operator<` for structs of pointers as a requirement
             # for putting them in `Set` or `Map`. We don't mind about unreliable ordering.
             # for putting them in `Set` or `Map`. We don't mind about unreliable ordering.
@@ -702,13 +710,16 @@ if selected_platform in platform_list:
                         "-Wduplicated-branches",
                         "-Wduplicated-branches",
                         "-Wduplicated-cond",
                         "-Wduplicated-cond",
                         "-Wstringop-overflow=4",
                         "-Wstringop-overflow=4",
-                        "-Wlogical-op",
                     ]
                     ]
                 )
                 )
-                # -Wnoexcept was removed temporarily due to GH-36325.
                 env.Append(CXXFLAGS=["-Wplacement-new=1"])
                 env.Append(CXXFLAGS=["-Wplacement-new=1"])
+                # Need to fix a warning with AudioServer lambdas before enabling.
+                # if cc_version_major != 9:  # GCC 9 had a regression (GH-36325).
+                #    env.Append(CXXFLAGS=["-Wnoexcept"])
                 if cc_version_major >= 9:
                 if cc_version_major >= 9:
                     env.Append(CCFLAGS=["-Wattribute-alias=2"])
                     env.Append(CCFLAGS=["-Wattribute-alias=2"])
+                if cc_version_major >= 11:  # Broke on MethodBind templates before GCC 11.
+                    env.Append(CCFLAGS=["-Wlogical-op"])
             elif methods.using_clang(env) or methods.using_emcc(env):
             elif methods.using_clang(env) or methods.using_emcc(env):
                 env.Append(CCFLAGS=["-Wimplicit-fallthrough"])
                 env.Append(CCFLAGS=["-Wimplicit-fallthrough"])
         elif env["warnings"] == "all":
         elif env["warnings"] == "all":
@@ -720,13 +731,10 @@ if selected_platform in platform_list:
 
 
         if env["werror"]:
         if env["werror"]:
             env.Append(CCFLAGS=["-Werror"])
             env.Append(CCFLAGS=["-Werror"])
+
             # FIXME: Temporary workaround after the Vulkan merge, remove once warnings are fixed.
             # FIXME: Temporary workaround after the Vulkan merge, remove once warnings are fixed.
             if methods.using_gcc(env):
             if methods.using_gcc(env):
                 env.Append(CXXFLAGS=["-Wno-error=cpp"])
                 env.Append(CXXFLAGS=["-Wno-error=cpp"])
-                if cc_version_major == 7:  # Bogus warning fixed in 8+.
-                    env.Append(CCFLAGS=["-Wno-error=strict-overflow"])
-                if cc_version_major >= 12:  # False positives in our error macros, see GH-58747.
-                    env.Append(CCFLAGS=["-Wno-error=return-type"])
             elif methods.using_clang(env) or methods.using_emcc(env):
             elif methods.using_clang(env) or methods.using_emcc(env):
                 env.Append(CXXFLAGS=["-Wno-error=#warnings"])
                 env.Append(CXXFLAGS=["-Wno-error=#warnings"])
 
 

+ 0 - 48
core/object/method_bind.h

@@ -292,11 +292,6 @@ class MethodBindT : public MethodBind {
 	void (MB_T::*method)(P...);
 	void (MB_T::*method)(P...);
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -304,9 +299,6 @@ protected:
 			return Variant::NIL;
 			return Variant::NIL;
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 		PropertyInfo pi;
 		PropertyInfo pi;
@@ -367,11 +359,6 @@ class MethodBindTC : public MethodBind {
 	void (MB_T::*method)(P...) const;
 	void (MB_T::*method)(P...) const;
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -379,9 +366,6 @@ protected:
 			return Variant::NIL;
 			return Variant::NIL;
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 		PropertyInfo pi;
 		PropertyInfo pi;
@@ -444,11 +428,6 @@ class MethodBindTR : public MethodBind {
 	(P...);
 	(P...);
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -466,9 +445,6 @@ protected:
 			return GetTypeInfo<R>::get_class_info();
 			return GetTypeInfo<R>::get_class_info();
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 public:
 public:
 #ifdef DEBUG_METHODS_ENABLED
 #ifdef DEBUG_METHODS_ENABLED
@@ -531,11 +507,6 @@ class MethodBindTRC : public MethodBind {
 	(P...) const;
 	(P...) const;
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -553,9 +524,6 @@ protected:
 			return GetTypeInfo<R>::get_class_info();
 			return GetTypeInfo<R>::get_class_info();
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 public:
 public:
 #ifdef DEBUG_METHODS_ENABLED
 #ifdef DEBUG_METHODS_ENABLED
@@ -615,11 +583,6 @@ class MethodBindTS : public MethodBind {
 	void (*function)(P...);
 	void (*function)(P...);
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -627,9 +590,6 @@ protected:
 			return Variant::NIL;
 			return Variant::NIL;
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 		PropertyInfo pi;
 		PropertyInfo pi;
@@ -678,11 +638,6 @@ class MethodBindTRS : public MethodBind {
 	(P...);
 	(P...);
 
 
 protected:
 protected:
-// GCC raises warnings in the case P = {} as the comparison is always false...
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 	virtual Variant::Type _gen_argument_type(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 			return call_get_argument_type<P...>(p_arg);
 			return call_get_argument_type<P...>(p_arg);
@@ -690,9 +645,6 @@ protected:
 			return GetTypeInfo<R>::VARIANT_TYPE;
 			return GetTypeInfo<R>::VARIANT_TYPE;
 		}
 		}
 	}
 	}
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
 
 
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 	virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
 		if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {

+ 2 - 2
drivers/unix/net_socket_posix.cpp

@@ -179,8 +179,8 @@ NetSocketPosix::~NetSocketPosix() {
 	close();
 	close();
 }
 }
 
 
-// Silent a warning reported in #27594
-
+// Silence a warning reported in GH-27594.
+// EAGAIN and EWOULDBLOCK have the same value on most platforms, but it's not guaranteed.
 #if defined(__GNUC__) && !defined(__clang__)
 #if defined(__GNUC__) && !defined(__clang__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wlogical-op"
 #pragma GCC diagnostic ignored "-Wlogical-op"