Rewritten unreachable __builtin_unreachable() behavior.

According to https://bugs.llvm.org/show_bug.cgi?id=13910,
old clang versions also suffer from this issue along with lcc.
And also this warning option is removed from gcc since 4.5.0,
and it's likely there is no unreachable code analysis at all:
https://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Warning-Options.html
This commit is contained in:
makise-homura 2019-02-01 20:37:32 +03:00
parent 6fceca8536
commit 369f6856f9
3 changed files with 11 additions and 18 deletions

View file

@ -57,10 +57,20 @@ taisei_c_args = cc.get_supported_arguments(
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wunneeded-internal-declaration',
'-Wunreachable-code',
'-Wunreachable-code-loop-increment',
)
if cc.compiles('''
int main() {
return 0;
__builtin_unreachable();
}
''', name : 'unreachable __builtin_unreachable() with -Werror', args : [ '-Wunreachable-code', '-Werror' ] )
taisei_c_args += cc.get_supported_arguments('-Wunreachable-code')
else
warning('-Wunreachable-code will not be used due to incorrect handling of __builtin_unreachable')
endif
static = get_option('static')
dep_freetype = dependency('freetype2', required : true, static : static)

View file

@ -71,11 +71,7 @@
#else
#define PRAGMA(p) _Pragma(#p)
#define USE_GNU_EXTENSIONS
#ifdef TAISEI_BUILDCONF_USE_BUILTIN_UNREACHABLE
#define UNREACHABLE __builtin_unreachable()
#else
#define UNREACHABLE
#endif
#endif
#ifndef __has_attribute

View file

@ -23,23 +23,10 @@ if is_developer_build
util_src += files('debug.c')
endif
use_builtin_unreachable = cc.compiles('''
int main() {
return 0;
__builtin_unreachable();
}
''', name : '__builtin_unreachable() with -Werror', args : [ '-Wunreachable-code', '-Werror' ] )
use_designated_init = cc.compiles('''
struct { ; } __attribute__((designated_init)) x;
''', name : '__attribute__((designated_init)) with -Werror', args : [ '-Wattributes', '-Werror' ] )
if use_builtin_unreachable
config.set('TAISEI_BUILDCONF_USE_BUILTIN_UNREACHABLE', true)
else
config.set('TAISEI_BUILDCONF_USE_BUILTIN_UNREACHABLE', false)
endif
if use_designated_init
config.set('TAISEI_BUILDCONF_USE_DESIGNATED_INIT', true)
else