Bugfix for syntax error in gcc/c-parse.y in MPLAB C32 v1.05 source code

Author
modulem
Starting Member
  • Total Posts : 55
  • Reward points : 0
  • Joined: 2008/10/10 09:20:46
  • Location: NY, NY
  • Status: offline
2009/04/13 09:14:11 (permalink)
0

Bugfix for syntax error in gcc/c-parse.y in MPLAB C32 v1.05 source code

Hi all:

I compiled the source code for v1.05 (downloaded from http://www.microchip.com/Microchip.WWW.SecureSoftwareList/secsoftwaredownload.aspx?device=en023073&lang=en&ReturnURL=http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023073#) by following pburgess's instructions here: http://www.microchip.com/forums/fb.aspx?m=372663.

While running "make all," I ran into the following error:


gcc -c -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-error -DHAVE_CONFIG_H -I. -I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include c-parse.c -o c-parse.o
gcc: c-parse.c: No such file or directory
gcc: no input files
make[1]: *** [c-parse.o] Error 1
make[1]: Leaving directory `/home/bryant/pic32mx-cc-1.05/cross-build/gcc'
make: *** [all-gcc] Error 2


The file c-parse.c, which is necessary for this phase of the compilation, did not exist. It is supposed to be generated by bison from $SRCDIR/gcc/c-parse.y:


bryant@nfkb:~$ bison -o c-parse.c c-parse.y
c-parse.y:1650.19-20: $$ for the midrule at $4 of `structsp_attr' has no declared type
c-parse.y:1661.19-20: $$ for the midrule at $4 of `structsp_attr' has no declared type
c-parse.y:1670.19-20: $$ for the midrule at $4 of `structsp_attr' has no declared type
c-parse.y:1675.19-20: $$ for the midrule at $3 of `structsp_attr' has no declared type


This hiccup can be fixed by applying the following patch to c-parse.y:

--- c-parse.y	2009-04-13 12:09:58.000000000 -0400
+++ c-parse.y.new 2009-04-13 12:09:33.000000000 -0400
@@ -1647,7 +1647,7 @@

structsp_attr:
struct_head identifier '{'
- { $$ = start_struct (RECORD_TYPE, $2);
+ { $<ttype>$ = start_struct (RECORD_TYPE, $2);
/* Start scope of tag before parsing components. */
}
component_decl_list '}' maybe_attribute
@@ -1658,7 +1658,7 @@
nreverse ($3), chainon ($1, $5));
}
| union_head identifier '{'
- { $$ = start_struct (UNION_TYPE, $2); }
+ { $<ttype>$ = start_struct (UNION_TYPE, $2); }
component_decl_list '}' maybe_attribute
{ $$ = finish_struct ($<ttype>4, nreverse ($5),
chainon ($1, $7)); }
@@ -1667,12 +1667,12 @@
nreverse ($3), chainon ($1, $5));
}
| enum_head identifier '{'
- { $$ = start_enum ($2); }
+ { $<ttype>$ = start_enum ($2); }
enumlist maybecomma_warn '}' maybe_attribute
{ $$ = finish_enum ($<ttype>4, nreverse ($5),
chainon ($1, $8)); }
| enum_head '{'
- { $$ = start_enum (NULL_TREE); }
+ { $<ttype>$ = start_enum (NULL_TREE); }
enumlist maybecomma_warn '}' maybe_attribute
{ $$ = finish_enum ($<ttype>3, nreverse ($4),
chainon ($1, $7)); }


Re-invoke bison on c-parse.y:


bryant@nfkb:~$ bison -o c-parse.c c-parse.y
bryant@nfkb:~$


And continue on with your compilation.


Enjoy,
Bryant
#1

3 Replies Related Threads

    JasonK
    Moderator
    • Total Posts : 3381
    • Reward points : 0
    • Joined: 2003/11/14 09:49:40
    • Location: Microchip Technology in Arizona, USA
    • Status: offline
    RE: Bugfix for syntax error in gcc/c-parse.y in MPLAB C32 v1.05 source code 2009/04/13 09:54:15 (permalink)
    0
    Hey Bryant,

    Thanks for the proposed patch. I noticed that you also started a thread over on the SourceForge project. Do you know if the build script works for you after applying this patch?
    post edited by JasonK - 2009/04/13 09:57:17

    Jason Kajita
     Follow me on Twitter
    http://support.microchip.com for urgent questions
    #2
    modulem
    Starting Member
    • Total Posts : 55
    • Reward points : 0
    • Joined: 2008/10/10 09:20:46
    • Location: NY, NY
    • Status: offline
    RE: Bugfix for syntax error in gcc/c-parse.y in MPLAB C32 v1.05 source code 2009/04/13 15:12:57 (permalink)
    0
    Hm,

    I just remembered that gcc/c-parse.y itself is generated from a template (gcc/c-parse.in) by gcc/Makefile:


    c-parse.c: c-parse.y
    -$(BISON) $(BISONFLAGS) -o $@ $<

    c-parse.y: c-parse.in
    echo '/*WARNING: This file is automatically generated!*/' >tmp-c-parse.y
    sed -e "/^@@ifobjc.*/,/^@@end_ifobjc.*/d" \
    -e "/^@@ifc.*/d" -e "/^@@end_ifc.*/d" $< >>tmp-c-parse.y
    $(SHELL) $(srcdir)/move-if-change tmp-c-parse.y $@


    Seems like bison's error output was suppressed in the Makefile, which is why the build process choked on c-parse.c, not c-parse.in.


    At any rate, I think it would be more appropriate to patch against the template, so here's an updated patch for c-parse.in:


    --- ./gcc/c-parse.in 2007-04-04 18:19:55.000000000 -0400
    +++ ./gcc/c-parse.in.new 2009-04-13 13:18:09.000000000 -0400
    @@ -1730,7 +1730,7 @@

    structsp_attr:
    struct_head identifier '{'
    - { $$ = start_struct (RECORD_TYPE, $2);
    + { $<ttype>$ = start_struct (RECORD_TYPE, $2);
    /* Start scope of tag before parsing components. */
    }
    component_decl_list '}' maybe_attribute
    @@ -1741,7 +1741,7 @@
    nreverse ($3), chainon ($1, $5));
    }
    | union_head identifier '{'
    - { $$ = start_struct (UNION_TYPE, $2); }
    + { $<ttype>$ = start_struct (UNION_TYPE, $2); }
    component_decl_list '}' maybe_attribute
    { $$ = finish_struct ($<ttype>4, nreverse ($5),
    chainon ($1, $7)); }
    @@ -1750,12 +1750,12 @@
    nreverse ($3), chainon ($1, $5));
    }
    | enum_head identifier '{'
    - { $$ = start_enum ($2); }
    + { $<ttype>$ = start_enum ($2); }
    enumlist maybecomma_warn '}' maybe_attribute
    { $$ = finish_enum ($<ttype>4, nreverse ($5),
    chainon ($1, $8)); }
    | enum_head '{'
    - { $$ = start_enum (NULL_TREE); }
    + { $<ttype>$ = start_enum (NULL_TREE); }
    enumlist maybecomma_warn '}' maybe_attribute
    { $$ = finish_enum ($<ttype>3, nreverse ($4),
    chainon ($1, $7)); }



    ORIGINAL: JasonK

    Hey Bryant,

    Thanks for the proposed patch. I noticed that you also started a thread over on the SourceForge project. Do you know if the build script works for you after applying this patch?


    I apologize for starting more than one thread -- when I submitted the post to the SF project forum, I had no clear idea of what the solution should be.

    Weird. I just tried the build script, and it worked without a hitch...


    Bryant


    EDIT: Whoa. I didn't realize that you had applied the patch already.
    post edited by modulem - 2009/04/13 15:13:58
    #3
    JasonK
    Moderator
    • Total Posts : 3381
    • Reward points : 0
    • Joined: 2003/11/14 09:49:40
    • Location: Microchip Technology in Arizona, USA
    • Status: offline
    RE: Bugfix for syntax error in gcc/c-parse.y in MPLAB C32 v1.05 source code 2009/04/13 15:15:44 (permalink)
    0
    EDIT: Whoa. I didn't realize that you had applied the patch already.

    Yep, I went ahead and committed the change this morning ;-)

    Jason Kajita
     Follow me on Twitter
    http://support.microchip.com for urgent questions
    #4
    Jump to:
    © 2018 APG vNext Commercial Version 4.5