This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
don't use -Werror=declaration-after-statement with C++
authorTony Cook <tony@develop-help.com>
Tue, 17 Dec 2019 00:32:40 +0000 (11:32 +1100)
committerKarl Williamson <khw@cpan.org>
Tue, 17 Dec 2019 21:44:20 +0000 (14:44 -0700)
declaration after statement is normal for C++ and C++ compilers
rightly complain if we try to warn (or error) on them, so don't
try to.

fixes #17353

cflags.SH

index f1bcd6c..90bf705 100755 (executable)
--- a/cflags.SH
+++ b/cflags.SH
@@ -178,11 +178,17 @@ Intel*) ;; # # Is that you, Intel C++?
 # -std=c89 before -ansi
 # -pedantic* before -Werror=d-a-s
 #
-*)  for opt in -std=c89 -ansi $pedantic \
-               -Werror=declaration-after-statement \
-               -Werror=pointer-arith \
-               -Wextra -W \
-               -Wc++-compat -Wwrite-strings
+*) warns=-std=c89 -ansi $pedantic \
+       -Werror=pointer-arith \
+       -Wextra -W \
+       -Wc++-compat -Wwrite-strings
+   # declaration after statement is normal in C++ rather than an
+   # extension and compilers complain if we try to warn about it
+   case "$d_cplusplus" in
+   define) ;;
+   *) warns="$warns -Werror=declaration-after-statement" ;;
+   esac
+   for opt in $warns
     do
        case " $ccflags " in
        *" $opt "*) ;; # Skip if already there.