Преглед изворни кода

be a bit more tolerant about external definitions

ceriel пре 33 година
родитељ
комит
893f514974

+ 1 - 1
lang/cem/cemcom.ansi/.distr

@@ -31,7 +31,7 @@ declar.g
 declar.str
 declarator.c
 decspecs.c
-decspecs.str
+decspecs.h
 def.str
 domacro.c
 dumpidf.c

+ 3 - 4
lang/cem/cemcom.ansi/Makefile

@@ -103,12 +103,12 @@ GOBJ =	char.o symbol2str.o next.o
 # The Sun-3 version is faster when the text-size exceeds 180K! ARRGH
 EXTRA_O =
 
-STRSRC = code.str declar.str decspecs.str def.str expr.str field.str \
+STRSRC = code.str declar.str def.str expr.str field.str \
 	estack.str util.str proto.str replace.str \
 	idf.str macro.str stack.str stmt.str struct.str switch.str type.str \
 	l_brace.str l_state.str l_outdef.str
 # generated source files
-GHSTRSRC = code.h declar.h decspecs.h def.h expr.h field.h \
+GHSTRSRC = code.h declar.h def.h expr.h field.h \
 	estack.h util.h proto.h replace.h \
 	idf.h macro.h stack.h stmt.h struct.h switch.h type.h \
 	l_brace.h l_state.h l_outdef.h
@@ -124,7 +124,7 @@ GHSRC =	botch_free.h dataflow.h debug.h density.h errout.h \
 
 HSRC = LLlex.h align.h arith.h assert.h atw.h class.h \
 	 input.h interface.h label.h level.h mes.h sizes.h specials.h \
-	 file_info.h tokenname.h l_em.h l_lint.h
+	 file_info.h tokenname.h l_em.h l_lint.h decspecs.h
 
 HFILES = $(HSRC) $(GHSRC) $(GHSTRSRC)
 
@@ -228,7 +228,6 @@ next.c:	make.next $(STRSRC)
 
 code.h:		make.allocd
 declar.h:	make.allocd
-decspecs.h:	make.allocd
 def.h:		make.allocd
 expr.h:		make.allocd
 field.h:	make.allocd

+ 4 - 0
lang/cem/cemcom.ansi/code.c

@@ -53,7 +53,9 @@ extern arith NewLocal();	/* util.c	*/
 /* global function info */
 char *func_name;
 struct type *func_type;
+#ifdef LINT
 int func_notypegiven;
+#endif
 
 #ifdef USE_TMP
 static int	tmp_id;
@@ -264,7 +266,9 @@ begin_proc(ds, idf)		/* to be called when entering a procedure */
 	else {
 		func_type = def->df_type->tp_up;
 	}
+#ifdef LINT
 	func_notypegiven = ds->ds_notypegiven;
+#endif
 	func_size = ATW(func_type->tp_size);
 	sp_occurred[SP_SETJMP] = 0;
 

+ 0 - 5
lang/cem/cemcom.ansi/decspecs.c

@@ -30,11 +30,6 @@ do_decspecs(ds)
 	
 	ASSERT(level != L_FORMAL1);
 	
-	/*
-	if (ds->ds_notypegiven && !ds->ds_sc_given)
-		strict("data definition lacking type or storage class");
-	*/
-
 	if (	level == L_GLOBAL &&
 		(ds->ds_sc == AUTO || ds->ds_sc == REGISTER)
 	)	{

+ 21 - 0
lang/cem/cemcom.ansi/decspecs.h

@@ -0,0 +1,21 @@
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+/* $Header$ */
+/* DECLARATION SPECIFIER DEFINITION */
+
+struct decspecs	{
+	struct decspecs *next;
+	struct type *ds_type;	/* single type */
+	int ds_notypegiven;	/* set if type not given explicitly */
+	int ds_typedef;		/* 1 if type was a user typedef */
+	int ds_sc_given;	/* 1 if the st. class is explicitly given */
+	int ds_sc;		/* storage class, given or implied */
+	int ds_size;		/* LONG, SHORT or 0 */
+	int ds_unsigned;	/* SIGNED, UNSIGNED or 0 */
+	int ds_typequal;	/* type qualifiers - see type.str */
+};
+
+extern struct type *qualifier_type();
+extern struct decspecs null_decspecs;

+ 17 - 17
lang/cem/cemcom.ansi/program.g

@@ -141,24 +141,10 @@ external_definition
 	}
 	[ %if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
 		decl_specifiers(&Ds)
-		[
-			declarator(&Dc)
-			{
-				declare_idf(&Ds, &Dc, level);
-#ifdef	LINT
-				lint_ext_def(Dc.dc_idf, Ds.ds_sc);
-#endif	LINT
-			}
-			[
-				function(&Ds, &Dc)
-			|
-				non_function(&Ds, &Dc)
-			]
-		|
-			';'
-		]
 	|
 		{do_decspecs(&Ds);}
+	]
+	[
 		declarator(&Dc)
 		{
 			declare_idf(&Ds, &Dc, level);
@@ -166,7 +152,21 @@ external_definition
 			lint_ext_def(Dc.dc_idf, Ds.ds_sc);
 #endif	LINT
 		}
-		function(&Ds, &Dc)
+		[
+			function(&Ds, &Dc)
+		|
+			{	if (! Ds.ds_sc_given && Ds.ds_notypegiven) {
+					strict("declaration specifiers missing");
+				}
+			}
+			non_function(&Ds, &Dc)
+		]
+	|
+		{	if (! Ds.ds_sc_given && Ds.ds_notypegiven) {
+				strict("declaration missing");
+			}
+		}
+		';'
 	]
 	{remove_declarator(&Dc); flush_strings(); }
 ;