History

vla: Fix check for vla used by autoconf

1) recursive types have no storage anymore, so a static int (*p)[x]; declaration is just fine 2) since somewhen VT_VLA doesn't imply VT_ARRAY anymore, so we now need to check VLA in at least one place before checking test_lvalue. ((2) should probably be cleaned up again so that VLA does again imply ARRAY)

Michael Matz committed 4 years ago

Commit fa256301 parent 76b88e22 files · +8 −4Browse files

Unified · Split

2 files
  1. tccgen.c +3 −2
  2. tests/tcctest.c +5 −2
tccgen.c+3−2
@@ -5018,7 +5018,8 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td) · 5017 unmodified lines
5018 expect("identifier");5018 expect("identifier");
5019 *v = 0;5019 *v = 0;
5020 }5020 }
5021 post_type(post, ad, storage, td & ~(TYPE_DIRECT|TYPE_ABSTRACT));5021 post_type(post, ad, post != ret ? 0 : storage,
5022 td & ~(TYPE_DIRECT|TYPE_ABSTRACT));
5022 parse_attribute(ad);5023 parse_attribute(ad);
5023 type->t |= storage;5024 type->t |= storage;
5024 return ret;5025 return ret;
@@ -5437,7 +5438,7 @@ ST_FUNC void unary(void) · 412 unmodified lines
5437 there and in function calls. */5438 there and in function calls. */
5438 /* arrays can also be used although they are not lvalues */5439 /* arrays can also be used although they are not lvalues */
5439 if ((vtop->type.t & VT_BTYPE) != VT_FUNC &&5440 if ((vtop->type.t & VT_BTYPE) != VT_FUNC &&
5440 !(vtop->type.t & VT_ARRAY))5441 !(vtop->type.t & (VT_ARRAY | VT_VLA)))
5441 test_lvalue();5442 test_lvalue();
5442 if (vtop->sym)5443 if (vtop->sym)
5443 vtop->sym->a.addrtaken = 1;5444 vtop->sym->a.addrtaken = 1;
tests/tcctest.c+5−2
@@ -2979,6 +2979,7 @@ void c99_vla_test_2(int d, int h, int w) · 2978 unmodified lines
2979 int x, y, z;2979 int x, y, z;
2980 int (*arr)[h][w] = malloc(sizeof(int) * d*h*w);2980 int (*arr)[h][w] = malloc(sizeof(int) * d*h*w);
2981 int c = 1;2981 int c = 1;
2982 static int (*starr)[h][w];
2982 2983
2983 printf("Test C99 VLA 6 (pointer)\n");2984 printf("Test C99 VLA 6 (pointer)\n");
2984 2985
@@ -2998,13 +2999,15 @@ void c99_vla_test_2(int d, int h, int w) · 13 unmodified lines
2998 }2999 }
2999 puts("");3000 puts("");
3000 }3001 }
3002 starr = &arr[1];
3001 printf(" sizes : %d %d %d\n"3003 printf(" sizes : %d %d %d\n"
3002 " pdiff : %d %d\n"3004 " pdiff : %d %d\n"
3003 " tests : %d %d\n",3005 " tests : %d %d %d\n",
3004 sizeof (*arr), sizeof (*arr)[0], sizeof (*arr)[0][0],3006 sizeof (*arr), sizeof (*arr)[0], sizeof (*arr)[0][0],
3005 arr + 2 - arr, *arr + 3 - *arr,3007 arr + 2 - arr, *arr + 3 - *arr,
3006 0 == sizeof (*arr + 1) - sizeof arr,3008 0 == sizeof (*arr + 1) - sizeof arr,
3007 0 == sizeof sizeof *arr - sizeof arr3009 0 == sizeof sizeof *arr - sizeof arr,
3010 starr[0][2][3] == arr[1][2][3]
3008 );3011 );
3009 free (arr);3012 free (arr);
3010}3013}

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