re PR c++/37816 ([c++0x] Invalid handling of scoped enums defined at class scope)
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. From-SVN: r149352
This commit is contained in:
parent
f9ce7e7648
commit
0ad8c85546
|
@ -1,3 +1,15 @@
|
|||
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-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/40619
|
||||
|
|
|
@ -11014,7 +11014,7 @@ start_enum (tree name, tree underlying_type, bool scoped_enum_p)
|
|||
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);
|
||||
}
|
||||
|
@ -11060,6 +11060,8 @@ finish_enum (tree 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;
|
||||
}
|
||||
|
||||
|
@ -11375,7 +11377,7 @@ build_enumerator (tree name, tree value, tree enumtype)
|
|||
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.) */
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
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 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/40669
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// PR c++/40633
|
||||
// { dg-options "-std=c++0x" }
|
||||
|
||||
template< typename T >
|
||||
struct wrap {
|
||||
enum class E { val };
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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;
|
|
@ -0,0 +1,15 @@
|
|||
// 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);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// 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;
|
||||
};
|
Loading…
Reference in New Issue