🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Sat, 25 Jul 1992 00:47
GCC 2.2.2 doesn't diagnose empty declarations in old-style functions
#199
Author: Paul Eggert
Date: Sat, 25 Jul 1992 00:47
106 lines
3268 bytes
GCC doesn't issue a diagnostic for the empty struct declaration in the
program

	int main(c,v)
		struct s {int a;};
		int c;
		char **v;
	{ return 0; }
	
even though the program violates the following constraint, taken from ANSI
X3.159-1989, section 3.7.1, page 83, lines 7-8:

	If the declarator includes an identifier list, each declaration in the
	declaration list shall have at least one declarator ...

Here is a patch.

Sat Jul 25 00:41:12 1992  Paul Eggert  (eggert@twinsun.com)

	* c-parse.y (datadecl): Diagnose empty declarations in old-style
	function headers.
	* c-decl.c (shadow_tag_warned): New function.

===================================================================
RCS file: c-parse.y,v
retrieving revision 2.2
diff -c -r2.2 c-parse.y
*** c-parse.y	1992/05/21 18:08:40	2.2
--- c-parse.y	1992/07/25 00:04:28
***************
*** 581,587 ****
  		  declspec_stack = TREE_CHAIN (declspec_stack);
  		  resume_momentary ($2); }
  	| typed_declspecs ';'
! 		{ shadow_tag ($1); }
  	| declmods ';'
  		{ pedwarn ("empty declaration"); }
  	;
--- 581,588 ----
  		  declspec_stack = TREE_CHAIN (declspec_stack);
  		  resume_momentary ($2); }
  	| typed_declspecs ';'
! 		{ shadow_tag_warned ($1, 1);
! 		  pedwarn ("empty declaration"); }
  	| declmods ';'
  		{ pedwarn ("empty declaration"); }
  	;
===================================================================
RCS file: c-decl.c,v
retrieving revision 2.2.2.1
diff -c -r2.2.2.1 c-decl.c
*** c-decl.c	1992/06/21 05:34:02	2.2.2.1
--- c-decl.c	1992/07/25 00:13:45
***************
*** 388,393 ****
--- 388,394 ----
  static tree grokparms (), grokdeclarator ();
  tree pushdecl ();
  tree builtin_function ();
+ void shadow_tag_warned ();
  
  static tree lookup_tag ();
  static tree lookup_tag_reverse ();
***************
*** 2706,2713 ****
  shadow_tag (declspecs)
       tree declspecs;
  {
    int found_tag = 0;
-   int warned = 0;
    register tree link;
  
    pending_invalid_xref = 0;
--- 2707,2721 ----
  shadow_tag (declspecs)
       tree declspecs;
  {
+   shadow_tag_warned (declspecs, 0);
+ }
+ 
+ void
+ shadow_tag_warned (declspecs, warned)
+      tree declspecs;
+      int warned;
+ {
    int found_tag = 0;
    register tree link;
  
    pending_invalid_xref = 0;
***************
*** 2728,2734 ****
  
  	  if (name == 0)
  	    {
! 	      if (code != ENUMERAL_TYPE)	/* Empty unnamed enum OK */
  		{
  		  pedwarn ("unnamed struct/union that defines no instances");
  		  warned = 1;
--- 2736,2742 ----
  
  	  if (name == 0)
  	    {
! 	      if (!warned && code != ENUMERAL_TYPE) /* Empty unnamed enum OK */
  		{
  		  pedwarn ("unnamed struct/union that defines no instances");
  		  warned = 1;
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads