shithub: scc

Download patch

ref: da3fdf4fee4a266d3e69ea569659cb0268cb7d28
parent: bfaf7a4d88aefd1c269ae83563de4b78511cc648
author: FRIGN <[email protected]>
date: Tue May 17 12:27:50 EDT 2016

Emit function prototypes

so we actually know which functions we are actually calling in the IR.
Also update the tests accordingly.

"Mientras se gana algo no se pierde nada."
 - Miguel de Cervantes Saavedra

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -847,6 +847,7 @@
 	 * against GLOBALCTX+1
 	 */
 	if (curctx != GLOBALCTX+1 || yytoken == ';') {
+		emit(ODECL, sym);
 		/*
 		 * avoid non used warnings in prototypes
 		 */
--- a/cc1/tests/test001.c
+++ b/cc1/tests/test001.c
@@ -3,6 +3,7 @@
 description: Basic hello world test
 error:
 output:
+X4	I	F	"printf
 G6	I	F	"main
 {
 \
--- a/cc1/tests/test029.c
+++ b/cc1/tests/test029.c
@@ -6,8 +6,10 @@
           moment f will not be expanded because the macro definition is
           a function alike macro, and in this case there is no arguments.
 error:
-test029.c:34: error: redefinition of 'f1'
-test029.c:35: error: 'f' undeclared
+test029.c:31: warning: expression without side effects
+test029.c:36: error: redefinition of 'f1'
+test029.c:37: error: 'f' undeclared
+test029.c:37: warning: expression without side effects
 output:
 G3	I	F	"f1
 {
--- a/cc1/tests/test034.c
+++ b/cc1/tests/test034.c
@@ -3,10 +3,11 @@
 name: TEST034
 description: Basic test for incomplete structures
 error:
-test034.c:44: error: declared variable 'bar' of incomplete type
-test034.c:44: error: redeclaration of 'bar'
+test034.c:45: error: declared variable 'bar' of incomplete type
+test034.c:45: error: redeclaration of 'bar'
 output:
 X3	S2	"x
+X5	I	F	"foo
 G6	I	F	"main
 {
 \
--- a/cc1/tests/test038.c
+++ b/cc1/tests/test038.c
@@ -3,12 +3,13 @@
 name: TEST038
 description: Basic test for tentative definitions
 error:
-test038.c:43: error: redeclaration of 'x'
+test038.c:44: error: redeclaration of 'x'
 output:
 G1	I	"x
 G1	I	"x	(
 	#I0
 )
+X3	I	F	"main
 G5	P	F	"foo
 {
 \
--- a/cc1/tests/test041.c
+++ b/cc1/tests/test041.c
@@ -2,12 +2,13 @@
 name: TEST041
 description: Test for bug parsing ternary operators
 error:
-test041.c:48: error: type mismatch in conditional expression
-test041.c:48: error: incompatible types when assigning
-test041.c:49: error: used struct/union type value where scalar is required
-test041.c:50: warning: 'i' defined but not used
-test041.c:50: warning: 'foo' defined but not used
-test041.c:50: warning: 's' defined but not used
+test041.c:49: error: type mismatch in conditional expression
+test041.c:49: error: incompatible types when assigning
+test041.c:50: error: used struct/union type value where scalar is required
+test041.c:50: warning: expression without side effects
+test041.c:51: warning: 'i' defined but not used
+test041.c:51: warning: 'foo' defined but not used
+test041.c:51: warning: 's' defined but not used
 output:
 G2	I	F	"main
 {
--- a/cc1/tests/test042.c
+++ b/cc1/tests/test042.c
@@ -2,11 +2,12 @@
 name: TEST042
 description: Test for bug parsing ternary operators
 error:
-test042.c:17: error: bad type convertion requested
+test042.c:18: error: bad type convertion requested
 output:
 G2	I	F	"main
 {
 \
+X4	0	F	"f
 */
 
 int