summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-12-16 17:50:58 (GMT)
committerYang Tse <yangsita@gmail.com>2012-12-16 17:50:58 (GMT)
commit84eb2dc22061df3e04cad921336123e88423715b (patch)
treeb4d04642af500729fbca64448699847683c254f9
parent9da14a847fc58a4fb8286155544bf9bbc79c6568 (diff)
downloadc-ares-84eb2dc22061df3e04cad921336123e88423715b.zip
c-ares-84eb2dc22061df3e04cad921336123e88423715b.tar.gz
c-ares-84eb2dc22061df3e04cad921336123e88423715b.tar.bz2
configure: check if compiler halts on function prototype mismatch
-rw-r--r--configure.ac1
-rw-r--r--m4/cares-compilers.m438
2 files changed, 38 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index f220b43..be7346c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,7 @@ fi
CARES_CHECK_COMPILER_HALT_ON_ERROR
CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
+CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
CARES_CHECK_COMPILER_SYMBOL_HIDING
CARES_CHECK_NO_UNDEFINED
diff --git a/m4/cares-compilers.m4 b/m4/cares-compilers.m4
index 8120aab..a716fed 100644
--- a/m4/cares-compilers.m4
+++ b/m4/cares-compilers.m4
@@ -15,7 +15,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 72
+# serial 73
dnl CARES_CHECK_COMPILER
@@ -1527,6 +1527,42 @@ AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [
])
+dnl CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
+dnl -------------------------------------------------
+dnl Verifies if the compiler actually halts after the
+dnl compilation phase without generating any object
+dnl code file, when the source code tries to redefine
+dnl a prototype which does not match previous one.
+
+AC_DEFUN([CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH], [
+ AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl
+ AC_MSG_CHECKING([if compiler halts on function prototype mismatch])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+# include <stdlib.h>
+ int rand(int n);
+ int rand(int n)
+ {
+ if(n)
+ return ++n;
+ else
+ return n;
+ }
+ ]],[[
+ int i[2];
+ int j = rand(i[0]);
+ if(j)
+ return j;
+ ]])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([compiler does not halt on function prototype mismatch.])
+ ],[
+ AC_MSG_RESULT([yes])
+ ])
+])
+
+
dnl CARES_VAR_MATCH (VARNAME, VALUE)
dnl -------------------------------------------------
dnl Verifies if shell variable VARNAME contains VALUE.