History

Fixes for issues I've just found/introduced to x86 TCC.

- Cast from pointer to long long makes TCC output an error. Use cast to int before we apply shift operation for a pointer value. - Removed test cases for casts from pointer to char/short because they produce warning.

Shinichiro Hamaji committed 17 years ago

Commit 83fd3631 parent be43c8e2 files · +6 −3Browse files

Unified · Split

2 files
  1. tcc.c +5 −0
  2. tcctest.c +1 −3
tcc.c+5−0
@@ -6219,6 +6219,11 @@ static void gen_cast(CType *type) · 6218 unmodified lines
62196219 vpushi(0);
62206220 gv(RC_INT);
62216221 } else {
6222+ if (sbt == VT_PTR) {
6223+ /* cast from pointer to int before we apply
6224+ shift operation, which pointers don't support*/
6225+ gen_cast(&int_type);
6226+ }
62226227 gv_dup();
62236228 vpushi(31);
62246229 gen_op(TOK_SAR);
tcctest.c+1−3
@@ -1154,9 +1154,7 @@ void cast_test() · 1153 unmodified lines
11541154 printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
11551155
11561156 /* from pointer to integer types */
1157− printf("%d %d %d %d %d %d %ld %ld %lld %lld\n",
1158− (char)p, (unsigned char)p,
1159− (short)p, (unsigned short)p,
1157+ printf("%d %d %ld %ld %lld %lld\n",
11601158 (int)p, (unsigned int)p,
11611159 (long)p, (unsigned long)p,
11621160 (long long)p, (unsigned long long)p);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t