diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-03-02 11:48:38 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-03-02 11:48:38 +0000 |
commit | 7eeb553cec1598b3cd5307f8be190af8bf155651 (patch) | |
tree | 48b71b444a8fd5c2482b8c57727cb8077cb2d614 /gcc | |
parent | d282fcb29aee561a8d60646d45333e5e89b4c5d4 (diff) | |
download | gcc-7eeb553cec1598b3cd5307f8be190af8bf155651.zip gcc-7eeb553cec1598b3cd5307f8be190af8bf155651.tar.gz gcc-7eeb553cec1598b3cd5307f8be190af8bf155651.tar.bz2 |
typeck.c (build_static_cast): Allow enum to enum conversions as per DR 128.
cp:
* typeck.c (build_static_cast): Allow enum to enum conversions
as per DR 128.
testsuite:
* g++.old-deja/g++.other/enum3.C: New test.
From-SVN: r40187
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/enum3.C | 14 |
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index af98592..389b9fc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2001-03-02 Nathan Sidwell <nathan@codesourcery.com> + * typeck.c (build_static_cast): Allow enum to enum conversions + as per DR 128. + +2001-03-02 Nathan Sidwell <nathan@codesourcery.com> + * class.c (check_field_decls): Pointers to member do not a non-pod struct make, as per DR 148. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index f0d70ce..8b87342 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5093,6 +5093,13 @@ build_static_cast (type, expr) && 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] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0b9178..94aa892 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2001-03-02 Nathan Sidwell <nathan@codesourcery.com> + * g++.old-deja/g++.other/enum3.C: New test. + +2001-03-02 Nathan Sidwell <nathan@codesourcery.com> + * g++.old-deja/g++.other/pod1.C: New test. 2001-03-02 Nathan Sidwell <nathan@codesourcery.com> diff --git a/gcc/testsuite/g++.old-deja/g++.other/enum3.C b/gcc/testsuite/g++.old-deja/g++.other/enum3.C new file mode 100644 index 0000000..c4303f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum3.C @@ -0,0 +1,14 @@ +// 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); +} |