c++: use noexcept where appropriate

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
Hi Don,

Thanks for the reports.  I will install this.  Cheers!

commit 9840e5b621be661c2f7cd593a8bcb910447531da
Author: Akim Demaille <[email protected]>
Date:   Wed Dec 2 21:38:43 2020 +0100

    c++: use noexcept where appropriate
    
    Reported by Don Macpherson.
    https://github.com/akimd/bison/issues/63
    https://github.com/akimd/bison/issues/64
    
    * data/skeletons/c++.m4, data/skeletons/lalr1.cc: here.

diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index f4834c64..b458af3f 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -339,7 +339,7 @@ m4_define([b4_symbol_type_define],
       }
 
       /// Destroy contents, and record that is empty.
-      void clear ()
+      void clear () YY_NOEXCEPT
       {]b4_variant_if([[
         // User destructor.
         symbol_kind_type yykind = this->kind ();
@@ -423,7 +423,7 @@ m4_define([b4_symbol_type_define],
       by_kind (kind_type t);
 
       /// Record that this symbol is empty.
-      void clear ();
+      void clear () YY_NOEXCEPT;
 
       /// Steal the symbol kind from \a that.
       void move (by_kind& that);
@@ -543,7 +543,7 @@ m4_define([b4_public_types_define],
   {}
 
   ]b4_inline([$1])[void
-  ]b4_parser_class[::by_kind::clear ()
+  ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
   {
     kind_ = ]b4_symbol(empty, kind)[;
   }
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index fbabba35..76603492 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -270,9 +270,9 @@ m4_define([b4_shared_declarations],
     {
     public:
       context (const ]b4_parser_class[& yyparser, const symbol_type& yyla);
-      const symbol_type& lookahead () const { return yyla_; }
-      symbol_kind_type token () const { return yyla_.kind (); }]b4_locations_if([[
-      const location_type& location () const { return yyla_.location; }
+      const symbol_type& lookahead () const YY_NOEXCEPT { return yyla_; }
+      symbol_kind_type token () const YY_NOEXCEPT { return yyla_.kind (); }]b4_locations_if([[
+      const location_type& location () const YY_NOEXCEPT { return yyla_.location; }
 ]])[
       /// Put in YYARG at most YYARGN of the expected tokens, and return the
       /// number of tokens stored in YYARG.  If YYARG is null, return the
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.