This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] DR 148
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] DR 148
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 02 Mar 2001 11:48:16 +0000
- Organization: Codesourcery LLC
Hi,
I've installed the attached on both the mainline and 3.0 branch.
It implements the proposed resolution of DR 148
http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/cwg_defects.html#148
which permits pointers to member (a pod type) inside a pod struct.
This is a regression from 2.95, as previously we were not so picky
about non-pod objects
built & tested on i686-pc-linux-gnu.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-02-28 Nathan Sidwell <nathan@codesourcery.com>
* class.c (check_field_decls): Pointers to member do not a
non-pod struct make, as per DR 148.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/class.c,v
retrieving revision 1.365
diff -c -3 -p -r1.365 class.c
*** class.c 2001/02/27 13:12:17 1.365
--- class.c 2001/02/28 15:20:16
*************** check_field_decls (t, access_decls, empt
*** 3594,3603 ****
if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE_P (type))
CLASSTYPE_HAS_MUTABLE (t) = 1;
! if (! pod_type_p (type)
! /* For some reason, pointers to members are POD types themselves,
! but are not allowed in POD structs. Silly. */
! || TYPE_PTRMEM_P (type) || TYPE_PTRMEMFUNC_P (type))
CLASSTYPE_NON_POD_P (t) = 1;
/* If any field is const, the structure type is pseudo-const. */
--- 3594,3602 ----
if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE_P (type))
CLASSTYPE_HAS_MUTABLE (t) = 1;
! if (! pod_type_p (type))
! /* DR 148 now allows pointers to members (which are POD themselves),
! to be allowed in POD structs. */
CLASSTYPE_NON_POD_P (t) = 1;
/* If any field is const, the structure type is pseudo-const. */
// Build don't link:
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com>
// DR 148. Now allows pointer to members in POD struct.
struct X
{
int X::*m;
int (X::*f) ();
};
void Foo (int, ...);
void Baz ()
{
X x;
Foo (1, x);
}