From ca1ed8602fedf7dc86d1eaf8d4b4e4beb5220a03 Mon Sep 17 00:00:00 2001 From: Kp Date: Mon, 11 Feb 2019 01:53:44 +0000 Subject: [PATCH] Add test for gcc bug #82541 --- SConstruct | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/SConstruct b/SConstruct index 5a5a2f7aa..722e47032 100644 --- a/SConstruct +++ b/SConstruct @@ -2634,6 +2634,34 @@ where the cast is useless. #if defined(__APPLE__) && defined(__MACH__) #include #endif + +/* gcc's warning -Wduplicated-branches was initially overzealous and + * warned if the branches were identical after expanding template + * parameters. This was documented in gcc bug #82541, which was fixed + * for gcc-8.x. As of this writing, the fix has not been backported to + * gcc-7.x. + * + * Work around this unwanted quirk by including code which will provoke + * a -Wduplicated-branches warning in affected versions, but not in + * fixed versions, so that the configure stage blacklists the warning on + * affected versions. + */ + +namespace gcc_pr82541 { + +template +unsigned u(bool b) +{ + return b ? U1 : U2; +} + +unsigned u2(bool b); +unsigned u2(bool b) +{ + return u<1, 1>(b); +} + +} ''', _mangle_compiler_option_name=__mangle_compiler_option_name, _mangle_linker_option_name=__mangle_linker_option_name