Skip to content

Commit 7f194fb

Browse files
committed
Merge pull request #171 from stesie/fix-gcc5-build
Improve -Wno-c++11-narrowing/-Wno-narrowing detection
2 parents b29bb88 + 7805abf commit 7f194fb

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

config.m4

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,32 @@ if test "$PHP_V8JS" != "no"; then
4646
CPPFLAGS=$old_CPPFLAGS
4747
]);
4848

49-
AC_CACHE_CHECK(how to disable c++11 narrowing warning, ac_cv_v8_narrowing, [
49+
AC_CACHE_CHECK(how to allow c++11 narrowing, ac_cv_v8_narrowing, [
5050
ac_cv_v8_narrowing=""
5151
old_CXXFLAGS=$CXXFLAGS
5252
AC_LANG_PUSH([C++])
53-
CXXFLAGS="-Wno-c++11-narrowing"
54-
AC_TRY_RUN([int main() { unsigned int a[1] = { -1 }; (void) a; return 0; }],[ac_cv_v8_narrowing="-Wno-c++11-narrowing"],[],[])
53+
CXXFLAGS="-std="$ac_cv_v8_cstd
54+
AC_TRY_RUN([int main() {
55+
struct { unsigned int x; } foo = {-1};
56+
(void) foo;
57+
return 0;
58+
}], [ ac_cv_v8_narrowing="" ], [
59+
CXXFLAGS="-Wno-c++11-narrowing -std="$ac_cv_v8_cstd
60+
AC_TRY_RUN([int main() {
61+
struct { unsigned int x; } foo = {-1};
62+
(void) foo;
63+
return 0;
64+
}], [ ac_cv_v8_narrowing="-Wno-c++11-narrowing" ], [
65+
CXXFLAGS="-Wno-narrowing -std="$ac_cv_v8_cstd
66+
AC_TRY_RUN([int main() {
67+
struct { unsigned int x; } foo = {-1};
68+
(void) foo;
69+
return 0;
70+
}], [ ac_cv_v8_narrowing="-Wno-narrowing" ], [
71+
AC_MSG_ERROR([cannot compile with narrowing])
72+
], [])
73+
], [])
74+
], [])
5575
AC_LANG_POP([C++])
5676
CXXFLAGS=$old_CXXFLAGS
5777
]);

0 commit comments

Comments
 (0)