summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-08-28 16:42:28 -0400
committerZack Weinberg <zackw@panix.com>2020-08-28 16:42:28 -0400
commit87a81f44c6a9e9dbb4b3b94680084edfea603a89 (patch)
tree3d020ffa58421cbf73b42643130f3d92ee034716
parenta2a6641c52994641bd10fb5efe2ecc51c07d798e (diff)
downloadautoconf-87a81f44c6a9e9dbb4b3b94680084edfea603a89.tar.gz
Fix testsuite failures from ‘make maintainer-check-c++’.
‘make maintainer-check-c++’ has two test failures that don’t show in an ordinary ‘make check’. One of these is a pair of problems with the semantics.at test of AC_CHECK_DECL(S): * AC_CHECK_DECL cannot handle a function argument whose declared type is ‘char []’; it generates a cast to the array type, which is invalid in both C and C++. This was masked by an M4 quotation bug, causing it to emit a cast to ‘char’ instead, prodicing code that was valid C but invalid C++. I don’t think it’s practical to teach AC_CHECK_DECL to do argument type decay, so I changed the type signature in the AC_CHECK_DECL call (not in the actual declaration) to ‘char *’. Conveniently this also avoids the quotation issue. * In C++, apparently ‘extern struct { int x; } foo;’ is invalid. (clang++ explains at length: “variable ‘foo’ is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage.”) Fixed by giving the struct a tag. The other failure is an actual bug in AC_PROG_LEX: the test program used by _AC_PROG_LEX_YYTEXT_DECL uses the flex utility function ‘input’, which is renamed to ‘yyinput’ when the scanner is compiled as C++. Fixed with ifdefs in the offending action--it might seem cleaner to use a macro defined in a %{ %} block, but that would be inserted into the skeleton *above* the declaration of (yy)input, so I didn’t feel it was safe. * tests/semantics.at (AC_CHECK_DECLS): Adjust test programs for C++ compatibility and to work around lack of support for argument type decay. * programs.m4 (_AC_PROG_LEX_YYTEXT_DECL): Call yyinput(), not input(), in scanner action when scanner is compiled as C++.
-rw-r--r--lib/autoconf/programs.m47
-rw-r--r--tests/semantics.at4
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index 0ad3ddd1..86ba3948 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -727,7 +727,12 @@ b { REJECT; }
c { yymore (); }
d { yyless (1); }
e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
- yyless ((input () != 0)); }
+#ifdef __cplusplus
+ yyless ((yyinput () != 0));
+#else
+ yyless ((input () != 0));
+#endif
+ }
f { unput (yytext[0]); }
. { BEGIN INITIAL; }
%%
diff --git a/tests/semantics.at b/tests/semantics.at
index 98933aa1..32811f6d 100644
--- a/tests/semantics.at
+++ b/tests/semantics.at
@@ -111,7 +111,7 @@ AT_CHECK_MACRO([AC_CHECK_DECLS],
[[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
[[extern int yes;
enum { myenum };
- extern struct { int x[20]; } mystruct;
+ extern struct mystruct_s { int x[20]; } mystruct;
extern int myfunc();
#define mymacro1(arg) arg
#define mymacro2]])
@@ -119,7 +119,7 @@ AT_CHECK_MACRO([AC_CHECK_DECLS],
AC_CHECK_DECLS([strerror],,, [[]])
# The difference in space-before-open-paren is intentional.
AC_CHECK_DECLS([basenam (char *), dirnam(char *),
- [moreargs (char, short, int, long, void *, char [], float, double)]],,,
+ moreargs (char, short, int, long, void *, char *, float, double)],,,
[[#ifdef __cplusplus
extern "C++" char *basenam (char *);
extern "C++" const char *basenam (const char *);