Commit e7b6bcf3 by Jakub Jelinek Committed by Jason Merrill

re PR c++/50207 (G++ segv's on reduced test case)

	PR c++/50207
	* class.c (finish_struct_1): Complain if the first field is
	artificial.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r178276
parent 25dd2fdd
2011-08-29 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
PR c++/50207
* class.c (finish_struct_1): Complain if the first field is
artificial.
2011-08-29 Jason Merrill <jason@redhat.com> 2011-08-29 Jason Merrill <jason@redhat.com>
PR c++/50209 PR c++/50209
......
...@@ -5795,10 +5795,25 @@ finish_struct_1 (tree t) ...@@ -5795,10 +5795,25 @@ finish_struct_1 (tree t)
/* Finish debugging output for this type. */ /* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t)); rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
if (TYPE_TRANSPARENT_AGGR (t) && first_field (t) == NULL_TREE) if (TYPE_TRANSPARENT_AGGR (t))
{ {
error ("type transparent class %qT does not have any fields", t); tree field = first_field (t);
TYPE_TRANSPARENT_AGGR (t) = 0; if (field == NULL_TREE || error_operand_p (field))
{
error ("type transparent class %qT does not have any fields", t);
TYPE_TRANSPARENT_AGGR (t) = 0;
}
else if (DECL_ARTIFICIAL (field))
{
if (DECL_FIELD_IS_BASE (field))
error ("type transparent class %qT has base classes", t);
else
{
gcc_checking_assert (DECL_VIRTUAL_P (field));
error ("type transparent class %qT has virtual functions", t);
}
TYPE_TRANSPARENT_AGGR (t) = 0;
}
} }
} }
......
2011-08-29 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
* g++.dg/dfp/base.C: New test.
2011-08-29 Jason Merrill <jason@redhat.com> 2011-08-29 Jason Merrill <jason@redhat.com>
Core DR 994 Core DR 994
......
// PR c++/50207
// { dg-do compile }
namespace std
{
namespace decimal
{
template <class _Fmt> struct _FmtTraits;
class decimal32;
template <> struct _FmtTraits <decimal32>
{
static const long _NumBytes = 4UL;
};
template <class _Tr> class _DecBase
{
unsigned char _Bytes[_Tr::_NumBytes];
};
class decimal32 : public _DecBase <_FmtTraits <decimal32> > // { dg-error "has base" }
{
decimal32 () { }
};
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment