This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlguts: sprintf %p now works
[perl5.git] / cflags.SH
index bd32840..f1bcd6c 100755 (executable)
--- a/cflags.SH
+++ b/cflags.SH
@@ -73,18 +73,10 @@ cat >_cflags.c <<__EOT__
 #include <setjmp.h>
 /* Just in case the inclusion of perl.h did not
  * pull in enough system headers, let's try again. */
-#ifdef I_STDLIB
 #include <stdlib.h>
-#endif
-#ifdef I_STDDEF
 #include <stddef.h>
-#endif
-#ifdef I_STDARG
 #include <stdarg.h>
-#endif
-#ifdef I_LIMITS
 #include <limits.h>
-#endif
 #ifdef I_DIRENT
 #include <dirent.h>
 #endif
@@ -164,7 +156,7 @@ esac
 
 case "$gccversion" in
 '') ;;
-[12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
+[12].*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
 Intel*) ;; # # Is that you, Intel C++?
 #
 # NOTE 1: the -std=c89 without -pedantic is a bit pointless.
@@ -188,6 +180,7 @@ Intel*) ;; # # Is that you, Intel C++?
 #
 *)  for opt in -std=c89 -ansi $pedantic \
                -Werror=declaration-after-statement \
+               -Werror=pointer-arith \
                -Wextra -W \
                -Wc++-compat -Wwrite-strings
     do
@@ -247,6 +240,16 @@ Intel*) ;; # # Is that you, Intel C++?
                      ;;
                   esac
                   ;;
+               -Werror=pointer-arith)
+                  # -pedantic* covers -Werror=p-a
+                  case "$warn" in
+                  *-pedantic*) ;;
+                  *)
+                     echo "cflags.SH: Adding $opt."
+                     warn="$warn $opt"
+                     ;;
+                  esac
+                  ;;
                *)
                   echo "cflags.SH: Adding $opt."
                   warn="$warn $opt"
@@ -367,7 +370,8 @@ case "$cc" in
   ;;
 esac
 
-for f in -Wdeclaration-after-statement -Werror=declaration-after-statement
+for f in -Wdeclaration-after-statement -Werror=declaration-after-statement \
+         -Wpointer-arith -Werror=pointer-arith
 do
   case "$cppflags" in
   *"$f"*)
@@ -485,10 +489,10 @@ for file do
 
     # allow variables like toke_cflags to be evaluated
 
-    if echo $file | grep -v / >/dev/null
-    then
-      eval 'eval ${'"${file}_cflags"'-""}'
-    fi
+    case "$file" in
+    */*) ;;
+    *) eval 'eval ${'"${file}_cflags"'-""}' ;;
+    esac
 
     # or customize here
 
@@ -515,7 +519,6 @@ for file do
     toke) optimize=-O0 ;;
     esac
 
-    # Can we perhaps use $ansi2knr here
     echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
 
     . $TOP/config.sh