* decl.c (build_enumerator): Don't add enumerators for a
scoped enum to the enclosing class.
PR c++/40639
* decl.c (start_enum): Allow dependent underlying type.
PR c++/40633
* decl.c (finish_enum): Finish scope even in a template.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149341
138bc75d-0d04-0410-961f-
82ee72b054a4
+2009-07-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/37816
+ * decl.c (build_enumerator): Don't add enumerators for a
+ scoped enum to the enclosing class.
+
+ PR c++/40639
+ * decl.c (start_enum): Allow dependent underlying type.
+
+ PR c++/40633
+ * decl.c (finish_enum): Finish scope even in a template.
+
2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
* init.c: Replace %J by an explicit location. Update all calls.
TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (underlying_type);
ENUM_UNDERLYING_TYPE (enumtype) = underlying_type;
}
- else
+ else if (!dependent_type_p (underlying_type))
error ("underlying type %<%T%> of %<%T%> must be an integral type",
underlying_type, enumtype);
}
TREE_TYPE (TREE_VALUE (values)) = enumtype;
if (at_function_scope_p ())
add_stmt (build_min (TAG_DEFN, enumtype));
+ if (SCOPED_ENUM_P (enumtype))
+ finish_scope ();
return;
}
TREE_READONLY (decl) = 1;
DECL_INITIAL (decl) = value;
- if (context && context == current_class_type)
+ if (context && context == current_class_type && !SCOPED_ENUM_P (enumtype))
/* In something like `struct S { enum E { i = 7 }; };' we put `i'
on the TYPE_FIELDS list for `S'. (That's so that you can say
things like `S::i' later.) */
+2009-07-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/37816
+ * g++.dg/cpp0x/enum7.C: New.
+
+ PR c++/37946
+ * g++.dg/cpp0x/enum6.C: New.
+
+ PR c++/40639
+ * g++.dg/cpp0x/enum5.C: New.
+
+ PR c++/40633
+ * g++.dg/cpp0x/enum4.C: New.
+
2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
* gcc.dg/format/gcc_diag-1.c: Remove tests for %J.
--- /dev/null
+// PR c++/40633
+// { dg-options "-std=c++0x" }
+
+template< typename T >
+struct wrap {
+ enum class E { val };
+};
+
--- /dev/null
+// PR c++/40639
+// { dg-options "-std=c++0x" }
+
+template< typename T >
+struct wrap {
+ enum E : T { val };
+};
+
+template< typename T >
+struct dependant {
+ enum E : typename T::type { val };
+};
+
+template<typename T>
+struct identity {
+ typedef T type;
+};
+
+wrap<int> x;
+dependant<identity<int>> y;
--- /dev/null
+// PR c++/37946
+// { dg-options "-std=c++0x" }
+
+enum class E : char
+{
+ e1,
+ e2
+};
+
+inline E operator| (E a1, E a2)
+{
+ char ret = static_cast<char> (a1)
+ | static_cast<char> (a2);
+ return static_cast<E>(ret);
+}
--- /dev/null
+// PR c++/37816
+// { dg-options "-std=c++0x" }
+
+class A
+{
+ enum class Color { Red, Orange, Yellow, Green, Blue, Violet };
+ enum class Alert { Green, Yellow, Red };
+ static const Color x = Red; // { dg-error "" }
+ static const Color y = Color::Red;
+ static const Alert z = Alert::Red;
+};