aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Kehoe <brendan@lisa.cygnus.com>1995-03-13 02:04:52 +0000
committerBrendan Kehoe <brendan@gcc.gnu.org>1995-03-12 21:04:52 -0500
commitf6abb50a8a53adba2fdfdee15069890868f0d443 (patch)
treec2a260465fa275684474039646345364e0fad98e
parentbf6ed0403197c55ff8176894d0a215b32ef15bc5 (diff)
downloadgcc-f6abb50a8a53adba2fdfdee15069890868f0d443.zip
gcc-f6abb50a8a53adba2fdfdee15069890868f0d443.tar.gz
gcc-f6abb50a8a53adba2fdfdee15069890868f0d443.tar.bz2
parse.y: New rules to allow attributes in a prefix position.
* 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
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/decl2.c6
-rw-r--r--gcc/cp/parse.y61
5 files changed, 59 insertions, 27 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7984637..0cbb5de 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d39a885..766e308 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 01547b0..aad3dfb 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1da4097..b0e5c00 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
}
/* CONSTRUCTOR_NAME:
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index b85ffc9..c51c756 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -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.