○[pcc] pcc(1) _Bool type bug その12
後置++の為にINCR/DECRをpass2に渡すのはとてもめんどくさそうなので後回し。
先にLSEQとRSEQが変な動作してるのを修正することにしますか。
前回のpatchで{PLUS,MINUS,MUL,DIV}EQであれば
#include <stdbool.h>
_Bool x;
int y;
main(void)
{
x *= y;
}
0xbb901290) =, bool, REG %eax, SU= 0(@REG,,,,)
0xbb901080) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9012bc) SCONV, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9011d0) *, int, REG %eax, SU= 0(@REG,,,,)
0xbb901264) SCONV, int, REG %eax, SU= 0(@REG,,,,)
0xbb90111c) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9011fc) NAME y, int, REG %eax, SU= 0(@REG,,,,)
と正しく整数拡張されたツリーが出来上がるんだけど、{LS,RS}EQだけは
#include <stdbool.h>
_Bool x;
int y;
main(void)
{
x <<= y;
}
0xbb901290) =, bool, REG %eax, SU= 0(@REG,,,,)
0xbb901080) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9011d0) <<, bool, REG %eax, SU= 0(@REG,,,,)
0xbb90111c) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb901264) SCONV, char, REG %eax, SU= 0(@REG,,,,)
0xbb9011fc) NAME y, int, REG %eax, SU= 0(@REG,,,,)
- 整数拡張が行われない
- 何故かyがcharにキャストされる
(最小レジスタ使うため型サイズをどっかでチェックしてるっぽい)
- pass2でエラーが発生する
という問題があったのよね。
暫定的にcc/ccom/trees.cに↓の変更を加えると
@@ -424,7 +435,8 @@
case RS: /* must make type size at least int... */
if (p->n_type == CHAR || p->n_type == SHORT) {
p->n_left = makety(l, INT, 0, 0, MKSUE(INT));
- } else if (p->n_type == UCHAR || p->n_type == USHORT) {
+ } else if (p->n_type == BOOL ||
+ p->n_type == UCHAR || p->n_type == USHORT) {
p->n_left = makety(l, UNSIGNED, 0, 0,
MKSUE(UNSIGNED));
}
pass2でコケる問題は解消するみたい。
0xbb9012bc) =, bool, REG %eax, SU= 0(@REG,,,,)
0xbb901080) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9012e8) SCONV, bool, REG %eax, SU= 0(@REG,,,,)
0xbb9011d0) <<, unsigned, REG %eax, SU= 0(@REG,,,,)
0xbb901264) SCONV, unsigned, REG %eax, SU= 0(@REG,,,,)
0xbb90111c) NAME x, bool, REG %eax, SU= 0(@REG,,,,)
0xbb901290) SCONV, char, REG %eax, SU= 0(@REG,,,,)
0xbb9011fc) NAME y, int, REG %eax, SU= 0(@REG,,,,)
...
movl y,%eax
movb %al,%cl
movzbl x,%eax
sall %cl,%eax
cmpl $0,%eax
setne %al
movb %al,x
...
でもこれ{LS,RS}EQの場合のopact()の処理から見直した方がいいのかもしれない。