Commit e8bd800e by Mark Mitchell Committed by Mark Mitchell

decl.c (build_enumerator): Set DECL_CONTEXT for the CONST_DECLs.

	* decl.c (build_enumerator): Set DECL_CONTEXT for the
	CONST_DECLs.

From-SVN: r22014
parent 563f648b
1998-08-27 Mark Mitchell <mark@markmitchell.com>
* decl.c (build_enumerator): Set DECL_CONTEXT for the
CONST_DECLs.
1998-08-26 Mark Mitchell <mark@markmitchell.com> 1998-08-26 Mark Mitchell <mark@markmitchell.com>
* cp-tree.h (finish_enum): Change prototype. * cp-tree.h (finish_enum): Change prototype.
......
...@@ -11994,6 +11994,7 @@ build_enumerator (name, value) ...@@ -11994,6 +11994,7 @@ build_enumerator (name, value)
tree name, value; tree name, value;
{ {
tree decl, result; tree decl, result;
tree context;
/* Remove no-op casts from the value. */ /* Remove no-op casts from the value. */
if (value) if (value)
...@@ -12043,26 +12044,27 @@ build_enumerator (name, value) ...@@ -12043,26 +12044,27 @@ build_enumerator (name, value)
/* C++ associates enums with global, function, or class declarations. */ /* C++ associates enums with global, function, or class declarations. */
decl = current_scope (); context = current_scope ();
if (decl && decl == current_class_type) if (context && context == current_class_type)
{ /* This enum declaration is local to the class. */
/* This enum declaration is local to the class, so we must put
it in that class's list of decls. */
decl = build_lang_field_decl (CONST_DECL, name, integer_type_node); decl = build_lang_field_decl (CONST_DECL, name, integer_type_node);
else
/* It's a global enum, or it's local to a function. (Note local to
a function could mean local to a class method. */
decl = build_decl (CONST_DECL, name, integer_type_node);
DECL_CONTEXT (decl) = FROB_CONTEXT (context);
DECL_INITIAL (decl) = value; DECL_INITIAL (decl) = value;
TREE_READONLY (decl) = 1; TREE_READONLY (decl) = 1;
if (context && context == current_class_type)
{
pushdecl_class_level (decl); pushdecl_class_level (decl);
TREE_CHAIN (decl) = current_local_enum; TREE_CHAIN (decl) = current_local_enum;
current_local_enum = decl; current_local_enum = decl;
} }
else else
{ {
/* It's a global enum, or it's local to a function. (Note local to
a function could mean local to a class method. */
decl = build_decl (CONST_DECL, name, integer_type_node);
DECL_INITIAL (decl) = value;
TREE_READONLY (decl) = 1;
pushdecl (decl); pushdecl (decl);
GNU_xref_decl (current_function_decl, decl); GNU_xref_decl (current_function_decl, decl);
} }
......
// Build don't link:
template <typename _CharT>
class _Format_cache
{
public:
enum {
_S_digits, _S_digits_end = _S_digits+10,
_S_xdigits = _S_digits_end,
};
};
template class _Format_cache<int>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment