[hackers] [scc] Fix error related to incorrect parameter declaration || Roberto E. Vargas Caballero
commit cde67f41cb37d1c695d7de0a5100458bcc5de9c1
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Aug 5 09:07:45 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Aug 5 09:07:45 2015 +0200
Fix error related to incorrect parameter declaration
dodcl is called without knowing that the next token
is a valid specifier, so specifier() can return
NULL in the case of parameters. This patch detects
this situation and apply old rule of default int.
Maybe is better to put a flag for it.
diff --git a/cc1/decl.c b/cc1/decl.c
index d6aeaab..6957c38 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -364,7 +364,7 @@ typename(void)
}
static void
-field(Symbol *sym, unsigned sclass, Type *data)
+field(Symbol *sym, int sclass, Type *data)
{
Type *tp = sym->type, *funtp = data;
size_t n = funtp->n.elem;
_AT_@ -384,7 +384,7 @@ field(Symbol *sym, unsigned sclass, Type *data)
}
static void
-parameter(Symbol *sym, unsigned sclass, Type *data)
+parameter(Symbol *sym, int sclass, Type *data)
{
Type *tp = sym->type, *funtp = data;
size_t n = funtp->n.elem;
_AT_@ -415,7 +415,7 @@ parameter(Symbol *sym, unsigned sclass, Type *data)
}
static void
-internal(Symbol *sym, unsigned sclass, Type *data)
+internal(Symbol *sym, int sclass, Type *data)
{
if (!sym->name) {
_AT_@ -431,7 +431,7 @@ internal(Symbol *sym, unsigned sclass, Type *data)
}
static void
-external(Symbol *sym, unsigned sclass, Type *data)
+external(Symbol *sym, int sclass, Type *data)
{
if (!sym->name) {
warn("empty declaration");
_AT_@ -480,25 +480,24 @@ prototype(Symbol *sym)
}
static bool
-dodcl(int rep, void (*fun)(Symbol *, unsigned, Type *), uint8_t ns, Type *type)
+dodcl(int rep, void (*fun)(Symbol *, int, Type *), uint8_t ns, Type *type)
{
- Type *base, *tp = NULL;
- unsigned sclass = 0;
- Symbol *sym = NULL;
+ Type *base;
+ int sclass;
/* FIXME: curctx == PARCTX is incorrect. Structs also
* create new contexts
*/
- /* FIXME: in arguments base can be NULL */
- base = specifier(&sclass);
- if (!base && curctx == OUTCTX) {
+ if ((base = specifier(&sclass)) == NULL) {
+ if (curctx != OUTCTX)
+ unexpected();
warn("type defaults to 'int' in declaration");
- tp = inttype;
+ base = inttype;
}
do {
- sym = declarator(base, ns);
- tp = sym->type;
+ Symbol *sym = declarator(base, ns);
+ Type *tp = sym->type;
switch (sclass) {
case REGISTER:
Received on Wed Aug 05 2015 - 20:09:42 CEST
This archive was generated by hypermail 2.3.0
: Wed Aug 05 2015 - 20:12:11 CEST