]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix testsuite failures from ‘make maintainer-check-c++’.
authorZack Weinberg <zackw@panix.com>
Fri, 28 Aug 2020 20:42:28 +0000 (16:42 -0400)
committerZack Weinberg <zackw@panix.com>
Fri, 28 Aug 2020 20:42:28 +0000 (16:42 -0400)
‘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++.

lib/autoconf/programs.m4
tests/semantics.at

index 0ad3ddd1db35d8f78b7ae93f32262672594ba942..86ba39489aac5faa9368e4af1127c08921c0ef69 100644 (file)
@@ -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; }
 %%
index 98933aa1a85403047019bf7bc703f11fe3e94ff6..32811f6d5c0a140cfed13c12f38da09da84e870f 100644 (file)
@@ -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 *);