diff options
author | Ting-Wei Lan <lantw44@gmail.com> | 2015-12-07 16:36:03 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw44@gmail.com> | 2015-12-07 16:36:28 +0800 |
commit | e43043422148ce9b4989cb5f0673868cafe86944 (patch) | |
tree | fcfc390ff69654e5bff7967cf62ca7161a50b92e | |
parent | 2b4a6e4b93c45fc5e23f311ccfef09f218267ca1 (diff) | |
download | compiler2015-e43043422148ce9b4989cb5f0673868cafe86944.tar.gz compiler2015-e43043422148ce9b4989cb5f0673868cafe86944.tar.zst compiler2015-e43043422148ce9b4989cb5f0673868cafe86944.zip |
Reject void variables and void arrays.
-rw-r--r-- | src/semantic-analysis.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/semantic-analysis.c b/src/semantic-analysis.c index d3a7de4..685fcdd 100644 --- a/src/semantic-analysis.c +++ b/src/semantic-analysis.c @@ -202,6 +202,12 @@ static bool process_typedef(CcmmcAst *type_decl, CcmmcSymbolTable *table) case CCMMC_KIND_ID_ARRAY: { size_t array_dimension; size_t *array_size; + if (source_sym->type.type_base == CCMMC_AST_VALUE_VOID) { + any_error = true; + fprintf (stderr, ERROR("ID `%s' is an array of voids."), + id->line_number, target_str); + continue; + } if (ccmmc_symbol_is_array(source_sym)) array_size = get_array_of_array_size( id, &array_dimension, @@ -257,6 +263,11 @@ static bool process_variable(CcmmcAst *var_decl, CcmmcSymbolTable *table) var_decl->line_number, type_str); return true; } + if (type_sym->type.type_base == CCMMC_AST_VALUE_VOID) { + fprintf(stderr, ERROR("ID `%s' is a void type."), + var_decl->line_number, type_str); + return true; + } // Other children are newly declared variables for (CcmmcAst *init_id = var_decl->child->right_sibling; init_id != NULL; |