summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2015-12-07 02:55:58 +0800
committerTing-Wei Lan <lantw44@gmail.com>2015-12-07 03:00:22 +0800
commit52ddbb128bba155818a75741b48615c5793b59c3 (patch)
treee872d926b6068e7c8a480745f6666f3949ffc732
parent762c59fd74b760aab11f0185f16189d05bae1feb (diff)
downloadcompiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar.gz
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar.bz2
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar.lz
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar.xz
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.tar.zst
compiler2015-52ddbb128bba155818a75741b48615c5793b59c3.zip
Fix problems caused by short-circuit evaluation
The semantic checker should not stop or skip tests when an error is found.
-rw-r--r--src/semantic-analysis.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/semantic-analysis.c b/src/semantic-analysis.c
index 673c3b6..eea37b0 100644
--- a/src/semantic-analysis.c
+++ b/src/semantic-analysis.c
@@ -341,13 +341,13 @@ static bool process_program(CcmmcAst *program, CcmmcSymbolTable *table)
assert(global_decl->type_node == CCMMC_AST_NODE_DECL);
switch (global_decl->value_decl.kind) {
case CCMMC_KIND_DECL_TYPE:
- any_error = any_error || process_typedef(global_decl, table);
+ any_error = process_typedef(global_decl, table) || any_error;
break;
case CCMMC_KIND_DECL_VARIABLE:
- any_error = any_error || process_variable(global_decl, table);
+ any_error = process_variable(global_decl, table) || any_error;
break;
case CCMMC_KIND_DECL_FUNCTION:
- any_error = any_error || process_function(global_decl, table);
+ any_error = process_function(global_decl, table) || any_error;
break;
case CCMMC_KIND_DECL_FUNCTION_PARAMETER:
default:
@@ -373,7 +373,7 @@ bool ccmmc_semantic_check(CcmmcAst *root, CcmmcSymbolTable *table)
ccmmc_symbol_table_insert(table, "void", CCMMC_SYMBOL_KIND_TYPE,
(CcmmcSymbolType){ .type_base = CCMMC_AST_VALUE_VOID });
// Start processing from the program node
- any_error = any_error || process_program(root, table);
+ any_error = process_program(root, table) || any_error;
return !any_error;
}