]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (start_decl): Pass attributes to grokdeclarator.
authorJason Merrill <jason@yorick.cygnus.com>
Fri, 9 Apr 1999 12:44:53 +0000 (12:44 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 9 Apr 1999 12:44:53 +0000 (08:44 -0400)
* decl.c (start_decl): Pass attributes to grokdeclarator.
(grokdeclarator): Handle attributes on constructor-syntax
initializers.

From-SVN: r26313

gcc/cp/ChangeLog
gcc/cp/decl.c

index c1c04e797f7fd5424ce9d3d642b78b32b17683c1..8a85396b40222361203a4cf1834615aee83ac80d 100644 (file)
@@ -1,3 +1,9 @@
+1999-04-09  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl.c (start_decl): Pass attributes to grokdeclarator.
+       (grokdeclarator): Handle attributes on constructor-syntax
+       initializers.
+
 1999-04-08  Mark Mitchell  <mark@codesourcery.com>
 
        * error.c (dump_expr): Don't crash on INDIRECT_REFs whose operands
index 098923768801c3d766c220b81d15d3ee88736b53..e50c90a22cdba2bc13cb5f19ee84211b8654baee 100644 (file)
@@ -6975,6 +6975,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
   tree context;
   extern int have_extern_spec;
   extern int used_extern_spec;
+  tree attrlist;
 
 #if 0
   /* See code below that used this.  */
@@ -6989,8 +6990,14 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
       used_extern_spec = 1;
     }
 
+  if (attributes || prefix_attributes)
+    attrlist = build_scratch_list (attributes, prefix_attributes);
+  else
+    attrlist = NULL_TREE;
+
   decl = grokdeclarator (declarator, declspecs, NORMAL, initialized,
-                        NULL_TREE);
+                        attrlist);
+                        
   if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE)
     return NULL_TREE;
 
@@ -8900,6 +8907,41 @@ build_ptrmemfunc_type (type)
   return t;
 }
 
+/* DECL is a VAR_DECL defined in-class, whose TYPE is also given.
+   Check to see that the definition is valid.  Issue appropriate error
+   messages.  Return 1 if the definition is particularly bad, or 0
+   otherwise.  */
+
+int
+check_static_variable_definition (decl, type)
+     tree decl;
+     tree type;
+{
+  /* Motion 10 at San Diego: If a static const integral data member is
+     initialized with an integral constant expression, the initializer
+     may appear either in the declaration (within the class), or in
+     the definition, but not both.  If it appears in the class, the
+     member is a member constant.  The file-scope definition is always
+     required.  */
+  if (CLASS_TYPE_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
+    {
+      cp_error ("in-class initialization of static data member of non-integral type `%T'", 
+               type);
+      /* If we just return the declaration, crashes will sometimes
+        occur.  We therefore return void_type_node, as if this was a
+        friend declaration, to cause callers to completely ignore
+        this declaration.  */
+      return 1;
+    }
+  else if (!CP_TYPE_CONST_P (type))
+    cp_error ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
+             decl);
+  else if (pedantic && !INTEGRAL_TYPE_P (type))
+    cp_pedwarn ("ANSI C++ forbids initialization of member constant `%D' of non-integral type `%T'", decl, type);
+
+  return 0;
+}
+
 /* Given declspecs and a declarator,
    determine the name and type of the object declared
    and construct a ..._DECL node for it.
@@ -8927,6 +8969,9 @@ build_ptrmemfunc_type (type)
      BITFIELD for a field with specified width.
    INITIALIZED is 1 if the decl has an initializer.
 
+   ATTRLIST is a TREE_LIST node with prefix attributes in TREE_VALUE and
+   normal attributes in TREE_PURPOSE, or NULL_TREE.
+
    In the TYPENAME case, DECLARATOR is really an absolute declarator.
    It may also be so in the PARM case, for a prototype where the
    argument type is specified but not the name.
@@ -8958,41 +9003,6 @@ build_ptrmemfunc_type (type)
 
 enum return_types { return_normal, return_ctor, return_dtor, return_conversion };
 
-/* DECL is a VAR_DECL defined in-class, whose TYPE is also given.
-   Check to see that the definition is valid.  Issue appropriate error
-   messages.  Return 1 if the definition is particularly bad, or 0
-   otherwise.  */
-
-int
-check_static_variable_definition (decl, type)
-     tree decl;
-     tree type;
-{
-  /* Motion 10 at San Diego: If a static const integral data member is
-     initialized with an integral constant expression, the initializer
-     may appear either in the declaration (within the class), or in
-     the definition, but not both.  If it appears in the class, the
-     member is a member constant.  The file-scope definition is always
-     required.  */
-  if (CLASS_TYPE_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
-    {
-      cp_error ("in-class initialization of static data member of non-integral type `%T'", 
-               type);
-      /* If we just return the declaration, crashes will sometimes
-        occur.  We therefore return void_type_node, as if this was a
-        friend declaration, to cause callers to completely ignore
-        this declaration.  */
-      return 1;
-    }
-  else if (!CP_TYPE_CONST_P (type))
-    cp_error ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
-             decl);
-  else if (pedantic && !INTEGRAL_TYPE_P (type))
-    cp_pedwarn ("ANSI C++ forbids initialization of member constant `%D' of non-integral type `%T'", decl, type);
-
-  return 0;
-}
-
 tree
 grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
      tree declspecs;
@@ -9129,14 +9139,29 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
          case CALL_EXPR:
            if (parmlist_is_exprlist (TREE_OPERAND (decl, 1)))
              {
-               /* This is actually a variable declaration using constructor
-                  syntax.  We need to call start_decl and cp_finish_decl so we
-                  can get the variable initialized...  */
+               /* This is actually a variable declaration using
+                  constructor syntax.  We need to call start_decl and
+                  cp_finish_decl so we can get the variable
+                  initialized...  */
+
+               tree attributes, prefix_attributes;
 
                *next = TREE_OPERAND (decl, 0);
                init = TREE_OPERAND (decl, 1);
 
-               decl = start_decl (declarator, declspecs, 1, NULL_TREE, NULL_TREE);
+               if (attrlist)
+                 {
+                   attributes = TREE_PURPOSE (attrlist);
+                   prefix_attributes = TREE_VALUE (attrlist);
+                 }
+               else
+                 {
+                   attributes = NULL_TREE;
+                   prefix_attributes = NULL_TREE;
+                 }
+
+               decl = start_decl (declarator, declspecs, 1,
+                                  attributes, prefix_attributes);
                if (decl)
                  {
                    /* Look for __unused__ attribute */