Re: [Tinycc-devel] 回复: tcc grammar problems

2014-08-05 Thread YX Hao
Tell something can be done rather than stop people doing anything time and time 
again.
  - Original Message - 
  From: Sia Lang 
  To: tinycc-devel@nongnu.org 
  Sent: Tuesday, August 05, 2014 12:52 AM
  Subject: Re: [Tinycc-devel]回复: tcc grammar problems


  On Mon, Aug 4, 2014 at 6:14 PM, jiang 30155...@qq.com wrote:

There are some problems I almost solved. But the new problems appeared, I 
use grischka tell me a method, with tcc compile yasm,  No passed, is the struct 
already the definition of errors. I are looking for reasons .Thank you care I 
patch, and can give me some suggestions.




  Aha.


  The english here was so bad I got suspicious (it's better than this from time 
to time.) So looking through code and mailing archives and translating some 
Chinese posts from you I've found, I can now safely conclude you're an 
extremely elaborate troll.


  Kudos for the effort, but please stop wasting the time of this fine project 
already!


  Sia
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] 回复: tcc grammar problems

2014-08-05 Thread Raphaël Londeix
On Tue, Aug 5, 2014 at 1:52 AM, Sia Lang silverlangu...@gmail.com wrote:

 On Mon, Aug 4, 2014 at 6:14 PM, jiang 30155...@qq.com wrote:

 There are some problems I almost solved. But the new problems appeared, I
 use grischka tell me a method, with tcc compile yasm,  No passed, is the
 struct already the definition of errors. I are looking for reasons .Thank
 you care I patch, and can give me some suggestions.


 Aha.

 The english here was so bad I got suspicious (it's better than this from
 time to time.) So looking through code and mailing archives and translating
 some Chinese posts from you I've found, I can now safely conclude you're an
 extremely elaborate troll.

 Kudos for the effort, but please stop wasting the time of this fine
 project already!



If this is true, this guy deserves a medal and we should all learn from
him. I are in pressed.
Btw, have you truly found trolling posts in some Chinese forums ? I say
that because google translate make any asian language sentence sounds like
a troll. Anyhow, thanks for the investigation, the fact that you did it
made me laugh already.

Cheers,

-- 
Raphaël Londeix
http://hotgloupi.fr
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc grammar problems

2014-08-05 Thread Thomas Preud'homme
Le vendredi 01 août 2014, 16:37:15 jiang a écrit :
 my patch:See Attachment
 You look at, if no problem, I'll push mob

Ok, here is what I noticed so far:

commit 1988c974137f3042d9c38000fda3e00779fecab3
Author: Jiang 30155...@qq.com
Date:   Fri Aug 1 16:27:58 2014 +0800

fix bitfields

see:
http://lists.nongnu.org/archive/html/tinycc-devel/2014-07/msg00023.html


Fix casts to bitfield followed by the quick testcase provided by grishka 
would be better.


diff --git a/tcc.h b/tcc.h
index c93cedf..a8cabb6 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1192,6 +1192,17 @@ ST_DATA int func_var; /* true if current function is 
variadic */
 ST_DATA int func_vc;
 ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and 
pc */
 ST_DATA char *funcname;
+/* gen_ctrl */
+enum {
+CTRL_NONE,
+CTRL_CALL,
+CTRL_FOCE,
+CTRL_ARGS,
+CTRL_RETS,
+CTRL_INIT,
+CTRL_USED,
+};
+ST_DATA int gen_ctrl;

A description of the use for each enumerator would be nice. Also, unless you 
mean something else, I think you should rename CTRL_FOCE into CTRL_FORCE. Also 
you seem to only use CTRL_FOCE and CTRL_INIT. So you should probably remove 
all the others. And why separating the kind of check? Why not just a switch 
which enables or not warnings? Please explain me why you feel the need for 
this enum.
 
 ST_INLN int is_float(int t);
 ST_FUNC int ieee_finite(double d);
diff --git a/tccgen.c b/tccgen.c
index 1a89d4a..73b759f 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -70,6 +70,7 @@ ST_DATA int func_var; /* true if current function is 
variadic (used by return in
 ST_DATA int func_vc;
 ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and 
pc */
 ST_DATA char *funcname;
+ST_DATA int gen_ctrl;
 
 ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
 
@@ -1909,8 +1910,9 @@ static void force_charshort_cast(int t)
 /* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
 static void gen_cast(CType *type)
 {
-int sbt, dbt, sf, df, c, p;
+int sbt, dbt, dt, sf, df, c, p, bb;
 
+bb = type-t  VT_BITFIELD;

Why bb for the bitfield? Maybe you could use db (destination bitfield) to 
follow the same naming convention as df (destination float). Also you should 
add it just before the c, but that's really nitpick.

I'm not sure about dt. On one hand its the real destination basic type but on 
the other hand dbt is already used.

 /* special delayed cast for char/short */
 /* XXX: in some cases (multiple cascaded casts), it may still
be incorrect */
@@ -1925,9 +1927,10 @@ static void gen_cast(CType *type)
 }
 
 dbt = type-t  (VT_BTYPE | VT_UNSIGNED);
+dt = dbt  VT_BTYPE;
 sbt = vtop-type.t  (VT_BTYPE | VT_UNSIGNED);
 
-if (sbt != dbt) {
+if (sbt != dbt || bb) {
 sf = is_float(sbt);
 df = is_float(dbt);
 c = (vtop-r  (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
@@ -1959,6 +1962,8 @@ static void gen_cast(CType *type)
 vtop-c.d = (double)vtop-c.ld;
 } else if (sf  dbt == (VT_LLONG|VT_UNSIGNED)) {
 vtop-c.ull = (unsigned long long)vtop-c.ld;
+if(bb)
+goto to_min;
 } else if (sf  dbt == VT_BOOL) {
 vtop-c.i = (vtop-c.ld != 0);
 } else {
@@ -1975,24 +1980,53 @@ static void gen_cast(CType *type)
 else if (sbt != VT_LLONG)
 vtop-c.ll = vtop-c.i;
 
-if (dbt == (VT_LLONG|VT_UNSIGNED))
+if (dbt == (VT_LLONG|VT_UNSIGNED)){
 vtop-c.ull = vtop-c.ll;
-else if (dbt == VT_BOOL)
+if(bb)
+goto to_min;
+}else if (dbt == VT_BOOL)

Spacing issue. You should have a space before '{' and after '}'

 vtop-c.i = (vtop-c.ll != 0);
 #ifdef TCC_TARGET_X86_64
 else if (dbt == VT_PTR)
 ;
 #endif
 else if (dbt != VT_LLONG) {
-int s = 0;
-if ((dbt  VT_BTYPE) == VT_BYTE)
-s = 24;
-else if ((dbt  VT_BTYPE) == VT_SHORT)
-s = 16;
-if(dbt  VT_UNSIGNED)
-vtop-c.ui = ((unsigned int)vtop-c.ll  s)  s;
-else
-vtop-c.i = ((int)vtop-c.ll  s)  s;
+unsigned long long ull;
+long long ll;
+int s, warr;

It would be better to name this variable warn.

+to_min:

Why not use the label cast_bitfield?

+warr = 0;
+if(bb){
+s = 64 - ((type-t  (VT_STRUCT_SHIFT + 6))  0x3f);

Spacing issue again and I don't understand the + 6. The bitfield size is 
encoded from bit (1  VT_STRUCT_SHIFT) on 6 bits. So you should do:
(type-t  VT_STRUCT_SHIFT)  0x3f (that is remove all the bits 

[Tinycc-devel] 回复: tcc grammar problems

2014-08-05 Thread jiang
HI, Thomas
My own ideas have some problems. temporarily not push into the mob.

Best regards,
Jiang

Thomas Preud'homme robo...@celest.fr编写:

Le vendredi 01 août 2014, 16:37:15 jiang a écrit :
 my patch:See Attachment
 You look at, if no problem, I'll push mob

Hi Jiang,

I wanted to tell you that I started reviewing your patch. It'll take me time 
as I don't have so much time to spend on it everyday but I hope I can finish 
in 
a few days only.

I started to make some note and already noted a few mistakes. I'll send you an 
email later this week.

Best regards,

Thomas
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel