an attempt to improve error correction on unknown type identifiers.
Also, a minor fix to ival.g
This commit is contained in:
parent
b53309f9f6
commit
1c85c44fad
5 changed files with 28 additions and 6 deletions
|
@ -68,7 +68,8 @@ decl_specifiers /* non-empty */ (register struct decspecs *ds;)
|
|||
:
|
||||
[
|
||||
other_specifier(ds)+
|
||||
[%prefer /* the thin ice in R.M. 11.1 */
|
||||
[%if (DOT != IDENTIFIER || AHEAD == IDENTIFIER)
|
||||
/* the thin ice in R.M. 11.1 */
|
||||
single_type_specifier(ds) other_specifier(ds)*
|
||||
|
|
||||
empty
|
||||
|
@ -121,6 +122,11 @@ type_specifier(struct type **tpp;)
|
|||
single_type_specifier(register struct decspecs *ds;):
|
||||
TYPE_IDENTIFIER /* this includes INT, CHAR, etc. */
|
||||
{idf2type(dot.tk_idf, &ds->ds_type);}
|
||||
|
|
||||
IDENTIFIER
|
||||
{error("%s is not a type identifier", dot.tk_idf->id_text);
|
||||
ds->ds_type = error_type;
|
||||
}
|
||||
|
|
||||
struct_or_union_specifier(&ds->ds_type)
|
||||
|
|
||||
|
|
|
@ -96,7 +96,7 @@ postfixed(struct expr **expp;)
|
|||
unary(register struct expr **expp;)
|
||||
{struct type *tp; int oper;}
|
||||
:
|
||||
%if (first_of_type_specifier(AHEAD))
|
||||
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
||||
cast(&tp) unary(expp)
|
||||
{ ch7cast(expp, CAST, tp);
|
||||
(*expp)->ex_flags |= EX_CAST;
|
||||
|
@ -114,7 +114,7 @@ size_of(register struct expr **expp;)
|
|||
{struct type *tp;}
|
||||
:
|
||||
SIZEOF
|
||||
[%if (first_of_type_specifier(AHEAD))
|
||||
[%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
|
||||
cast(&tp)
|
||||
{
|
||||
*expp = intexpr(size_of_type(tp, "type"), INT);
|
||||
|
|
|
@ -193,6 +193,10 @@ gen_tphead(tpp, nest)
|
|||
register struct e_stack *p;
|
||||
register struct sdef *sd;
|
||||
|
||||
if (tpp && *tpp == error_type) {
|
||||
gen_error = 1;
|
||||
return 0;
|
||||
}
|
||||
if (gen_error) return tpp;
|
||||
p = new_e_stack();
|
||||
p->next = p_stack;
|
||||
|
@ -217,6 +221,13 @@ gen_tphead(tpp, nest)
|
|||
sd = next_field(sd, p);
|
||||
}
|
||||
#endif
|
||||
if (! sd) {
|
||||
/* something wrong with this struct */
|
||||
gen_error = 1;
|
||||
p_stack = p->next;
|
||||
free_e_stack(p);
|
||||
return 0;
|
||||
}
|
||||
p->s_def = sd;
|
||||
if (AHEAD != '{' && aggregate_type(sd->sd_type)) {
|
||||
return gen_tphead(&(sd->sd_type), 1);
|
||||
|
@ -236,7 +247,10 @@ gen_tpmiddle()
|
|||
register struct sdef *sd;
|
||||
register struct e_stack *p = p_stack;
|
||||
|
||||
if (gen_error) if (p) return p->s_tpp; else return 0;
|
||||
if (gen_error) {
|
||||
if (p) return p->s_tpp;
|
||||
return 0;
|
||||
}
|
||||
again:
|
||||
tp = *(p->s_tpp);
|
||||
switch(tp->tp_fund) {
|
||||
|
|
|
@ -140,7 +140,7 @@ external_definition
|
|||
;
|
||||
|
||||
ext_decl_specifiers(struct decspecs *ds;) :
|
||||
%prefer /* the thin ice in R.M. 11.1 */
|
||||
%if (DOT != IDENTIFIER || AHEAD == IDENTIFIER) /* the thin ice in R.M. 11.1 */
|
||||
decl_specifiers(ds)
|
||||
|
|
||||
empty
|
||||
|
|
|
@ -358,7 +358,9 @@ compound_statement:
|
|||
{
|
||||
stack_level();
|
||||
}
|
||||
[%while (AHEAD != ':') /* >>> conflict on TYPE_IDENTIFIER */
|
||||
[%while ((DOT != IDENTIFIER && AHEAD != ':') ||
|
||||
(DOT == IDENTIFIER && AHEAD == IDENTIFIER))
|
||||
/* >>> conflict on TYPE_IDENTIFIER, IDENTIFIER */
|
||||
declaration
|
||||
]*
|
||||
[%persistent
|
||||
|
|
Loading…
Reference in a new issue