diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-08-27 00:14:27 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-08-27 00:14:27 +0000 |
commit | e8bd800e45b432c80294945265888aac20add1ff (patch) | |
tree | e41ca766518f71e3d817f12f88938631eb0a2efa | |
parent | 563f648be5df0a2c3cd0a490ce3f4e72c54f32f6 (diff) | |
download | gcc-e8bd800e45b432c80294945265888aac20add1ff.zip gcc-e8bd800e45b432c80294945265888aac20add1ff.tar.gz gcc-e8bd800e45b432c80294945265888aac20add1ff.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 50 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/enum9.C | 13 |
3 files changed, 44 insertions, 24 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 366f352..636fc12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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> * cp-tree.h (finish_enum): Change prototype. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 995207d..ad52979 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11994,6 +11994,7 @@ build_enumerator (name, value) tree name, value; { tree decl, result; + tree context; /* Remove no-op casts from the value. */ if (value) @@ -12042,30 +12043,31 @@ build_enumerator (name, value) value = copy_node (value); /* C++ associates enums with global, function, or class declarations. */ - - decl = current_scope (); - if (decl && decl == current_class_type) - { - /* 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_INITIAL (decl) = value; - TREE_READONLY (decl) = 1; - pushdecl_class_level (decl); - TREE_CHAIN (decl) = current_local_enum; - current_local_enum = decl; - } - 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); - GNU_xref_decl (current_function_decl, decl); - } + + context = current_scope (); + if (context && context == current_class_type) + /* This enum declaration is local to the class. */ + 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; + TREE_READONLY (decl) = 1; + + if (context && context == current_class_type) + { + pushdecl_class_level (decl); + TREE_CHAIN (decl) = current_local_enum; + current_local_enum = decl; + } + else + { + pushdecl (decl); + GNU_xref_decl (current_function_decl, decl); + } if (! processing_template_decl) { diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum9.C b/gcc/testsuite/g++.old-deja/g++.pt/enum9.C new file mode 100644 index 0000000..96aeaa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum9.C @@ -0,0 +1,13 @@ +// 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>; |