Hi! TYPE_TRANSPARENT_AGGR types are passed and mangled as its first field. But if somebody errorneously doesn't put any types in its definition, the FE marks it TYPE_TRANSPARENT_AGGR early (e.g. even on a forward declaration), but during mangling or in middle-end when trying to find out how it will be passed we ICE because first_field is NULL.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk/4.6? 2011-08-22 Jakub Jelinek <ja...@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. * g++.dg/ext/decimal1.C: New test. --- gcc/cp/class.c.jj 2011-08-18 08:35:38.000000000 +0200 +++ gcc/cp/class.c 2011-08-22 12:52:13.000000000 +0200 @@ -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 (tiem...@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 --- gcc/testsuite/g++.dg/ext/decimal1.C.jj 2011-08-22 13:22:01.000000000 +0200 +++ gcc/testsuite/g++.dg/ext/decimal1.C 2011-08-22 13:16:30.000000000 +0200 @@ -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) +{ +} Jakub