tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] weird error message.


From: shinichiro . h
Subject: Re: [Tinycc-devel] weird error message.
Date: Tue, 16 Jun 2009 04:43:33 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/22.3 (x86_64-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hi,

> I don't know if this is the best way to fix it, but it does cause tcc to
> generate the warning.

Nice! I think this is the right way. I would suggest to handle
volatile as well.

diff --git a/tccgen.c b/tccgen.c
index 942c503..e4b73aa 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3266,6 +3268,7 @@ static void unary(void)
             inc(1, tok);
             next();
         } else if (tok == '.' || tok == TOK_ARROW) {
+            int cv_qual;
             /* field */
             if (tok == TOK_ARROW)
                 indir();
@@ -3275,6 +3278,7 @@ static void unary(void)
             /* expect pointer on structure */
             if ((vtop->type.t & VT_BTYPE) != VT_STRUCT)
                 expect("struct or union");
+            cv_qual = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
             s = vtop->type.ref;
             /* find field */
             tok |= SYM_FIELD;
@@ -3290,6 +3294,7 @@ static void unary(void)
             gen_op('+');
             /* change type to field type, and set to lvalue */
             vtop->type = s->type;
+            vtop->type.t |= cv_qual;
             /* an array is never an lvalue */
             if (!(vtop->type.t & VT_ARRAY)) {
                 vtop->r |= lvalue_type(vtop->type.t);

In this way, you can produce warning for another case:

struct somestruct{
      int i;
};
main(){
      struct somestruct item;
      volatile struct somestruct *cssp;
      int* ip = &cssp->i;
}

I think grischka will suggest you to commit this patch into mob
branch, as usual. If you are familiar with git or you are happy to
learn it, please push this patch on the mob branch. Otherwise, please
let me know and I'll land it.

Thanks,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]