(C++) yet another attribute parsing patch

Jason Merrill jason@cygnus.com
Thu Apr 15 05:51:00 GMT 1999


Fixes updated attrib1.C.

1999-04-15  Jason Merrill  <jason@yorick.cygnus.com>

	* parse.y (after_type_declarator_intern): New nonterminal.
	(after_type_declarator): Use it.
	(direct_after_type_declarator): Likewise.  Move above 
	nonnested_type to fix reduce/reduce conflict resolution.
	(declmods): Reducing from just 'attributes' has EMPTY precedence.
	* Makefile.in (CONFLICTS): Update.

Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/parse.y,v
retrieving revision 1.115
diff -c -p -r1.115 parse.y
*** parse.y	1999/04/12 23:57:29	1.115
--- parse.y	1999/04/15 12:50:10
*************** empty_parms ()
*** 205,210 ****
--- 205,211 ----
  
  %type <ttype> declarator notype_declarator after_type_declarator
  %type <ttype> notype_declarator_intern absdcl_intern
+ %type <ttype> after_type_declarator_intern
  %type <ttype> direct_notype_declarator direct_after_type_declarator
  %type <itype> components notype_components
  %type <ttype> component_decl component_decl_1 
*************** declmods:
*** 1778,1784 ****
  		  TREE_STATIC ($$) = TREE_STATIC ($1); }
  	| declmods attributes
  		{ $$ = hash_tree_cons ($2, NULL_TREE, $1); }
! 	| attributes
  		{ $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
  	;
  
--- 1779,1785 ----
  		  TREE_STATIC ($$) = TREE_STATIC ($1); }
  	| declmods attributes
  		{ $$ = hash_tree_cons ($2, NULL_TREE, $1); }
! 	| attributes  %prec EMPTY
  		{ $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
  	;
  
*************** maybe_parmlist:
*** 2731,2753 ****
  	;
  
  /* A declarator that is allowed only after an explicit typespec.  */
  /* may all be followed by prec '.' */
  after_type_declarator:
! 	  '*' nonempty_cv_qualifiers after_type_declarator  %prec UNARY
  		{ $$ = make_pointer_declarator ($2.t, $3); }
! 	| '&' nonempty_cv_qualifiers after_type_declarator  %prec UNARY
  		{ $$ = make_reference_declarator ($2.t, $3); }
! 	| '*' after_type_declarator  %prec UNARY
  		{ $$ = make_pointer_declarator (NULL_TREE, $2); }
! 	| '&' after_type_declarator  %prec UNARY
  		{ $$ = make_reference_declarator (NULL_TREE, $2); }
! 	| ptr_to_mem cv_qualifiers after_type_declarator
  		{ tree arg = make_pointer_declarator ($2, $3);
  		  $$ = build_parse_node (SCOPE_REF, $1, arg);
  		}
  	| direct_after_type_declarator
  	;
  
  nonnested_type:
  	  type_name  %prec EMPTY
  		{
--- 2732,2781 ----
  	;
  
  /* A declarator that is allowed only after an explicit typespec.  */
+ 
+ after_type_declarator_intern:
+ 	  after_type_declarator
+ 	| attributes after_type_declarator
+                 {
+ 		  /* Provide support for '(' attributes '*' declarator ')'
+ 		     etc */
+ 		  $$ = decl_tree_cons ($1, $2, NULL_TREE);
+ 		}
+ 	;
+ 
  /* may all be followed by prec '.' */
  after_type_declarator:
! 	  '*' nonempty_cv_qualifiers after_type_declarator_intern  %prec UNARY
  		{ $$ = make_pointer_declarator ($2.t, $3); }
! 	| '&' nonempty_cv_qualifiers after_type_declarator_intern  %prec UNARY
  		{ $$ = make_reference_declarator ($2.t, $3); }
! 	| '*' after_type_declarator_intern  %prec UNARY
  		{ $$ = make_pointer_declarator (NULL_TREE, $2); }
! 	| '&' after_type_declarator_intern  %prec UNARY
  		{ $$ = make_reference_declarator (NULL_TREE, $2); }
! 	| ptr_to_mem cv_qualifiers after_type_declarator_intern
  		{ tree arg = make_pointer_declarator ($2, $3);
  		  $$ = build_parse_node (SCOPE_REF, $1, arg);
  		}
  	| direct_after_type_declarator
  	;
  
+ direct_after_type_declarator:
+ 	  direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt  %prec '.'
+ 		{ $$ = make_call_declarator ($$, $2, $3, $4); }
+ 	| direct_after_type_declarator '[' nonmomentary_expr ']'
+ 		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
+ 	| direct_after_type_declarator '[' ']'
+ 		{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+ 	| '(' after_type_declarator_intern ')'
+ 		{ $$ = $2; }
+ 	| nested_name_specifier type_name  %prec EMPTY
+ 		{ push_nested_class ($1, 3);
+ 		  $$ = build_parse_node (SCOPE_REF, $$, $2);
+ 		  TREE_COMPLEXITY ($$) = current_class_depth; }
+ 	| type_name  %prec EMPTY
+ 	;
+ 
  nonnested_type:
  	  type_name  %prec EMPTY
  		{
*************** complete_type_name:
*** 2779,2800 ****
  nested_type:
  	  nested_name_specifier type_name  %prec EMPTY
  		{ $$ = get_type_decl ($2); }
- 	;
- 
- direct_after_type_declarator:
- 	  direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt  %prec '.'
- 		{ $$ = make_call_declarator ($$, $2, $3, $4); }
- 	| direct_after_type_declarator '[' nonmomentary_expr ']'
- 		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
- 	| direct_after_type_declarator '[' ']'
- 		{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
- 	| '(' after_type_declarator ')'
- 		{ $$ = $2; }
- 	| nested_name_specifier type_name  %prec EMPTY
- 		{ push_nested_class ($1, 3);
- 		  $$ = build_parse_node (SCOPE_REF, $$, $2);
- 		  TREE_COMPLEXITY ($$) = current_class_depth; }
- 	| type_name  %prec EMPTY
  	;
  
  /* A declarator allowed whether or not there has been
--- 2807,2812 ----
Index: Makefile.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/Makefile.in,v
retrieving revision 1.50
diff -c -p -r1.50 Makefile.in
*** Makefile.in	1999/04/02 15:35:56	1.50
--- Makefile.in	1999/04/15 12:50:10
*************** parse.o : $(PARSE_C) $(CONFIG_H) $(CXX_T
*** 225,231 ****
  	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
    `echo $(PARSE_C) | sed 's,^\./,,'`
  
! CONFLICTS = expect 36 shift/reduce conflicts and 42 reduce/reduce conflicts.
  $(PARSE_H) : $(PARSE_C)
  $(PARSE_C) : $(srcdir)/parse.y
  	@echo $(CONFLICTS)
--- 225,231 ----
  	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
    `echo $(PARSE_C) | sed 's,^\./,,'`
  
! CONFLICTS = expect 30 shift/reduce conflicts and 42 reduce/reduce conflicts.
  $(PARSE_H) : $(PARSE_C)
  $(PARSE_C) : $(srcdir)/parse.y
  	@echo $(CONFLICTS)


More information about the Gcc-patches mailing list