Skip to content

Commit 6ce735e

Browse files
committed
Fixup sizeof a little bit
1 parent 4b413db commit 6ce735e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

repl/completion_trie.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdio.h>
33
#include <string.h>
44

5-
#if defined(TEST_MAIN)
5+
#if defined(COMP_TRIE_TEST_MAIN)
66
# include "../os/os.c"
77
# include "../os/metac_alloc.c"
88
#endif
@@ -471,7 +471,7 @@ void CompletionTrie_Add(completion_trie_root_t* root, const char* word, uint32_t
471471
CompletionTrie_AddChild(root, parentNode, "", 0);
472472
}
473473

474-
#if defined(TEST_MAIN)
474+
#if defined(COMP_TRIE_TEST_MAIN)
475475
typedef struct {
476476
const char** Strings;
477477
uint32_t nStrings;
@@ -596,7 +596,7 @@ void CompletionTrie_PrintStats(completion_trie_root_t* self, uint16_t n)
596596
#endif
597597
}
598598

599-
#ifdef TEST_MAIN
599+
#if defined(COMP_TRIE_TEST_MAIN)
600600
int main(int argc, const char* argv[])
601601
{
602602
CompletionTrie_NoPreallocatedCIdentifierChars = true;

semantic/metac_expr_semantic.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,16 +1275,17 @@ metac_sema_expr_t* MetaCSemantic_doExprSemantic_(metac_sema_state_t* self,
12751275
case expr_sizeof:
12761276
{
12771277
int32_t size = -1;
1278-
hash = sizeof_key;
12791278
metac_sema_expr_t* e1 =
12801279
MetaCSemantic_doExprSemantic(self, expr->E1, 0);
1280+
metac_type_index_t typeIdx;
1281+
hash = sizeof_key;
12811282

12821283
while (e1->Kind == expr_paren)
12831284
{
12841285
e1 = e1->E1;
12851286
}
12861287

1287-
metac_type_index_t typeIdx = e1->TypeIndex;
1288+
typeIdx = e1->TypeIndex;
12881289
// usually we assume the type of which we want
12891290
// to get the size is the type of the expression
12901291
if (e1->Kind == expr_type)
@@ -1293,15 +1294,18 @@ metac_sema_expr_t* MetaCSemantic_doExprSemantic_(metac_sema_state_t* self,
12931294
// which is something that resolves to a type such as the identifier int
12941295
typeIdx = e1->TypeExp;
12951296
hash = CRC32C_VALUE(hash, e1->TypeExp);
1296-
} else if (e1->TypeIndex.v == TYPE_INDEX_V(type_index_basic, type_type))
1297+
}
1298+
else if (e1->TypeIndex.v == TYPE_INDEX_V(type_index_basic, type_type))
12971299
{
12981300
// if the expression is any other kind of expression and it is of type type
12991301
// it indicates we want this sizeof be resolved at a later time
13001302
// possibly when calling a function
13011303
}
13021304

1303-
if (e1->TypeIndex.v != 0 && e1->TypeIndex.v != -1)
1305+
if (typeIdx.v != 0 && typeIdx.v != -1)
1306+
{
13041307
size = MetaCSemantic_GetTypeSize(self, typeIdx);
1308+
}
13051309

13061310
result->TypeIndex.v = TYPE_INDEX_V(type_index_basic, type_size_t);
13071311
result->Kind = expr_signed_integer;

0 commit comments

Comments
 (0)