summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/c-parse.in
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-10-16 06:09:09 +0000
committerobrien <obrien@FreeBSD.org>1999-10-16 06:09:09 +0000
commitcae8fa8120c70195f34a2456f18c4c848a2d3e0c (patch)
treef7d3a3ab9c32694206552e767626366f016f2062 /contrib/gcc/c-parse.in
parent84656b55b6e25e30322dc903a05de53706361d3d (diff)
downloadFreeBSD-src-cae8fa8120c70195f34a2456f18c4c848a2d3e0c.zip
FreeBSD-src-cae8fa8120c70195f34a2456f18c4c848a2d3e0c.tar.gz
Virgin import of the GCC 2.95.1 compilers
Diffstat (limited to 'contrib/gcc/c-parse.in')
-rw-r--r--contrib/gcc/c-parse.in90
1 files changed, 64 insertions, 26 deletions
diff --git a/contrib/gcc/c-parse.in b/contrib/gcc/c-parse.in
index 16500c5..6757c4d 100644
--- a/contrib/gcc/c-parse.in
+++ b/contrib/gcc/c-parse.in
@@ -1,5 +1,5 @@
/* YACC parser for C syntax and for Objective C. -*-c-*-
- Copyright (C) 1987, 88, 89, 92-97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -31,7 +31,7 @@ ifobjc
%expect 66
end ifobjc
ifc
-%expect 46
+%expect 51
/* These are the 23 conflicts you should get in parse.output;
the state numbers may vary if minor changes in the grammar are made.
@@ -116,7 +116,7 @@ end ifc
yylval contains an IDENTIFIER_NODE which indicates which one. */
%token TYPESPEC
-/* Reserved words that qualify type: "const" or "volatile".
+/* Reserved words that qualify type: "const", "volatile", or "restrict".
yylval contains an IDENTIFIER_NODE which indicates which one. */
%token TYPE_QUAL
@@ -525,7 +525,7 @@ cast_expr:
tree type = $2;
finish_init ();
- if (pedantic)
+ if (pedantic && ! flag_isoc9x)
pedwarn ("ANSI C forbids constructor expressions");
if (TYPE_NAME (type) != 0)
{
@@ -604,12 +604,22 @@ expr_no_commas:
{ skip_evaluation -= $1 == boolean_true_node;
$$ = build_conditional_expr ($1, $<ttype>2, $5); }
| expr_no_commas '=' expr_no_commas
- { $$ = build_modify_expr ($1, NOP_EXPR, $3);
- C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
+ { char class;
+ $$ = build_modify_expr ($1, NOP_EXPR, $3);
+ class = TREE_CODE_CLASS (TREE_CODE ($$));
+ if (class == 'e' || class == '1'
+ || class == '2' || class == '<')
+ C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
+ }
| expr_no_commas ASSIGN expr_no_commas
- { $$ = build_modify_expr ($1, $2, $3);
+ { char class;
+ $$ = build_modify_expr ($1, $2, $3);
/* This inhibits warnings in truthvalue_conversion. */
- C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
+ class = TREE_CODE_CLASS (TREE_CODE ($$));
+ if (class == 'e' || class == '1'
+ || class == '2' || class == '<')
+ C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
+ }
;
primary:
@@ -1275,33 +1285,41 @@ initlist1:
/* `initelt' is a single element of an initializer.
It may use braces. */
initelt:
- expr_no_commas
- { process_init_element ($1); }
- | '{'
+ designator_list '=' initval
+ | designator initval
+ | identifier ':'
+ { set_init_label ($1); }
+ initval
+ | initval
+ ;
+
+initval:
+ '{'
{ push_init_level (0); }
initlist_maybe_comma '}'
{ process_init_element (pop_init_level (0)); }
+ | expr_no_commas
+ { process_init_element ($1); }
| error
+ ;
+
+designator_list:
+ designator
+ | designator_list designator
+ ;
+
+designator:
+ '.' identifier
+ { set_init_label ($2); }
/* These are for labeled elements. The syntax for an array element
initializer conflicts with the syntax for an Objective-C message,
so don't include these productions in the Objective-C grammar. */
ifc
- | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
+ | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
{ set_init_index ($2, $4); }
- initelt
- | '[' expr_no_commas ']' '='
- { set_init_index ($2, NULL_TREE); }
- initelt
| '[' expr_no_commas ']'
{ set_init_index ($2, NULL_TREE); }
- initelt
end ifc
- | identifier ':'
- { set_init_label ($1); }
- initelt
- | '.' identifier '='
- { set_init_label ($2); }
- initelt
;
nested_function:
@@ -1398,6 +1416,13 @@ parm_declarator:
/* | parm_declarator '(' error ')' %prec '.'
{ $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
poplevel (0, 0, 0); } */
+ifc
+ | parm_declarator '[' '*' ']' %prec '.'
+ { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
+ if (! flag_isoc9x)
+ error ("`[*]' in parameter declaration only allowed in ISO C 9x");
+ }
+end ifc
| parm_declarator '[' expr ']' %prec '.'
{ $$ = build_nt (ARRAY_REF, $1, $3); }
| parm_declarator '[' ']' %prec '.'
@@ -1427,6 +1452,13 @@ notype_declarator:
{ $$ = $2; }
| '*' type_quals notype_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2, $3); }
+ifc
+ | notype_declarator '[' '*' ']' %prec '.'
+ { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
+ if (! flag_isoc9x)
+ error ("`[*]' in parameter declaration only allowed in ISO C 9x");
+ }
+end ifc
| notype_declarator '[' expr ']' %prec '.'
{ $$ = build_nt (ARRAY_REF, $1, $3); }
| notype_declarator '[' ']' %prec '.'
@@ -1509,7 +1541,8 @@ maybecomma:
maybecomma_warn:
/* empty */
| ','
- { if (pedantic) pedwarn ("comma at end of enumerator list"); }
+ { if (pedantic && ! flag_isoc9x)
+ pedwarn ("comma at end of enumerator list"); }
;
component_decl_list:
@@ -1676,6 +1709,8 @@ absdcl1: /* a nonempty absolute declarator */
{ $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
/* ??? It appears we have to support attributes here, however
using prefix_attributes is wrong. */
+ | attributes setattrs absdcl1
+ { $$ = $3; }
;
/* at least one statement, the first of which parses without error. */
@@ -2191,12 +2226,15 @@ label: CASE expr_no_commas ':'
error_with_decl (duplicate, "this is the first default label");
}
position_after_white_space (); }
- | identifier ':'
+ | identifier ':' maybe_attribute
{ tree label = define_label (input_filename, lineno, $1);
stmt_count++;
emit_nop ();
if (label)
- expand_label (label);
+ {
+ expand_label (label);
+ decl_attributes (label, $3, NULL_TREE);
+ }
position_after_white_space (); }
;
OpenPOWER on IntegriCloud