re PR c++/46862 (ICE on std::decimal::decimal32 without any fields)

PR c++/46862
	* class.c (finish_struct_1): If TYPE_TRANSPARENT_AGGR is set on a type
	which doesn't have any fields, clear it and diagnose.

	* g++.dg/dfp/nofields.C: New test.

From-SVN: r177987
This commit is contained in:
Jakub Jelinek 2011-08-23 15:20:04 +02:00 committed by Jakub Jelinek
parent 02f5d6c5e3
commit bfcbe06886
4 changed files with 37 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2011-08-23 Jakub Jelinek <jakub@redhat.com>
PR c++/46862
* class.c (finish_struct_1): If TYPE_TRANSPARENT_AGGR is set on a type
which doesn't have any fields, clear it and diagnose.
2011-08-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Marc Glisse <marc.glisse@normalesup.org>

View File

@ -1,6 +1,6 @@
/* Functions related to building classes and their related objects.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@ -5794,6 +5794,12 @@ finish_struct_1 (tree t)
/* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
if (TYPE_TRANSPARENT_AGGR (t) && first_field (t) == NULL_TREE)
{
error ("type transparent class %qT does not have any fields", t);
TYPE_TRANSPARENT_AGGR (t) = 0;
}
}
/* When T was built up, the member declarations were added in reverse

View File

@ -1,3 +1,8 @@
2011-08-23 Jakub Jelinek <jakub@redhat.com>
PR c++/46862
* g++.dg/dfp/nofields.C: New test.
2011-08-23 Tobias Burnus <burnus@net-b.de>
PR fortran/31600

View File

@ -0,0 +1,19 @@
// PR c++/46862
// { dg-do compile }
namespace std
{
namespace decimal
{
class decimal32 { }; // { dg-error "does not have any fields" }
class decimal64 { }; // { dg-error "does not have any fields" }
class decimal128 { }; // { dg-error "does not have any fields" }
}
}
void
foo (std::decimal::decimal32 x,
std::decimal::decimal64 y,
std::decimal::decimal128 z)
{
}