OSDN Git Service

* decl.c (build_enumerator): Set DECL_CONTEXT for the
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Aug 1998 00:14:27 +0000 (00:14 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Aug 1998 00:14:27 +0000 (00:14 +0000)
CONST_DECLs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@22014 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.pt/enum9.C [new file with mode: 0644]

index 366f352..636fc12 100644 (file)
@@ -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.
index 995207d..ad52979 100644 (file)
@@ -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 (file)
index 0000000..96aeaa6
--- /dev/null
@@ -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>;