diff --git a/tests/headers.at b/tests/headers.at index f58160d7..bade94ed 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -105,6 +105,85 @@ AT_PARSER_CHECK([./caller]) AT_BISON_OPTION_POPDEFS AT_CLEANUP + + +## -------------- ## +## Sane headers. ## +## -------------- ## + +# AT_TEST([DIRECTIVES]) +# --------------------- +# Check that headers are self-contained and protected againt multiple +# inclusions. + +m4_pushdef([AT_TEST], +[AT_SETUP([Sane headers: $1]) + +AT_BISON_OPTION_PUSHDEFS([$1]) +AT_DATA_GRAMMAR([input.y], +[[$1 +%error-verbose +]AT_VARIANT_IF([], [%union {int integer;}])[ +%code { +#include + ]AT_YYERROR_DECLARE[ + ]AT_YYLEX_DECLARE[ +} +%% +exp: + 'x' { printf ("x\n"); } +; + +%% +]AT_YYERROR_DEFINE[ +]AT_YYLEX_DEFINE(["x"])[ +]]) + +AT_BISON_CHECK([-d -o input.AT_SKEL_CC_IF([cc], [c]) input.y]) + +AT_LANG_COMPILE([input.o]) + +AT_DATA([main.cc], +[AT_DATA_SOURCE_PROLOGUE +AT_MAIN_DEFINE +]) + +# Check that the headers are self-contained, and protected against +# multiple inclusions. While at it, check they are sane for C++. +for h in *.AT_SKEL_CC_IF([hh], [h]) +do + # No shell expansion with AT_DATA. + cat >$h.AT_SKEL_CC_IF([cc], [c]) <$h.cc <