Skip to content

Commit 3fc3ef6

Browse files
committed
c++: use YY_NOEXCEPT where it helps
Suggested by Don Macpherson. <akimd/bison#80> * data/skeletons/c++.m4, data/skeletons/glr2.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh: Use YY_NOEXCEPT where it helps constructors.
1 parent dd6e783 commit 3fc3ef6

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

data/skeletons/c++.m4

+16-16
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ m4_define([b4_symbol_type_define],
308308
typedef Base super_type;
309309
310310
/// Default constructor.
311-
basic_symbol ()
311+
basic_symbol () YY_NOEXCEPT
312312
: value ()]b4_locations_if([
313313
, location ()])[
314314
{}
@@ -437,16 +437,22 @@ m4_define([b4_symbol_type_define],
437437
/// Type access provider for token (enum) based symbols.
438438
struct by_kind
439439
{
440+
/// The symbol kind as needed by the constructor.
441+
typedef token_kind_type kind_type;
442+
440443
/// Default constructor.
441-
by_kind ();
444+
by_kind () YY_NOEXCEPT;
442445
443446
#if 201103L <= YY_CPLUSPLUS
444447
/// Move constructor.
445-
by_kind (by_kind&& that);
448+
by_kind (by_kind&& that) YY_NOEXCEPT;
446449
#endif
447450
448451
/// Copy constructor.
449-
by_kind (const by_kind& that);
452+
by_kind (const by_kind& that) YY_NOEXCEPT;
453+
454+
/// Constructor from (external) token numbers.
455+
by_kind (kind_type t) YY_NOEXCEPT;
450456
451457
]b4_glr2_cc_if([[
452458
/// Copy assignment.
@@ -456,12 +462,6 @@ m4_define([b4_symbol_type_define],
456462
by_kind& operator= (by_kind&& that);
457463
]])[
458464
459-
/// The symbol kind as needed by the constructor.
460-
typedef token_kind_type kind_type;
461-
462-
/// Constructor from (external) token numbers.
463-
by_kind (kind_type t);
464-
465465
/// Record that this symbol is empty.
466466
void clear () YY_NOEXCEPT;
467467
@@ -490,7 +490,7 @@ m4_define([b4_symbol_type_define],
490490
typedef basic_symbol<by_kind> super_type;
491491
492492
/// Empty symbol.
493-
symbol_type () {}
493+
symbol_type () YY_NOEXCEPT {}
494494
495495
/// Constructor for valueless symbols, and symbols from each type.
496496
]b4_type_foreach([_b4_symbol_constructor_define])dnl
@@ -564,23 +564,23 @@ m4_define([b4_public_types_define],
564564
}
565565
566566
// by_kind.
567-
]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
567+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
568568
: kind_ (]b4_symbol(empty, kind)[)
569569
{}
570570
571571
#if 201103L <= YY_CPLUSPLUS
572-
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that)
572+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
573573
: kind_ (that.kind_)
574574
{
575575
that.clear ();
576576
}
577577
#endif
578578
579-
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that)
579+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
580580
: kind_ (that.kind_)
581581
{}
582582
583-
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t)
583+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
584584
: kind_ (yytranslate_ (t))
585585
{}
586586
@@ -643,7 +643,7 @@ m4_define([b4_token_constructor_define], [])
643643
# sometimes in the cc file.
644644
m4_define([b4_yytranslate_define],
645645
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
646-
]b4_parser_class[::yytranslate_ (int t)
646+
]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
647647
{
648648
]b4_api_token_raw_if(
649649
[[ return static_cast<symbol_kind_type> (t);]],

data/skeletons/glr2.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ m4_define([b4_shared_declarations],
348348
/// Convert a scanner token kind \a t to a symbol kind.
349349
/// In theory \a t should be a token_kind_type, but character literals
350350
/// are valid, yet not members of the token_kind_type enum.
351-
static symbol_kind_type yytranslate_ (int t);
351+
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
352352
353353
]b4_parse_error_bmatch(
354354
[simple],
@@ -3136,13 +3136,13 @@ b4_dollar_popdef])[]dnl
31363136
}
31373137

31383138
static bool
3139-
yy_is_shift_action (int yyaction)
3139+
yy_is_shift_action (int yyaction) YY_NOEXCEPT
31403140
{
31413141
return 0 < yyaction;
31423142
}
31433143

31443144
static bool
3145-
yy_is_error_action (int yyaction)
3145+
yy_is_error_action (int yyaction) YY_NOEXCEPT
31463146
{
31473147
return yyaction == 0;
31483148
}

data/skeletons/lalr1.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,19 @@ m4_define([b4_shared_declarations],
325325

326326
/// Whether the given \c yypact_ value indicates a defaulted state.
327327
/// \param yyvalue the value to check
328-
static bool yy_pact_value_is_default_ (int yyvalue);
328+
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
329329

330330
/// Whether the given \c yytable_ value indicates a syntax error.
331331
/// \param yyvalue the value to check
332-
static bool yy_table_value_is_error_ (int yyvalue);
332+
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
333333

334334
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
335335
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
336336

337337
/// Convert a scanner token kind \a t to a symbol kind.
338338
/// In theory \a t should be a token_kind_type, but character literals
339339
/// are valid, yet not members of the token_kind_type enum.
340-
static symbol_kind_type yytranslate_ (int t);
340+
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
341341

342342
]b4_parse_error_bmatch(
343343
[simple],
@@ -474,7 +474,7 @@ m4_define([b4_shared_declarations],
474474
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
475475

476476
/// Pop \a n symbols from the stack.
477-
void yypop_ (int n = 1);
477+
void yypop_ (int n = 1) YY_NOEXCEPT;
478478

479479
/// Constants.
480480
enum
@@ -779,7 +779,7 @@ m4_if(b4_prefix, [yy], [],
779779
}
780780

781781
void
782-
]b4_parser_class[::yypop_ (int n)
782+
]b4_parser_class[::yypop_ (int n) YY_NOEXCEPT
783783
{
784784
yystack_.pop (n);
785785
}
@@ -822,13 +822,13 @@ m4_if(b4_prefix, [yy], [],
822822
}
823823

824824
bool
825-
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue)
825+
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
826826
{
827827
return yyvalue == yypact_ninf_;
828828
}
829829

830830
bool
831-
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue)
831+
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
832832
{
833833
return yyvalue == yytable_ninf_;
834834
}

data/skeletons/stack.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ m4_define([b4_stack_define],
3737
typedef typename S::size_type size_type;
3838
typedef typename std::ptrdiff_t index_type;
3939

40-
stack (size_type n = 200)
40+
stack (size_type n = 200) YY_NOEXCEPT
4141
: seq_ (n)
4242
{}
4343

@@ -116,7 +116,7 @@ m4_define([b4_stack_define],
116116
class slice
117117
{
118118
public:
119-
slice (const stack& stack, index_type range)
119+
slice (const stack& stack, index_type range) YY_NOEXCEPT
120120
: stack_ (stack)
121121
, range_ (range)
122122
{}

0 commit comments

Comments
 (0)