From: Akim Demaille Date: Tue, 14 Apr 2009 04:52:31 +0000 (+0200) Subject: variables: use `parse.assert' instead of `assert'. X-Git-Tag: v2.7.90~900 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/0c90a1f5e91bdaf862b82abe92a649a6b473aa6d?ds=sidebyside variables: use `parse.assert' instead of `assert'. * TODO (assert): Remove. * data/bison.m4 (b4_assert_if): Replace with... (b4_parse_assert_if): this. * data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust. * doc/bison.texinfo (Decl Summary): Document parse.assert. --- diff --git a/ChangeLog b/ChangeLog index 0513c688..eadc6527 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-04-14 Akim Demaille + + variables: use `parse.assert' instead of `assert'. + * TODO (assert): Remove. + * data/bison.m4 (b4_assert_if): Replace with... + (b4_parse_assert_if): this. + * data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust. + * doc/bison.texinfo (Decl Summary): Document parse.assert. + 2009-04-14 Akim Demaille variables: use `parse.assert' instead of `debug'. diff --git a/TODO b/TODO index d00092a9..4bcb3a65 100644 --- a/TODO +++ b/TODO @@ -293,8 +293,6 @@ Are there any Texinfo standards for bibliography? ** %printer Wow, %printer is not documented. Clearly mark YYPRINT as obsolete. -** %define assert - * Java, Fortran, etc. diff --git a/data/bison.m4 b/data/bison.m4 index 52144e9a..2b4e5046 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -677,17 +677,17 @@ m4_define([b4_percent_define_if_define], b4_percent_define_if_define_([$1], $[1], $[2])]) -# b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) +# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) # b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) # b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT]) # b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT]) # b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) # ---------------------------------------------- -b4_percent_define_if_define([assert]) -b4_percent_define_if_define([parse.trace]) b4_percent_define_if_define([error_verbose]) b4_percent_define_if_define([lex_symbol]) b4_percent_define_if_define([locations]) # Whether locations are tracked. +b4_percent_define_if_define([parse.assert]) +b4_percent_define_if_define([parse.trace]) b4_percent_define_if_define([variant]) diff --git a/data/lalr1.cc b/data/lalr1.cc index 1791c76f..39167f94 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -146,7 +146,7 @@ dnl FIXME: This is wrong, we want computed header guards. ]b4_percent_code_get([[requires]])[ -]b4_assert_if([#include ])[ +]b4_parse_assert_if([#include ])[ #include #include #include "stack.hh" diff --git a/data/variant.hh b/data/variant.hh index 0c29f7f4..14884ecb 100644 --- a/data/variant.hh +++ b/data/variant.hh @@ -87,13 +87,13 @@ m4_define([b4_variant_define], /// via the current state. template struct variant - {]b4_assert_if([ + {]b4_parse_assert_if([ /// Whether something is contained. bool built; ])[ /// Empty construction. inline - variant ()]b4_assert_if([ + variant ()]b4_parse_assert_if([ : built (false)])[ {} @@ -101,7 +101,7 @@ m4_define([b4_variant_define], template inline T& build () - {]b4_assert_if([ + {]b4_parse_assert_if([ assert (!built); built = true;])[ return *new (buffer.raw) T; @@ -111,7 +111,7 @@ m4_define([b4_variant_define], template inline T& build (const T& t) - {]b4_assert_if([ + {]b4_parse_assert_if([ assert(!built); built = true;])[ return *new (buffer.raw) T(t); @@ -120,7 +120,7 @@ m4_define([b4_variant_define], /// Construct and fill. template inline - variant (const T& t)]b4_assert_if([ + variant (const T& t)]b4_parse_assert_if([ : built (true)])[ { new (buffer.raw) T(t); @@ -130,7 +130,7 @@ m4_define([b4_variant_define], template inline T& as () - {]b4_assert_if([ + {]b4_parse_assert_if([ assert (built);])[ return reinterpret_cast(buffer.raw); } @@ -139,7 +139,7 @@ m4_define([b4_variant_define], template inline const T& as () const - {]b4_assert_if([ + {]b4_parse_assert_if([ assert(built);])[ return reinterpret_cast(buffer.raw); } @@ -168,7 +168,7 @@ m4_define([b4_variant_define], inline void destroy () { - as().~T();]b4_assert_if([ + as().~T();]b4_parse_assert_if([ built = false;])[ } diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 6df5617b..fbe9ac9d 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -5003,6 +5003,22 @@ The parser namespace is @code{foo} and @code{yylex} is referenced as @end itemize @c namespace +@item parse.assert +@findex %define parse.assert + +@itemize +@item Languages(s): C++ + +@item Purpose: Issue runtime assertions to catch invalid uses. +In C++, when variants are used, symbols must be constructed and +destroyed properly. This option checks these constraints. + +@item Accepted Values: Boolean + +@item Default Value: @code{false} +@end itemize +@c parse.assert + @item parse.trace @findex %define parse.trace diff --git a/tests/c++.at b/tests/c++.at index e2f9d03f..55a6b3a7 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -1,5 +1,5 @@ # Checking the output filenames. -*- Autotest -*- -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -196,10 +196,10 @@ AT_CLEANUP ]) AT_CHECK_VARIANTS([]) -AT_CHECK_VARIANTS([%define assert]) -AT_CHECK_VARIANTS([[%define assert %code {\n#define ONE_STAGE_BUILD\n}]]) -AT_CHECK_VARIANTS([[%define assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]]) -AT_CHECK_VARIANTS([[%define assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define token.prefix "TOK_"]]) +AT_CHECK_VARIANTS([%define parse.assert]) +AT_CHECK_VARIANTS([[%define parse.assert %code {\n#define ONE_STAGE_BUILD\n}]]) +AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]]) +AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define token.prefix "TOK_"]]) ## ----------------------- ##