summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2021-09-18 08:02:41 +0200
committerAkim Demaille <akim.demaille@gmail.com>2021-09-18 08:07:22 +0200
commit3fc3ef658e855565d2fa83f0a05a0369edbede1f (patch)
tree84e0ddb100288b7df26bef44a186ec573d3084f6
parentdd6e78360a351c29a7f4bc93abee3c255b9ac195 (diff)
downloadbison-3fc3ef658e855565d2fa83f0a05a0369edbede1f.tar.gz
c++: use YY_NOEXCEPT where it helps
Suggested by Don Macpherson. <https://github.com/akimd/bison/issues/80> * data/skeletons/c++.m4, data/skeletons/glr2.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh: Use YY_NOEXCEPT where it helps constructors.
-rw-r--r--data/skeletons/c++.m432
-rw-r--r--data/skeletons/glr2.cc6
-rw-r--r--data/skeletons/lalr1.cc14
-rw-r--r--data/skeletons/stack.hh4
4 files changed, 28 insertions, 28 deletions
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index 42f6404e..2ae8423a 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -308,7 +308,7 @@ m4_define([b4_symbol_type_define],
typedef Base super_type;
/// Default constructor.
- basic_symbol ()
+ basic_symbol () YY_NOEXCEPT
: value ()]b4_locations_if([
, location ()])[
{}
@@ -437,16 +437,22 @@ m4_define([b4_symbol_type_define],
/// Type access provider for token (enum) based symbols.
struct by_kind
{
+ /// The symbol kind as needed by the constructor.
+ typedef token_kind_type kind_type;
+
/// Default constructor.
- by_kind ();
+ by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
- by_kind (by_kind&& that);
+ by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
- by_kind (const by_kind& that);
+ by_kind (const by_kind& that) YY_NOEXCEPT;
+
+ /// Constructor from (external) token numbers.
+ by_kind (kind_type t) YY_NOEXCEPT;
]b4_glr2_cc_if([[
/// Copy assignment.
@@ -456,12 +462,6 @@ m4_define([b4_symbol_type_define],
by_kind& operator= (by_kind&& that);
]])[
- /// The symbol kind as needed by the constructor.
- typedef token_kind_type kind_type;
-
- /// Constructor from (external) token numbers.
- by_kind (kind_type t);
-
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@@ -490,7 +490,7 @@ m4_define([b4_symbol_type_define],
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
- symbol_type () {}
+ symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([_b4_symbol_constructor_define])dnl
@@ -564,23 +564,23 @@ m4_define([b4_public_types_define],
}
// by_kind.
- ]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
+ ]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
: kind_ (]b4_symbol(empty, kind)[)
{}
#if 201103L <= YY_CPLUSPLUS
- ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that)
+ ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
}
#endif
- ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that)
+ ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
- ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t)
+ ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
@@ -643,7 +643,7 @@ m4_define([b4_token_constructor_define], [])
# sometimes in the cc file.
m4_define([b4_yytranslate_define],
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
- ]b4_parser_class[::yytranslate_ (int t)
+ ]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
{
]b4_api_token_raw_if(
[[ return static_cast<symbol_kind_type> (t);]],
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 8b06c37a..757d68d4 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -348,7 +348,7 @@ m4_define([b4_shared_declarations],
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_kind_type enum.
- static symbol_kind_type yytranslate_ (int t);
+ static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
]b4_parse_error_bmatch(
[simple],
@@ -3136,13 +3136,13 @@ b4_dollar_popdef])[]dnl
}
static bool
- yy_is_shift_action (int yyaction)
+ yy_is_shift_action (int yyaction) YY_NOEXCEPT
{
return 0 < yyaction;
}
static bool
- yy_is_error_action (int yyaction)
+ yy_is_error_action (int yyaction) YY_NOEXCEPT
{
return yyaction == 0;
}
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 11fcf923..7cb69d3d 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -325,11 +325,11 @@ m4_define([b4_shared_declarations],
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
- static bool yy_pact_value_is_default_ (int yyvalue);
+ static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
- static bool yy_table_value_is_error_ (int yyvalue);
+ static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
@@ -337,7 +337,7 @@ m4_define([b4_shared_declarations],
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_kind_type enum.
- static symbol_kind_type yytranslate_ (int t);
+ static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
]b4_parse_error_bmatch(
[simple],
@@ -474,7 +474,7 @@ m4_define([b4_shared_declarations],
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
- void yypop_ (int n = 1);
+ void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@@ -779,7 +779,7 @@ m4_if(b4_prefix, [yy], [],
}
void
- ]b4_parser_class[::yypop_ (int n)
+ ]b4_parser_class[::yypop_ (int n) YY_NOEXCEPT
{
yystack_.pop (n);
}
@@ -822,13 +822,13 @@ m4_if(b4_prefix, [yy], [],
}
bool
- ]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue)
+ ]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
{
return yyvalue == yypact_ninf_;
}
bool
- ]b4_parser_class[::yy_table_value_is_error_ (int yyvalue)
+ ]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
{
return yyvalue == yytable_ninf_;
}
diff --git a/data/skeletons/stack.hh b/data/skeletons/stack.hh
index bd5756c1..98913258 100644
--- a/data/skeletons/stack.hh
+++ b/data/skeletons/stack.hh
@@ -37,7 +37,7 @@ m4_define([b4_stack_define],
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
- stack (size_type n = 200)
+ stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@@ -116,7 +116,7 @@ m4_define([b4_stack_define],
class slice
{
public:
- slice (const stack& stack, index_type range)
+ slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}