]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Check compiler for c99 declarations after code.
authorDarren Tucker <dtucker@dtucker.net>
Wed, 18 Aug 2021 02:51:30 +0000 (12:51 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Wed, 18 Aug 2021 02:51:30 +0000 (12:51 +1000)
The sntrup761 reference code contains c99-style declarations after code
so don't try to build that if the compiler doesn't support it.

configure.ac
defines.h

index e728e323610204e3b715800fca96a2cdec56af12..01e7d2a4fbecb7ec584015d9b3e952b091dd5259 100644 (file)
@@ -307,6 +307,16 @@ AC_COMPILE_IFELSE(
     [ AC_MSG_RESULT([no]) ]
 )
 
+AC_MSG_CHECKING([if compiler accepts variable declarations after code])
+AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([[#include <stdlib.h>]],
+    [[ int a; a = 1; int b = 1; exit(a-b); ]])],
+    [ AC_MSG_RESULT([yes])
+      AC_DEFINE(VARIABLE_DECLARATION_AFTER_CODE, [1],
+        [compiler variable declarations after code]) ],
+    [ AC_MSG_RESULT([no]) ]
+)
+
 if test "x$no_attrib_nonnull" != "x1" ; then
        AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
 fi
index 7fff562c0e45b2117337a7bc1c30fa29c5cb27f2..857abb8b1d6fd6dd92938066625a74f650e5a588 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -901,10 +901,10 @@ struct winsize {
 #endif
 
 /*
- * sntrup761 uses variable length arrays, only enable if the compiler
- * supports them.
+ * sntrup761 uses variable length arrays and c99-style declarations after code,
+ * so only enable if the compiler supports them.
  */
-#ifdef VARIABLE_LENGTH_ARRAYS
+#if defined(VARIABLE_LENGTH_ARRAYS) && defined(VARIABLE_DECLARATION_AFTER_CODE)
 # define USE_SNTRUP761X25519 1
 #endif
 #endif /* _DEFINES_H */