From 722070124e991ee93ec3ffbde631b5f3713cd9f0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 1 Aug 2022 07:08:52 +0200 Subject: [PATCH] lalr1.cc: declare stack_symbol_type as noexcept Many C++ tests (400-25, 440-53, 664-5, 667-76, 679-80, 682-3, 685-9, 692) failed with GCC 12.1: ``` test.cc:843:28: required from here /opt/local/include/gcc12/c++/bits/stl_construct.h:95:14: error: noexcept-expression evaluates to 'false' because of a call to 'yy::parser::stack_symbol_type::stack_symbol_type()' [-Werror=noexcept] 95 | noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.cc:990:3: note: but 'yy::parser::stack_symbol_type::stack_symbol_type()' does not throw; perhaps it should be declared 'noexcept' 990 | parser::stack_symbol_type::stack_symbol_type () | ^~~~~~ ``` Reported by Paul Eggert. * data/skeletons/lalr1.cc (stack_symbol_type::stack_symbol_type()): Declare noexcept. --- data/skeletons/lalr1.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc index ce4c6a3d..240f4c36 100644 --- a/data/skeletons/lalr1.cc +++ b/data/skeletons/lalr1.cc @@ -425,7 +425,7 @@ m4_define([b4_shared_declarations], /// Superclass. typedef basic_symbol super_type; /// Construct an empty symbol. - stack_symbol_type (); + stack_symbol_type () YY_NOEXCEPT; /// Move or copy construction. stack_symbol_type (YY_RVREF (stack_symbol_type) that); /// Steal the contents from \a sym to build this. @@ -678,7 +678,7 @@ m4_if(b4_prefix, [yy], [], return YY_CAST (symbol_kind_type, yystos_[+state]); } - ]b4_parser_class[::stack_symbol_type::stack_symbol_type () + ]b4_parser_class[::stack_symbol_type::stack_symbol_type () YY_NOEXCEPT {} ]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)