lalr1.cc: fix compiler warnings

Reported by Rob Conde.
http://lists.gnu.org/archive/html/bug-bison/2013-03/msg00003.html

* data/stack.hh (operator=, stack(const stack&)): Make this class
uncopyable, i.e., "undefine" these operators: make them private and
don't implement them.
(clear): New.
* data/lalr1.cc: Use it instead of an assignment.
(parser): Make this class uncopyable.
This commit is contained in:
Akim Demaille
2013-04-08 10:54:12 +02:00
parent 80a2826e69
commit e83be476a5
4 changed files with 18 additions and 3 deletions

2
NEWS
View File

@@ -8,6 +8,8 @@ GNU Bison NEWS
With locations enabled, __attribute__ was used unprotected. With locations enabled, __attribute__ was used unprotected.
*** Fix some compiler warnings (lalr1.cc)
* Noteworthy changes in release 2.7 (2012-12-12) [stable] * Noteworthy changes in release 2.7 (2012-12-12) [stable]
** Bug fixes ** Bug fixes

1
THANKS
View File

@@ -103,6 +103,7 @@ Ralf Wildenhues Ralf.Wildenhues@gmx.de
Richard Stallman rms@gnu.org Richard Stallman rms@gnu.org
Rob Vermaas rob.vermaas@gmail.com Rob Vermaas rob.vermaas@gmail.com
Robert Anisko anisko_r@epita.fr Robert Anisko anisko_r@epita.fr
Rob Conde rob.conde@ai-solutions.com
Satya Kiran Popuri satyakiran@gmail.com Satya Kiran Popuri satyakiran@gmail.com
Sebastian Setzer sebastian.setzer.ext@siemens.com Sebastian Setzer sebastian.setzer.ext@siemens.com
Sebastien Fricker sebastien.fricker@gmail.com Sebastien Fricker sebastien.fricker@gmail.com

View File

@@ -107,6 +107,10 @@ b4_user_stype
#endif #endif
private: private:
/// This class is not copyable.
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
]b4_parser_class_name[& operator= (const ]b4_parser_class_name[&);
/// Report a syntax error. /// Report a syntax error.
/// \param loc where the syntax error is found. /// \param loc where the syntax error is found.
/// \param msg a description of the syntax error. /// \param msg a description of the syntax error.
@@ -552,9 +556,9 @@ b4_dollar_popdef])[]dnl
yynewstate, since the latter expects the semantical and the yynewstate, since the latter expects the semantical and the
location values to have been already stored, initialize these location values to have been already stored, initialize these
stacks with a primary value. */ stacks with a primary value. */
yystate_stack_ = state_stack_type (0); yystate_stack_.clear ();
yysemantic_stack_ = semantic_stack_type (0); yysemantic_stack_.clear ();
yylocation_stack_ = location_stack_type (0); yylocation_stack_.clear ();
yysemantic_stack_.push (yylval); yysemantic_stack_.push (yylval);
yylocation_stack_.push (yylloc); yylocation_stack_.push (yylloc);

View File

@@ -77,6 +77,12 @@ b4_copyright([Stack handling for Bison parsers in C++],
seq_.pop_front (); seq_.pop_front ();
} }
void
clear ()
{
seq_.clear ();
}
inline inline
unsigned int unsigned int
height () const height () const
@@ -88,6 +94,8 @@ b4_copyright([Stack handling for Bison parsers in C++],
inline const_iterator end () const { return seq_.rend (); } inline const_iterator end () const { return seq_.rend (); }
private: private:
stack (const stack&);
stack& operator= (const stack&);
S seq_; S seq_;
}; };