From 6f2d72e0e1038dbd57131bdeee8569c4397ad706 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Sun, 24 May 2015 23:17:58 +0000 Subject: [PATCH] re PR c++/66243 (enum class value is allowed to be initialized by value from other enum class) cp/ PR c++/66243 * decl.c (build_enumerator): Don't silently convert scoped enums. testsuite/ PR c++/66243 * g++.dg/cpp0x/pr66243.C: New. From-SVN: r223636 --- gcc/cp/ChangeLog | 7 ++++++- gcc/cp/decl.c | 3 ++- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/cpp0x/pr66243.C | 12 ++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr66243.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b5168c2a2cb..92c47388f74 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,4 +1,9 @@ -2015-05-22 Jan Hubicka +2015-05-24 Nathan Sidwell + + PR c++/66243 + * decl.c (build_enumerator): Don't silently convert scoped enums. + +2015-05-24 Jan Hubicka PR lto/66180 * mangle.c (mangle_decl): Mangle anonymous namespace types as diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 06fbbd5451f..41530c12947 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13097,7 +13097,8 @@ build_enumerator (tree name, tree value, tree enumtype, tree attributes, if (tmp_value) value = tmp_value; } - else if (! INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))) + else if (! INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P + (TREE_TYPE (value))) value = perform_implicit_conversion_flags (ENUM_UNDERLYING_TYPE (enumtype), value, tf_warning_or_error, LOOKUP_IMPLICIT | LOOKUP_NO_NARROWING); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e6122da271..e41d7e89fcc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,9 @@ -2015-05-22 Jan Hubicka +2015-05-23 Nathan Sidwell + + PR c++/66243 + * g++.dg/cpp0x/pr66243.C: New. + +2015-05-24 Jan Hubicka PR lto/66180 * g++.dg/lto/pr66180_0.C: New testcase. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr66243.C b/gcc/testsuite/g++.dg/cpp0x/pr66243.C new file mode 100644 index 00000000000..41465a03926 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr66243.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +enum class A +{ + X +}; + +enum class B +{ + X = A::X // { dg-error "could not convert" } +}; + -- 2.30.2