old-cross-binutils/gdb/testsuite/gdb.cp/vla-cxx.cc
Tom Tromey d98b7a16a9 fix PR 17106
This fixes PR 17106, a regression in printing.

The bug is that resolve_dynamic_type follows struct members and
references, but doesn't consider the possibility of infinite
recursion.

This patch fixes the problem by limiting reference following to the
topmost layer of calls -- that is, reference-typed struct members are
never considered as being VLAs.

Built and regtested on x86-64 Fedora 20.
New test case included.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	PR exp/17106:
	* gdbtypes.c (is_dynamic_type_internal): New function, from
	is_dynamic_type.
	(is_dynamic_type): Rewrite.
	(resolve_dynamic_union): Use resolve_dynamic_type_internal.
	(resolve_dynamic_struct): Likewise.
	(resolve_dynamic_type_internal): New function, from
	resolve_dynamic_type.
	(resolve_dynamic_type): Rewrite.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/vla-cxx.cc: New file.
	* gdb.cp/vla-cxx.exp: New file.
2014-07-14 10:14:36 -06:00

49 lines
1.2 KiB
C++

/* This testcase is part of GDB, the GNU debugger.
Copyright 2014 Free Software Foundation, Inc.
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>. */
struct container;
struct element
{
container &c;
element(container &cc) : c (cc) { }
};
struct container
{
element e;
container() : e(*this) { }
};
int main(int argc, char **argv)
{
int z = 3;
// Note that this is a GNU extension.
int vla[z];
typeof (vla) &vlaref (vla);
typedef typeof (vla) &vlareftypedef;
vlareftypedef vlaref2 (vla);
container c;
for (int i = 0; i < z; ++i)
vla[i] = 5 + 2 * i;
// vlas_filled
return vla[2];
}