-# If we have g++, we cannot have the -Wdeclaration-after-statement.
-# Some g++s accept it but then whine about it with every file.
-# This removal is also done "later", in cflags run time.
-case "$cc" in
-*g++*) warn="`echo $warn|sed 's/-Wdeclaration-after-statement/ /'`" ;;
-esac
-
-# If we have -Duse64bitint (or equivalent) in effect and the quadtype
-# has become 'long long', gcc -pedantic becomes unbearable (moreso
-# when combined with -Wall) because long long and LL and %lld|%Ld
-# become warn-worthy. So let's drop the -pedantic in that case.
-case "$quadtype:$sPRId64" in
-"long long"*|*lld*|*Ld*)
- ccflags="`echo $ccflags|sed 's/-pedantic/ /'`"
- warn="`echo $warn|sed 's/-pedantic/ /'`"
+case "$gccversion" in
+'') ;;
+*)
+ if [ "$gccansipedantic" = "" ]; then
+ # If we have -Duse64bitint (or equivalent) in effect and the quadtype
+ # has become 'long long', gcc -pedantic becomes unbearable (moreso
+ # when combined with -Wall) because long long and LL and %lld|%Ld
+ # become warn-worthy. So let's drop the -pedantic in that case.
+ case "$quadtype:$sPRId64" in
+ "long long"*|*lld*|*Ld*)
+ ccflags="`echo $ccflags|sed 's/-pedantic/ /'`"
+ warn="`echo $warn|sed 's/-pedantic/ /'`"
+ ;;
+ esac
+ # Similarly, since 'long long' isn't part of C89, FreeBSD 6.2 headers
+ # don't declare atoll() under -std=c89, but we need it. In general,
+ # insisting on -std=c89 is inconsistent with insisting on using
+ # 'long long'. So drop -std=c89 and -ansi as well if we're using
+ # 'long long' as our main integral type.
+ case "$ivtype" in
+ "long long")
+ ccflags=`echo $ccflags|sed -e 's/-pedantic/ /' -e 's/-std=c89/ /' -e 's/-ansi/ /'`
+ warn=`echo $warn|sed -e 's/-pedantic/ /' -e 's/-ansi/ /'`
+ stdflags=`echo $warn|sed -e 's/-std=c89/ /'`
+ ;;
+ esac
+ fi
+ # Using certain features (like the gcc statement expressions)
+ # requires knowing whether -pedantic has been specified.
+ case "$warn$ccflags" in
+ *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;;
+ esac