[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/8] C++: fix -Wdeprecated warnings
From: |
Akim Demaille |
Subject: |
[PATCH 2/8] C++: fix -Wdeprecated warnings |
Date: |
Sun, 27 May 2018 10:55:29 +0200 |
For instance on test 99:
In file included from @@.cc:56:
@@.hh:409:26: error: definition of implicit copy constructor for
'stack_symbol_type' is deprecated because it
has a user-declared copy assignment operator
[-Werror,-Wdeprecated]
stack_symbol_type& operator= (const stack_symbol_type& that);
^
Reported by Derek Clegg.
https://lists.gnu.org/archive/html/bison-patches/2018-05/msg00036.html
* configure.ac (warn_tests): Add -Wdeprecated.
* data/lalr1.cc (stack_symbol_type): Add an explicit copy ctor.
We cannot rely on the explicit default implementation (`= default`)
as we support C++ 98.
---
THANKS | 1 +
configure.ac | 2 +-
data/lalr1.cc | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/THANKS b/THANKS
index 52298d08..d964c10a 100644
--- a/THANKS
+++ b/THANKS
@@ -40,6 +40,7 @@ Daniel Hagerty address@hidden
David J. MacKenzie address@hidden
David Kastrup address@hidden
Dennis Clarke address@hidden
+Derek Clegg address@hidden
Derek M. Jones address@hidden
Di-an Jan address@hidden
Dick Streefland address@hidden
diff --git a/configure.ac b/configure.ac
index 5412f6b9..99f6ad43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,7 +94,7 @@ if test "$enable_gcc_warnings" = yes; then
# -Wno-keyword-macro: We use the "#define private public" dirty
# trick in the test suite to check some private implementation
# details for lalr1.cc.
- warn_tests='-Wundef -pedantic -Wsign-compare -fno-color-diagnostics
+ warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare
-fno-color-diagnostics
-Wno-keyword-macro'
AC_LANG_PUSH([C])
diff --git a/data/lalr1.cc b/data/lalr1.cc
index a4feab0a..5ac9d2de 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -314,6 +314,8 @@ b4_location_define])])[
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
+ /// Copy construct.
+ stack_symbol_type (const stack_symbol_type& that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back.
@@ -573,6 +575,13 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
{}
+ ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const
stack_symbol_type& that)
+ : super_type (that.state]b4_locations_if([, that.location])[)
+ {
+ ]b4_variant_if([b4_symbol_variant([that.type_get ()],
+ [value], [copy], [that.value])],
+ [[value = that.value;]])[
+ }
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s,
symbol_type& that)
: super_type (s]b4_locations_if([, that.location])[)
--
2.17.0
- [PATCH 0/8] maint: fix more warnings, Akim Demaille, 2018/05/27
- [PATCH 1/8] tests: fix -Wdeprecated warning, Akim Demaille, 2018/05/27
- [PATCH 3/8] C++: style: space before paren, Akim Demaille, 2018/05/27
- [PATCH 4/8] C++: style: prefer `unsigned` to `unsigned int`, Akim Demaille, 2018/05/27
- [PATCH 5/8] NEWS: update, Akim Demaille, 2018/05/27
- [PATCH 6/8] C++: style: fix indentation, Akim Demaille, 2018/05/27
- [PATCH 2/8] C++: fix -Wdeprecated warnings,
Akim Demaille <=
- [PATCH 8/8] regen, Akim Demaille, 2018/05/27
- [PATCH 7/8] bison: please address sanitizer, Akim Demaille, 2018/05/27