re PR c++/66243 (enum class value is allowed to be initialized by value from other...
authorNathan Sidwell <nathan@gcc.gnu.org>
Sun, 24 May 2015 23:17:58 +0000 (23:17 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Sun, 24 May 2015 23:17:58 +0000 (23:17 +0000)
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
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr66243.C [new file with mode: 0644]

index b5168c2a2cb98a171b3c8063108a78c88acd146b..92c47388f74a1b97b64e8474f2413691d5acf354 100644 (file)
@@ -1,4 +1,9 @@
-2015-05-22  Jan Hubicka  <hubicka@ucw.cz>
+2015-05-24  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/66243
+       * decl.c (build_enumerator): Don't silently convert scoped enums.
+
+2015-05-24  Jan Hubicka  <hubicka@ucw.cz>
 
        PR lto/66180
        * mangle.c (mangle_decl): Mangle anonymous namespace types as
index 06fbbd5451f5e0e16ce5f3ad8141c329f794c4c9..41530c12947791c3ff6139c19e7237229889fb7d 100644 (file)
@@ -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);
index 7e6122da27119a3a3fb2a3a772cf6b74bb96bed9..e41d7e89fcce5373aa4550422a85bc9601abb741 100644 (file)
@@ -1,4 +1,9 @@
-2015-05-22  Jan Hubicka  <hubicka@ucw.cz>
+2015-05-23  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/66243
+       * g++.dg/cpp0x/pr66243.C: New.
+
+2015-05-24  Jan Hubicka  <hubicka@ucw.cz>
 
        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 (file)
index 0000000..41465a0
--- /dev/null
@@ -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" }
+};
+