mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	test that the compiler support -Werror=statement-after-declaration before using it
This commit is contained in:
		
							parent
							
								
									63f72908a1
								
							
						
					
					
						commit
						cc00e01fad
					
				
					 2 changed files with 65 additions and 4 deletions
				
			
		
							
								
								
									
										45
									
								
								configure
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								configure
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -6264,8 +6264,6 @@ UNIVERSAL_ARCH_FLAGS=
 | 
				
			||||||
# tweak BASECFLAGS based on compiler and platform
 | 
					# tweak BASECFLAGS based on compiler and platform
 | 
				
			||||||
case $GCC in
 | 
					case $GCC in
 | 
				
			||||||
yes)
 | 
					yes)
 | 
				
			||||||
    BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Python doesn't violate C99 aliasing rules, but older versions of
 | 
					    # Python doesn't violate C99 aliasing rules, but older versions of
 | 
				
			||||||
    # GCC produce warnings for legal Python code.  Enable
 | 
					    # GCC produce warnings for legal Python code.  Enable
 | 
				
			||||||
    # -fno-strict-aliasing on versions of GCC that support but produce
 | 
					    # -fno-strict-aliasing on versions of GCC that support but produce
 | 
				
			||||||
| 
						 | 
					@ -6379,6 +6377,49 @@ $as_echo "$ac_cv_disable_unused_result_warning" >&6; }
 | 
				
			||||||
      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
 | 
					      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Werror=declaration-after-statement" >&5
 | 
				
			||||||
 | 
					$as_echo_n "checking for -Werror=declaration-after-statement... " >&6; }
 | 
				
			||||||
 | 
					     ac_save_cc="$CC"
 | 
				
			||||||
 | 
					     CC="$CC -Werror=declaration-after-statement"
 | 
				
			||||||
 | 
					     save_CFLAGS="$CFLAGS"
 | 
				
			||||||
 | 
					     if ${ac_cv_declaration_after_statement_warning+:} false; then :
 | 
				
			||||||
 | 
					  $as_echo_n "(cached) " >&6
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 | 
				
			||||||
 | 
					/* end confdefs.h.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					main ()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					_ACEOF
 | 
				
			||||||
 | 
					if ac_fn_c_try_compile "$LINENO"; then :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					           ac_cv_declaration_after_statement_warning=yes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					           ac_cv_declaration_after_statement_warning=no
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     CFLAGS="$save_CFLAGS"
 | 
				
			||||||
 | 
					     CC="$ac_save_cc"
 | 
				
			||||||
 | 
					    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_declaration_after_statement_warning" >&5
 | 
				
			||||||
 | 
					$as_echo "$ac_cv_declaration_after_statement_warning" >&6; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if test $ac_cv_declaration_after_statement_warning = yes
 | 
				
			||||||
 | 
					    then
 | 
				
			||||||
 | 
					      BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # if using gcc on alpha, use -mieee to get (near) full IEEE 754
 | 
					    # if using gcc on alpha, use -mieee to get (near) full IEEE 754
 | 
				
			||||||
    # support.  Without this, treatment of subnormals doesn't follow
 | 
					    # support.  Without this, treatment of subnormals doesn't follow
 | 
				
			||||||
    # the standard.
 | 
					    # the standard.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										24
									
								
								configure.ac
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								configure.ac
									
										
									
									
									
								
							| 
						 | 
					@ -1127,8 +1127,6 @@ AC_SUBST(UNIVERSAL_ARCH_FLAGS)
 | 
				
			||||||
# tweak BASECFLAGS based on compiler and platform
 | 
					# tweak BASECFLAGS based on compiler and platform
 | 
				
			||||||
case $GCC in
 | 
					case $GCC in
 | 
				
			||||||
yes)
 | 
					yes)
 | 
				
			||||||
    BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Python doesn't violate C99 aliasing rules, but older versions of
 | 
					    # Python doesn't violate C99 aliasing rules, but older versions of
 | 
				
			||||||
    # GCC produce warnings for legal Python code.  Enable
 | 
					    # GCC produce warnings for legal Python code.  Enable
 | 
				
			||||||
    # -fno-strict-aliasing on versions of GCC that support but produce
 | 
					    # -fno-strict-aliasing on versions of GCC that support but produce
 | 
				
			||||||
| 
						 | 
					@ -1186,6 +1184,28 @@ yes)
 | 
				
			||||||
      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
 | 
					      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AC_MSG_CHECKING(for -Werror=declaration-after-statement)
 | 
				
			||||||
 | 
					     ac_save_cc="$CC"
 | 
				
			||||||
 | 
					     CC="$CC -Werror=declaration-after-statement"
 | 
				
			||||||
 | 
					     save_CFLAGS="$CFLAGS"
 | 
				
			||||||
 | 
					     AC_CACHE_VAL(ac_cv_declaration_after_statement_warning,
 | 
				
			||||||
 | 
					       AC_COMPILE_IFELSE(
 | 
				
			||||||
 | 
					         [
 | 
				
			||||||
 | 
						   AC_LANG_PROGRAM([[]], [[]])
 | 
				
			||||||
 | 
						 ],[
 | 
				
			||||||
 | 
					           ac_cv_declaration_after_statement_warning=yes
 | 
				
			||||||
 | 
						 ],[
 | 
				
			||||||
 | 
					           ac_cv_declaration_after_statement_warning=no
 | 
				
			||||||
 | 
						 ]))
 | 
				
			||||||
 | 
					     CFLAGS="$save_CFLAGS"
 | 
				
			||||||
 | 
					     CC="$ac_save_cc"
 | 
				
			||||||
 | 
					    AC_MSG_RESULT($ac_cv_declaration_after_statement_warning)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if test $ac_cv_declaration_after_statement_warning = yes
 | 
				
			||||||
 | 
					    then
 | 
				
			||||||
 | 
					      BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # if using gcc on alpha, use -mieee to get (near) full IEEE 754
 | 
					    # if using gcc on alpha, use -mieee to get (near) full IEEE 754
 | 
				
			||||||
    # support.  Without this, treatment of subnormals doesn't follow
 | 
					    # support.  Without this, treatment of subnormals doesn't follow
 | 
				
			||||||
    # the standard.
 | 
					    # the standard.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue