diff --git a/config/ChangeLog b/config/ChangeLog
index 6f20dd8b328fbc427c909c8ecc2dff4546643d9c..6bd7bbf54164ee06db0c537433ad0d433f44e845 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-17  Joseph Myers  <joseph@codesourcery.com>
+
+	PR other/40784
+	* tls.m4 (GCC_CHECK_TLS): Add extra quoting around argument to
+	AC_LINK_IFELSE.
+
 2009-07-16  Joseph Myers  <joseph@codesourcery.com>
 
 	* tls.m4 (GCC_CHECK_TLS): Also test TLS in a shared library when
diff --git a/config/tls.m4 b/config/tls.m4
index e0870682d51408a3e85d59a461373009c8bf8ac7..099bdc257a8e6db1ea7c26671692ee51b669a76b 100644
--- a/config/tls.m4
+++ b/config/tls.m4
@@ -79,9 +79,9 @@ AC_DEFUN([GCC_CHECK_TLS], [
 	  CFLAGS="-fPIC $CFLAGS"
 	  dnl If -shared works, test if TLS works in a shared library.
 	  AC_LINK_IFELSE([int f() { return 0; }],
-	    AC_LINK_IFELSE([__thread int a; int b; int f() { return a = b; }],
+	    [AC_LINK_IFELSE([__thread int a; int b; int f() { return a = b; }],
 	      [gcc_cv_have_tls=yes],
-	      [gcc_cv_have_tls=no]),
+	      [gcc_cv_have_tls=no])],
 	    [gcc_cv_have_tls=yes])
 	  CFLAGS="$chktls_save_CFLAGS"
 	  LDFLAGS="$chktls_save_LDFLAGS"], [gcc_cv_have_tls=no])
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 22feaedf7d5c1797254af42c6bab809031c5c28d..d838e26fabe56006b0f7237efaa0a78b682cebcd 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-17  Joseph Myers  <joseph@codesourcery.com>
+
+	PR other/40784
+	* configure: Regenerate.
+
 2009-07-16  Joseph Myers  <joseph@codesourcery.com>
 
 	* configure: Regenerate.
diff --git a/libjava/configure b/libjava/configure
index 82911d155ac78bba6f193665b026beb1714eeec1..9206e9153ca0e7a95fdafa4b2b9ea7e2ad7bdff7 100755
--- a/libjava/configure
+++ b/libjava/configure
@@ -27702,8 +27702,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   if test x$gcc_no_link = xyes; then
-  { { echo "$as_me:$LINENO: error: Link tests are not allowed after ." >&5
-echo "$as_me: error: Link tests are not allowed after ." >&2;}
+  { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
+echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
    { (exit 1); exit 1; }; }
 fi
 cat >conftest.$ac_ext <<_ACEOF
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f7656a393f622e14d03a0b47aa4232f63b1fa988..4beeae38e62bd0f4962f0901b2f31d87250d1dd4 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-17  Joseph Myers  <joseph@codesourcery.com>
+
+	PR other/40784
+	* configure: Regenerate.
+
 2009-07-16  Benjamin Kosnik  <bkoz@redhat.com>
 
 	* testsuite/util/testsuite_common_types.h (standard_layout): Activate.
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d9e9f8df5f1a2ad976fa09084629c52a3e1eeaa4..13f477ed34b4833f03f20d509278bd910ea116fb 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -40770,8 +40770,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   if test x$gcc_no_link = xyes; then
-  { { echo "$as_me:$LINENO: error: Link tests are not allowed after ." >&5
-echo "$as_me: error: Link tests are not allowed after ." >&2;}
+  { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
+echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
    { (exit 1); exit 1; }; }
 fi
 cat >conftest.$ac_ext <<_ACEOF
@@ -94505,8 +94505,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   if test x$gcc_no_link = xyes; then
-  { { echo "$as_me:$LINENO: error: Link tests are not allowed after ." >&5
-echo "$as_me: error: Link tests are not allowed after ." >&2;}
+  { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
+echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
    { (exit 1); exit 1; }; }
 fi
 cat >conftest.$ac_ext <<_ACEOF
@@ -112207,8 +112207,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   if test x$gcc_no_link = xyes; then
-  { { echo "$as_me:$LINENO: error: Link tests are not allowed after ." >&5
-echo "$as_me: error: Link tests are not allowed after ." >&2;}
+  { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
+echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
    { (exit 1); exit 1; }; }
 fi
 cat >conftest.$ac_ext <<_ACEOF