mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-26 17:24:36 +08:00
re PR libstdc++/12600 (Demangler goes in infinite loop for certain invalid mangled names.)
PR libstdc++/12600 * include/bits/demangle.h (session<Allocator>:: decode_unqualified_name(string_type& output)): Fail on a <operator-name> when decoding <template-argument>. * testsuite/demangle/regression/cw-15.cc: New. From-SVN: r72480
This commit is contained in:
parent
1638f5c9d0
commit
be3faf8996
@ -1,3 +1,11 @@
|
||||
2003-10-14 Carlo Wood <carlo@alinoe.com>
|
||||
|
||||
PR libstdc++/12600
|
||||
* include/bits/demangle.h (session<Allocator>::
|
||||
decode_unqualified_name(string_type& output)): Fail on a
|
||||
<operator-name> when decoding <template-argument>.
|
||||
* testsuite/demangle/regression/cw-15.cc: New.
|
||||
|
||||
2003-10-14 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/11480
|
||||
|
@ -1938,48 +1938,41 @@ namespace __gnu_cxx
|
||||
session<Allocator>::decode_unqualified_name(string_type& output)
|
||||
{
|
||||
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unqualified_name");
|
||||
if (isdigit(current()))
|
||||
if (M_inside_template_args)
|
||||
{
|
||||
if (!M_inside_template_args)
|
||||
{
|
||||
bool recursive_unqualified_name = (&M_function_name == &output);
|
||||
// This can be a recursive call when we are decoding
|
||||
// an <operator-name> that is a cast operator for a some
|
||||
// <unqualified-name>; for example "operator Foo()".
|
||||
// In that case this is thus not a ctor or dtor and we
|
||||
// are not interested in updating M_function_name.
|
||||
if (!recursive_unqualified_name)
|
||||
M_function_name.clear();
|
||||
M_name_is_template = false;
|
||||
M_name_is_cdtor = false;
|
||||
M_name_is_conversion_operator = false;
|
||||
if (!decode_source_name(M_function_name))
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
if (!recursive_unqualified_name)
|
||||
output += M_function_name;
|
||||
}
|
||||
else if (!decode_source_name(output))
|
||||
if (!decode_source_name(output))
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
_GLIBCXX_DEMANGLER_RETURN;
|
||||
}
|
||||
if (islower(current()))
|
||||
else if (isdigit(current()))
|
||||
{
|
||||
if (!M_inside_template_args)
|
||||
{
|
||||
bool recursive_unqualified_name = (&M_function_name == &output);
|
||||
// This can be a recursive call when we are decoding
|
||||
// an <operator-name> that is a cast operator for a some
|
||||
// <unqualified-name>; for example "operator Foo()".
|
||||
// In that case this is thus not a ctor or dtor and we
|
||||
// are not interested in updating M_function_name.
|
||||
if (!recursive_unqualified_name)
|
||||
M_function_name.clear();
|
||||
M_name_is_template = false;
|
||||
M_name_is_cdtor = false;
|
||||
M_name_is_conversion_operator = false;
|
||||
if (!decode_operator_name(M_function_name))
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
output += M_function_name;
|
||||
}
|
||||
_GLIBCXX_DEMANGLER_RETURN;
|
||||
}
|
||||
if (current() == 'C' || current() == 'D')
|
||||
{
|
||||
if (M_inside_template_args)
|
||||
M_name_is_template = false;
|
||||
M_name_is_cdtor = false;
|
||||
M_name_is_conversion_operator = false;
|
||||
if (!decode_source_name(M_function_name))
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
if (!recursive_unqualified_name)
|
||||
output += M_function_name;
|
||||
}
|
||||
else if (islower(current()))
|
||||
{
|
||||
M_function_name.clear();
|
||||
M_name_is_template = false;
|
||||
M_name_is_cdtor = false;
|
||||
M_name_is_conversion_operator = false;
|
||||
if (!decode_operator_name(M_function_name))
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
output += M_function_name;
|
||||
}
|
||||
else if (current() == 'C' || current() == 'D')
|
||||
{
|
||||
// <ctor-dtor-name> ::=
|
||||
// C1 # complete object (in-charge) constructor
|
||||
// C2 # base object (not-in-charge) constructor
|
||||
@ -2005,9 +1998,10 @@ namespace __gnu_cxx
|
||||
M_name_is_cdtor = true;
|
||||
eat_current();
|
||||
output += M_function_name;
|
||||
_GLIBCXX_DEMANGLER_RETURN;
|
||||
}
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
else
|
||||
_GLIBCXX_DEMANGLER_FAILURE;
|
||||
_GLIBCXX_DEMANGLER_RETURN;
|
||||
}
|
||||
|
||||
// <unscoped-name> ::=
|
||||
|
35
libstdc++-v3/testsuite/demangle/regression/cw-15.cc
Normal file
35
libstdc++-v3/testsuite/demangle/regression/cw-15.cc
Normal file
@ -0,0 +1,35 @@
|
||||
// 2003-10-14 Carlo Wood <carlo@alinoe.com>
|
||||
|
||||
// Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// IA 64 C++ ABI - 5.1 External Names (a.k.a. Mangling)
|
||||
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libcwd tests
|
||||
int main()
|
||||
{
|
||||
using namespace __gnu_test;
|
||||
|
||||
// cplus-dem CORE
|
||||
verify_demangle("_Z1xNiEE",
|
||||
"error code = -2: invalid mangled name");
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user