This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[C++ PATCH] Bug 338/DR 128


Hi,
I've installed this patch on the mainline. It fixes bug 338 by
implementing the proposed resolution to DR128
http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/cwg_defects.html#128

This is not a regression from 2.95 as that also disallowed the
conversion, so I've not put this on the branch.

built & tested on i686-pc-linux-gnu, approved by Mark (who
also approved my previous patch for DR 148)

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>

	* typeck.c (build_static_cast): Allow enum to enum conversions
	as per DR 128.

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.339
diff -c -3 -p -r1.339 typeck.c
*** typeck.c	2001/02/14 16:41:44	1.339
--- typeck.c	2001/02/28 15:18:25
*************** build_static_cast (type, expr)
*** 5093,5098 ****
--- 5093,5105 ----
  	   && TREE_CODE (type) != FUNCTION_TYPE
  	   && can_convert (intype, strip_all_pointer_quals (type)))
      ok = 1;
+   else if (TREE_CODE (intype) == ENUMERAL_TYPE
+            && TREE_CODE (type) == ENUMERAL_TYPE)
+     /* DR 128: "A value of integral _or enumeration_ type can be explicitly
+        converted to an enumeration type."
+        The integral to enumeration will be accepted by the previous clause.
+        We need to explicitly check for enumeration to enumeration.  */
+     ok = 1;
  
    /* [expr.static.cast]
  
// Build don't link:

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com>

// Bug 338 and DR 128. Allow static cast to convert between enums.

enum E1 {e1};
enum E2 {e2};

E2 Foo (E1 e)
{
  return static_cast <E2> (e);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]