This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for alternate type attribute syntax


Apparently some windowsy compilers allow you to say
"struct __declspec (foo) my_struct".  It seems reasonable for us to support
it, too, especially since this is less ambiguous than the
current support for type attributes.

Mon Jul  6 16:27:12 1998  Jason Merrill  <jason@yorick.cygnus.com>

	* c-parse.in (struct_head, union_head, enum_head): New nonterminals.
	(structsp): Use them.
	* extend.texi (Type Attributes): Document it.

Index: extend.texi
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/extend.texi,v
retrieving revision 1.9
diff -c -p -r1.9 extend.texi
*** extend.texi	1998/05/30 23:29:42	1.9
--- extend.texi	1998/07/06 23:41:01
*************** closing curly brace of a complete enum, 
*** 2015,2020 ****
--- 2015,2023 ----
  @emph{definition} and the @code{packed} attribute only past the closing
  brace of a definition.
  
+ You may also specify attributes between the enum, struct or union
+ tag and the name of the type rather than after the closing brace.
+ 
  @table @code
  @cindex @code{aligned} attribute
  @item aligned (@var{alignment})
Index: c-parse.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-parse.in,v
retrieving revision 1.8
diff -c -p -r1.8 c-parse.in
*** c-parse.in	1998/05/06 04:45:43	1.8
--- c-parse.in	1998/07/06 23:25:03
*************** end ifc
*** 197,202 ****
--- 197,203 ----
  %type <ttype> structsp component_decl_list component_decl_list2
  %type <ttype> component_decl components component_declarator
  %type <ttype> enumlist enumerator
+ %type <ttype> struct_head union_head enum_head
  %type <ttype> typename absdcl absdcl1 type_quals
  %type <ttype> xexpr parms parm identifiers
  
*************** notype_declarator:
*** 1440,1481 ****
  	| IDENTIFIER
  	;
  
  structsp:
! 	  STRUCT identifier '{'
  		{ $$ = start_struct (RECORD_TYPE, $2);
  		  /* Start scope of tag before parsing components.  */
  		}
  	  component_decl_list '}' maybe_attribute 
! 		{ $$ = finish_struct ($<ttype>4, $5, $7); }
! 	| STRUCT '{' component_decl_list '}' maybe_attribute
  		{ $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
! 				      $3, $5);
  		}
! 	| STRUCT identifier
  		{ $$ = xref_tag (RECORD_TYPE, $2); }
! 	| UNION identifier '{'
  		{ $$ = start_struct (UNION_TYPE, $2); }
  	  component_decl_list '}' maybe_attribute
! 		{ $$ = finish_struct ($<ttype>4, $5, $7); }
! 	| UNION '{' component_decl_list '}' maybe_attribute
  		{ $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
! 				      $3, $5);
  		}
! 	| UNION identifier
  		{ $$ = xref_tag (UNION_TYPE, $2); }
! 	| ENUM identifier '{'
  		{ $<itype>3 = suspend_momentary ();
  		  $$ = start_enum ($2); }
  	  enumlist maybecomma_warn '}' maybe_attribute
! 		{ $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
  		  resume_momentary ($<itype>3); }
! 	| ENUM '{'
  		{ $<itype>2 = suspend_momentary ();
  		  $$ = start_enum (NULL_TREE); }
  	  enumlist maybecomma_warn '}' maybe_attribute
! 		{ $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
  		  resume_momentary ($<itype>2); }
! 	| ENUM identifier
  		{ $$ = xref_tag (ENUMERAL_TYPE, $2); }
  	;
  
--- 1441,1503 ----
  	| IDENTIFIER
  	;
  
+ struct_head:
+ 	  STRUCT
+ 		{ $$ = NULL_TREE; }
+ 	| STRUCT attributes
+ 		{ $$ = $2; }
+ 	;
+ 
+ union_head:
+ 	  UNION
+ 		{ $$ = NULL_TREE; }
+ 	| UNION attributes
+ 		{ $$ = $2; }
+ 	;
+ 
+ enum_head:
+ 	  ENUM
+ 		{ $$ = NULL_TREE; }
+ 	| ENUM attributes
+ 		{ $$ = $2; }
+ 	;
+ 
  structsp:
! 	  struct_head identifier '{'
  		{ $$ = start_struct (RECORD_TYPE, $2);
  		  /* Start scope of tag before parsing components.  */
  		}
  	  component_decl_list '}' maybe_attribute 
! 		{ $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
! 	| struct_head '{' component_decl_list '}' maybe_attribute
  		{ $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
! 				      $3, chainon ($1, $5));
  		}
! 	| struct_head identifier
  		{ $$ = xref_tag (RECORD_TYPE, $2); }
! 	| union_head identifier '{'
  		{ $$ = start_struct (UNION_TYPE, $2); }
  	  component_decl_list '}' maybe_attribute
! 		{ $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
! 	| union_head '{' component_decl_list '}' maybe_attribute
  		{ $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
! 				      $3, chainon ($1, $5));
  		}
! 	| union_head identifier
  		{ $$ = xref_tag (UNION_TYPE, $2); }
! 	| enum_head identifier '{'
  		{ $<itype>3 = suspend_momentary ();
  		  $$ = start_enum ($2); }
  	  enumlist maybecomma_warn '}' maybe_attribute
! 		{ $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
  		  resume_momentary ($<itype>3); }
! 	| enum_head '{'
  		{ $<itype>2 = suspend_momentary ();
  		  $$ = start_enum (NULL_TREE); }
  	  enumlist maybecomma_warn '}' maybe_attribute
! 		{ $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
  		  resume_momentary ($<itype>2); }
! 	| enum_head identifier
  		{ $$ = xref_tag (ENUMERAL_TYPE, $2); }
  	;
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]