commit - c591ae72dc1bd77c12a0563030c9a2e539ffe09f
commit + 2534b579b7fcf1f22729331399e0898ff4f52dd7
blob - 88fe4d77b4bdfda32b836e84ffe97180502b1cea
blob + 82f180a8cba0e5563641e4baed24a853cd05738c
--- MyMakefile
+++ MyMakefile
CFLAGS += -ansi -Wall -Wno-deprecated-non-prototype -Wno-implicit-int
## Default C Preprocssor Flags
-CPPFLAGS ?=
+CPPFLAGS ?= -D_GNU_SOURCE -D_BSD_SOURCE
.EXPORTS: CC YACC CFLAGS CPPFLAGS
blob - 7ef55d5088264082583f2cf2d5dc2c15bb876ce1
blob + a22d12933faf8a16999616fdbcf2587d88a479c9
--- cc/cc1/MyMakefile
+++ cc/cc1/MyMakefile
(echo '=== IR ==='; cat test.ir; echo '=== ASM ==='; cat test.asm) | less
cc1: lex.o parse.o gen.o main.o dt.o
- ${CC} -o $@ $^ ${CFLAGS}
+ ${CC} -o $@ $^ ${CFLAGS} ${CPPFLAGS}
parse.o y.tab.h: parse.y
${YACC} ${YFLAGS} parse.y
- ${CC} -c -o ${.OBJDIR}/parse.o y.tab.c ${CFLAGS}
+ ${CC} -c -o ${.OBJDIR}/parse.o y.tab.c ${CFLAGS} ${CPPFLAGS}
rm -f y.tab.c
lex.o: cc1.h y.tab.h
blob - ef0df826f47b0b5403d2710e1d9696c46e65569a
blob + 229460f5e3be502f6a3ba3609d88521be9d665de
--- cc/cc1/cc1.h
+++ cc/cc1/cc1.h
};
enum irc_type {
- IT_BYTE, // char
- IT_WORD, // short, int
- IT_DWORD, // long
- IT_QWORD, // (unused for now)
+ IT_BYTE, /* char */
+ IT_WORD, /* short, int */
+ IT_DWORD, /* long */
+ IT_QWORD, /* (unused for now) */
};
extern struct scope gscope, fscope;
extern reg, linenum;
extern struct expr *cast ();
-#endif // FILE_CC1_H
+#endif /* FILE_CC1_H */
blob - c00a601f0dafa2a9036540c91a42b350662f8570
blob + 683084b71918edd127ff667324b85e1720ffa683
--- cc/cc1/gen.c
+++ cc/cc1/gen.c
print_dt (dt->inner);
break;
case DT_FUNC:
- // TODO
+ /* TODO */
abort ();
break;
}
break;
case SC_EXTERN:
ext = 1;
- // fallthrough
+ /* fallthrough */
case SC_STATIC:
pub = 0;
break;
switch (sym->init.type) {
case IN_EX:
printf (" = %d", eval_expr (sym->init.ex));
- // fallthrough
+ /* fallthrough */
case IN_NONE:
printf (";\n");
break;
printf ("\n");
}
- // TODO: define static variables
+ /* TODO: define static variables */
for (st = fn->body; *st != NULL; ++st) {
gen_stmt (*st);
blob - 06510e0eb093d5955e81d84501fdfcd238c82d34
blob + 76ecbe9ebf82c667e1cca3f71611532e76e74743
--- cc/cc1/lex.c
+++ cc/cc1/lex.c
struct token lval;
struct scope gscope, fscope;
-// MISC
+/* MISC */
yyerror (msg)
char *msg;
return isalnum (ch) || ch == '_';
}
-// LEXER
+/* LEXER */
yylex ()
{
}
}
}
- // fallthrough
+ /* fallthrough */
default:
return yyerror ("invalid input");
}
blob - 6a5acd0471fec6f5390f1302128599d8dae660a3
blob + a4a1a9af67d5239c661489426447d5d97f51f037
--- cc/cc1/parse.y
+++ cc/cc1/parse.y
declarator : declarator '(' ')' { $$.type = DL_FUNC; $$.dl = new (struct declarator); *$$.dl = $1; }
| declarator '(' ident_list ')' { $$.type = DL_FUNCDEF; $$.def.dl = new (struct declarator); *$$.def.dl = $1; $$.def.il = $3; }
- //| declarator '[' const_expr ']'
+ /*| declarator '[' const_expr ']' */
| declarator1 { $$ = $1; }
;
abstdecl1 : '(' abstdecl1 ')' { $$ = $2; }
| '*' abstdecl { $$.type = DL_PTR; $$.dl = new (struct declarator); *$$.dl = $2; }
- //| abstdecl '(' ')' { $$.type = DL_FUNC; $$.dl = new (struct declarator); *$$.dl = $1; }
- //| abstdecl '[' const_expr ']'
+ /*| abstdecl '(' ')' { $$.type = DL_FUNC; $$.dl = new (struct declarator); *$$.dl = $1; } */
+ /*| abstdecl '[' const_expr ']' */
;
initializer : '=' expression { $$.type = IN_EX; $$.ex = $2; }
fn->vhead = vtail = NULL;
fn->body = stmts;
- // declare arguments as implicit int
+ /* declare arguments as implicit int */
for (il = dl->def.il; il != NULL; il = il->next) {
if (find_sym (fscope.vars, il->ident) != NULL)
yyerror ("redeclaration of argument");
atail = sym;
}
- // set the correct data types for arguments
+ /* set the correct data types for arguments */
for (dd = args; dd != NULL; dd = dd->next) {
if (dd->d.sc != SC_NONE)
yyerror ("invalid storage class for function argument");
}
}
- // declare variables
+ /* declare variables */
for (dd = vars; dd != NULL; dd = dd->next) {
base = resolve_type (&dd->d.ts);
for (di = dd->d.head; di != NULL; di = di->next) {