parse.y: New rules to allow attributes in a prefix position.
authorBrendan Kehoe <brendan@lisa.cygnus.com>
Mon, 13 Mar 1995 02:04:52 +0000 (02:04 +0000)
committerBrendan Kehoe <brendan@gcc.gnu.org>
Mon, 13 Mar 1995 02:04:52 +0000 (21:04 -0500)
        * parse.y: New rules to allow attributes in a prefix position.
        (prefix_attributes): New variable.  Pass it into cplus_decl_attributes.
        (setattr): New rule.
        (reserved_declspecs, declmods): Catch attributes here.
        * decl2.c (cplus_decl_attributes): Add PREFIX_ATTRIBUTES argument.
        * decl.c (duplicate_decls): Pass DECL_MACHINE_ATTRIBUTES to
        descendent typedef.
        (grokdeclarator): Added code to support machine attributes.
        * Makefile.in (stamp-parse): Expect 5 shift/reduce failures.

From-SVN: r9172

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/parse.y

index 7984637caaba02e596944c97a8157d30b9c2b487..0cbb5de182119d3da0ea99c0a212343b2b27e533 100644 (file)
@@ -1,3 +1,15 @@
+Tue Mar  7 10:14:29 1995  Brendan Kehoe  (brendan@lisa.cygnus.com)
+
+       * parse.y: New rules to allow attributes in a prefix position.
+       (prefix_attributes): New variable.  Pass it into cplus_decl_attributes.
+       (setattr): New rule.
+       (reserved_declspecs, declmods): Catch attributes here.
+       * decl2.c (cplus_decl_attributes): Add PREFIX_ATTRIBUTES argument.
+       * decl.c (duplicate_decls): Pass DECL_MACHINE_ATTRIBUTES to
+       descendent typedef.
+       (grokdeclarator): Added code to support machine attributes.
+       * Makefile.in (stamp-parse): Expect 5 shift/reduce failures.
+
 Tue Feb 21 18:43:48 1995  Douglas Rupp  (drupp@cs.washington.edu)
 
        * Make-lang.in, config-lang.in: ($exeext): New macro.
index d39a88595a306c7992d5774d67072fce51c0dafa..766e308e370776d0171ed1c3ef6fc11d0337e73b 100644 (file)
@@ -2011,6 +2011,7 @@ extern tree grokbitfield                  PROTO((tree, tree, tree));
 extern tree groktypefield                      PROTO((tree, tree));
 extern tree grokoptypename                     PROTO((tree, tree));
 extern tree build_push_scope                   PROTO((tree, tree));
+extern void cplus_decl_attributes              PROTO((tree, tree, tree)); 
 extern tree constructor_name_full              PROTO((tree));
 extern tree constructor_name                   PROTO((tree));
 extern void setup_vtbl_ptr                     PROTO((void));
index 01547b0a766bdd85690e2a6136dd3975ef4d2f59..aad3dfb04b0a5566174c2bbf698df7dd22249dd1 100644 (file)
@@ -2122,6 +2122,9 @@ duplicate_decls (newdecl, olddecl)
   int new_defines_function;
   tree previous_c_decl = NULL_TREE;
 
+  if (TREE_CODE_CLASS (TREE_CODE (olddecl)) == 'd')
+    DECL_MACHINE_ATTRIBUTES (newdecl) = DECL_MACHINE_ATTRIBUTES (olddecl);
+
   types_match = decls_match (newdecl, olddecl);
 
   if (TREE_CODE (olddecl) != TREE_LIST)
@@ -7157,6 +7160,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
   enum tree_code innermost_code = ERROR_MARK;
   int bitfield = 0;
   int size_varies = 0;
+  tree decl_machine_attr = NULL_TREE;
   /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
      All FIELD_DECLs we build here have `init' put into their DECL_INITIAL.  */
   tree init = NULL_TREE;
@@ -7530,6 +7534,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
          else
            {
              type = TREE_TYPE (t);
+             decl_machine_attr = DECL_MACHINE_ATTRIBUTES (id);
              typedef_decl = t;
            }
        }
@@ -9001,6 +9006,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
            decl = grokfndecl (ctype, type, declarator,
                               virtualp, flags, quals,
                               raises, friendp ? -1 : 0, publicp);
+           decl = build_decl_attribute_variant (decl, decl_machine_attr);
            if (decl == NULL_TREE)
              return NULL_TREE;
 
index 1da4097c5569d99649d5f2c5365a299bd01d519b..b0e5c00c56949c71e8288020688610b936ebdc8d 100644 (file)
@@ -1921,11 +1921,11 @@ build_push_scope (cname, name)
   return rval;
 }
 
-void cplus_decl_attributes (decl, attributes)
-     tree decl, attributes;
+void cplus_decl_attributes (decl, attributes, prefix_attributes)
+     tree decl, attributes, prefix_attributes;
 {
   if (decl && decl != void_type_node)
-    decl_attributes (decl, attributes, NULL_TREE);
+    decl_attributes (decl, attributes, prefix_attributes);
 }
 \f
 /* CONSTRUCTOR_NAME:
index b85ffc9d49926cf38c0c9a5f5fb96c8195ebe715..c51c756700a3f506ced4381f6b8b0035ecbf355f 100644 (file)
@@ -287,6 +287,7 @@ empty_parms ()
 %{
 /* List of types and structure classes of the current declaration.  */
 static tree current_declspecs;
+static tree prefix_attributes = NULL_TREE;
 
 /* When defining an aggregate, this is the most recent one being defined.  */
 static tree current_aggr;
@@ -504,7 +505,7 @@ template_def:
                  momentary = suspend_momentary ();
                  d = start_decl ($<ttype>2, /*current_declspecs*/NULL_TREE, 0,
                                  $3);
-                 cplus_decl_attributes (d, $5);
+                 cplus_decl_attributes (d, $5, prefix_attributes);
                  finish_decl (d, NULL_TREE, $4, 0, 0);
                  end_template_decl ($1, d, 0, def);
                  if (def)
@@ -523,7 +524,7 @@ template_def:
                  momentary = suspend_momentary ();
                  d = start_decl ($<ttype>3, current_declspecs,
                                  0, $<ttype>4);
-                 cplus_decl_attributes (d, $6);
+                 cplus_decl_attributes (d, $6, prefix_attributes);
                  finish_decl (d, NULL_TREE, $5, 0, 0);
                  end_template_decl ($1, d, 0, def);
                  if (def)
@@ -975,7 +976,7 @@ condition:
                  current_declspecs = $1;
                  $<itype>6 = suspend_momentary ();
                  $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3);
-                 cplus_decl_attributes ($<ttype>$, $5);
+                 cplus_decl_attributes ($<ttype>$, $5, prefix_attributes);
                }
        init
                { 
@@ -1724,6 +1725,10 @@ object:    primary '.'
                }
        ;
 
+setattrs: /* empty */
+               { prefix_attributes = $<ttype>0; }
+       ;
+
 decl:
        /* Normal case: make this fast.  */
          typespec declarator ';'
@@ -1833,6 +1838,10 @@ reserved_declspecs:
                    warning ("`%s' is not at beginning of declaration",
                             IDENTIFIER_POINTER ($2));
                  $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+       | reserved_declspecs attributes setattrs
+               { $$ = $1; }
+       | attributes setattrs
+               { $$ = NULL_TREE; }
        ;
 
 /* List of just storage classes and type modifiers.
@@ -1853,6 +1862,10 @@ declmods:
                             IDENTIFIER_POINTER ($2));
                  $$ = decl_tree_cons (NULL_TREE, $2, $$);
                  TREE_STATIC ($$) = TREE_STATIC ($1); }
+       | declmods attributes setattrs
+               { $$ = $1; }
+       | attributes setattrs
+               { $$ = NULL_TREE; }
        ;
 
 
@@ -1968,7 +1981,7 @@ initdcl0:
                    }
                  $<itype>5 = suspend_momentary ();
                  $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
-                 cplus_decl_attributes ($<ttype>$, $4); }
+                 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
@@ -1987,20 +2000,20 @@ initdcl0:
                    }
                  $$ = suspend_momentary ();
                  d = start_decl ($<ttype>1, current_declspecs, 0, $2);
-                 cplus_decl_attributes (d, $4);
+                 cplus_decl_attributes (d, $4, prefix_attributes);
                  finish_decl (d, NULL_TREE, $3, 0, 0); }
        ;
 
 initdcl:
          declarator exception_specification_opt maybeasm maybe_attribute '='
                { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
-                 cplus_decl_attributes ($<ttype>$, $4); }
+                 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING); }
        | declarator exception_specification_opt maybeasm maybe_attribute
                { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2);
-                 cplus_decl_attributes ($<ttype>$, $4);
+                 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes);
                  finish_decl ($<ttype>$, NULL_TREE, $3, 0, 0); }
        ;
 
@@ -2009,7 +2022,7 @@ notype_initdcl0:
                { current_declspecs = $<ttype>0;
                  $<itype>5 = suspend_momentary ();
                  $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
-                 cplus_decl_attributes ($<ttype>$, $4); }
+                 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
@@ -2019,7 +2032,7 @@ notype_initdcl0:
                  current_declspecs = $<ttype>0;
                  $$ = suspend_momentary ();
                  d = start_decl ($<ttype>1, current_declspecs, 0, $2);
-                 cplus_decl_attributes (d, $4);
+                 cplus_decl_attributes (d, $4, prefix_attributes);
                  finish_decl (d, NULL_TREE, $3, 0, 0); }
        ;
 
@@ -2028,7 +2041,7 @@ nomods_initdcl0:
                { current_declspecs = NULL_TREE;
                  $<itype>5 = suspend_momentary ();
                  $<ttype>$ = start_decl ($1, current_declspecs, 1, $2);
-                 cplus_decl_attributes ($<ttype>$, $4); }
+                 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
@@ -2038,7 +2051,7 @@ nomods_initdcl0:
                  current_declspecs = NULL_TREE;
                  $$ = suspend_momentary ();
                  d = start_decl ($1, current_declspecs, 0, $2);
-                 cplus_decl_attributes (d, $4);
+                 cplus_decl_attributes (d, $4, prefix_attributes);
                  finish_decl (d, NULL_TREE, $3, 0, 0); }
        ;
 
@@ -2608,7 +2621,7 @@ component_decl_1:
                }
        | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
                { $$ = grokfield ($$, NULL_TREE, $2, $5, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | ':' expr_no_commas
                { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
        | error
@@ -2626,12 +2639,12 @@ component_decl_1:
                { $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1),
                                         $3, $5);
                  $$ = grokfield ($$, TREE_CHAIN ($1), $6, $9, $7);
-                 cplus_decl_attributes ($$, $8); }
+                 cplus_decl_attributes ($$, $8, prefix_attributes); }
        | typed_declspecs LEFT_RIGHT type_quals exception_specification_opt maybeasm maybe_attribute maybe_init
                { $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1),
                                         empty_parms (), $3);
                  $$ = grokfield ($$, TREE_CHAIN ($1), $4, $7, $5);
-                 cplus_decl_attributes ($$, $6); }
+                 cplus_decl_attributes ($$, $6, prefix_attributes); }
        | using_decl
        ;
 
@@ -2680,47 +2693,47 @@ after_type_component_declarator0:
          after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
                { current_declspecs = $<ttype>0;
                  $$ = grokfield ($$, current_declspecs, $2, $5, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | TYPENAME ':' expr_no_commas maybe_attribute
                { current_declspecs = $<ttype>0;
                  $$ = grokbitfield ($$, current_declspecs, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        ;
 
 notype_component_declarator0:
          notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
                { current_declspecs = $<ttype>0;
                  $$ = grokfield ($$, current_declspecs, $2, $5, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | IDENTIFIER ':' expr_no_commas maybe_attribute
                { current_declspecs = $<ttype>0;
                  $$ = grokbitfield ($$, current_declspecs, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | ':' expr_no_commas maybe_attribute
                { current_declspecs = $<ttype>0;
                  $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
-                 cplus_decl_attributes ($$, $3); }
+                 cplus_decl_attributes ($$, $3, prefix_attributes); }
        ;
 
 after_type_component_declarator:
          after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
                { $$ = grokfield ($$, current_declspecs, $2, $5, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | TYPENAME ':' expr_no_commas maybe_attribute
                { $$ = grokbitfield ($$, current_declspecs, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        ;
 
 notype_component_declarator:
          notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
                { $$ = grokfield ($$, current_declspecs, $2, $5, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | IDENTIFIER ':' expr_no_commas maybe_attribute
                { $$ = grokbitfield ($$, current_declspecs, $3);
-                 cplus_decl_attributes ($$, $4); }
+                 cplus_decl_attributes ($$, $4, prefix_attributes); }
        | ':' expr_no_commas maybe_attribute
                { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
-                 cplus_decl_attributes ($$, $3); }
+                 cplus_decl_attributes ($$, $3, prefix_attributes); }
        ;
 
 /* We chain the enumerators in reverse order.