# Mostly test that we are robust to mistakes.
+## ----------------- ##
+## Invalid options. ##
+## ----------------- ##
+
+AT_SETUP([Invalid options])
+
+AT_DATA([input.y],
+[[%%
+exp: '0'
+]])
+
+# We used to accept these, as -f, --report and others were sharing
+# their code with -W.
+AT_BISON_CHECK([-ferror=caret input.y], [1], [], [ignore])
+AT_BISON_CHECK([--report=error=itemsets input.y], [1], [], [ignore])
+
+AT_CLEANUP
+
+
## ---------------- ##
## Invalid inputs. ##
## ---------------- ##
%%
exp: foo { $$; } foo { $2; } foo
| foo
- | /* Empty. */
+ | /* empty. */
;
]])
| foo
^^^
input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother]
- | /* Empty. */
+ | /* empty. */
^
]])
input.y:2.10-24: previous declaration
input.y:5.10-24: error: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
-input.y:11.13-29: error: %destructor redeclaration for <field1>
-input.y:4.13-29: previous declaration
input.y:11.13-29: error: %destructor redeclaration for <field2>
input.y:1.13-29: previous declaration
-input.y:12.10-24: error: %printer redeclaration for <field1>
-input.y:2.10-24: previous declaration
+input.y:11.13-29: error: %destructor redeclaration for <field1>
+input.y:4.13-29: previous declaration
input.y:12.10-24: error: %printer redeclaration for <field2>
input.y:5.10-24: previous declaration
+input.y:12.10-24: error: %printer redeclaration for <field1>
+input.y:2.10-24: previous declaration
]])
AT_CLEANUP
#include "input.h"
int yyparse (void);
-
-int
-main (void)
-{
- return yyparse ();
-}
+]AT_MAIN_DEFINE[
]])
AT_BISON_OPTION_POPDEFS
AT_DATA_GRAMMAR([input.y],
[[%require "$1";
%%
-empty_file:;
+empty_file: /* empty */;
]])
AT_BISON_CHECK([-o input.c input.y], $2, [], ignore)
AT_CLEANUP
# POSIX Yacc accept periods, but not dashes.
AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
-input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
+input.y:20.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
]])
# So warn about them.
AT_BISON_CHECK([-Wyacc input.y], [], [],
[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
-input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
+input.y:20.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
]])
# Dashes are fine for GNU Bison.
]])
])
-AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
-AT_CHECK_API_PURE([[%language "c++" %defines]], [[false]])
-AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
-AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[false]])
+AT_CHECK_API_PURE([[%language "c++"]], [[]])
+AT_CHECK_API_PURE([[%language "c++"]], [[false]])
+AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[""]])
+AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[false]])
AT_CHECK_API_PURE([[%language "java"]], [[true]])
AT_CHECK_API_PURE([[%language "java"]], [[false]])
AT_CHECK_NAMESPACE_ERROR([[]],
[[namespace reference is empty]])
-AT_CHECK_NAMESPACE_ERROR([[ ]],
+AT_CHECK_NAMESPACE_ERROR([[ @tb@@tb@ @tb@ @tb@]],
[[namespace reference is empty]])
AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
[[namespace reference has consecutive "::"]])
-AT_CHECK_NAMESPACE_ERROR([[foo:: ::bar]],
+AT_CHECK_NAMESPACE_ERROR([[foo:: @tb@::bar]],
[[namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[::::bar]],
[[namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
[[namespace reference has consecutive "::"]])
-AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ::]],
+AT_CHECK_NAMESPACE_ERROR([[foo::bar::@tb@::]],
[[namespace reference has consecutive "::"]],
[[namespace reference has a trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
[[namespace reference has a trailing "::"]])
-AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ]],
+AT_CHECK_NAMESPACE_ERROR([[foo::bar:: @tb@]],
[[namespace reference has a trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[::]],
[[namespace reference has a trailing "::"]])
[AT_DATA([[input.y]],
[[$1
%%
-exp:;
+exp: /* empty */;
]])
AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
[[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together