implement some missing builtin variants
[cparser] / parser.c
index 0f40e75..0cc4257 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -36,7 +36,7 @@
 #include "entity_t.h"
 #include "attribute_t.h"
 #include "lang_features.h"
-#include "walk_statements.h"
+#include "walk.h"
 #include "warning.h"
 #include "printer.h"
 #include "adt/bitfiddle.h"
@@ -1547,7 +1547,6 @@ unary:
                        return;
 
                EXPR_LITERAL_CASES
-               case EXPR_UNKNOWN:
                case EXPR_INVALID:
                case EXPR_STRING_LITERAL:
                case EXPR_WIDE_STRING_LITERAL:
@@ -3650,7 +3649,7 @@ static type_t *construct_declarator_type(construct_type_t *construct_list,
                                errorf(pos, "function returning array is not allowed");
                        } else {
                                if (skipped_return_type->base.qualifiers != 0) {
-                                       warningf(WARN_OTHER, pos, "type qualifiers in return type of function type are meaningless");
+                                       warningf(WARN_IGNORED_QUALIFIERS, pos, "type qualifiers in return type of function type are meaningless");
                                }
                        }
 
@@ -4830,9 +4829,6 @@ static bool expression_returns(expression_t const *const expr)
                        return
                                expression_returns(expr->binary.left) &&
                                expression_returns(expr->binary.right);
-
-               case EXPR_UNKNOWN:
-                       break;
        }
 
        panic("unhandled expression");
@@ -8208,7 +8204,7 @@ static bool maybe_negative(expression_t const *const expr)
 {
        switch (is_constant_expression(expr)) {
                case EXPR_CLASS_ERROR:    return false;
-               case EXPR_CLASS_CONSTANT: return fold_constant_to_int(expr) < 0;
+               case EXPR_CLASS_CONSTANT: return constant_is_negative(expr);
                default:                  return true;
        }
 }
@@ -8527,7 +8523,6 @@ static void semantic_binexpr_assign(binary_expression_t *expression)
 static bool expression_has_effect(const expression_t *const expr)
 {
        switch (expr->kind) {
-               case EXPR_UNKNOWN:                    break;
                case EXPR_INVALID:                    return true; /* do NOT warn */
                case EXPR_REFERENCE:                  return false;
                case EXPR_REFERENCE_ENUM_VALUE:       return false;
@@ -8746,7 +8741,6 @@ static expression_t *parse_subexpression(precedence_t precedence)
                left = parser->infix_parser(left);
 
                assert(left != NULL);
-               assert(left->kind != EXPR_UNKNOWN);
        }
 
        return left;
@@ -8904,7 +8898,7 @@ static asm_argument_t *parse_asm_arguments(bool is_out)
                                                size  = get_atomic_type_size(akind);
                                        } else {
                                                flags = ATOMIC_TYPE_FLAG_INTEGER | ATOMIC_TYPE_FLAG_ARITHMETIC;
-                                               size  = get_atomic_type_size(get_intptr_kind());
+                                               size  = get_type_size(type_void_ptr);
                                        }
 
                                        do {
@@ -8920,7 +8914,7 @@ static asm_argument_t *parse_asm_arguments(bool is_out)
                                                        value_size  = get_atomic_type_size(value_akind);
                                                } else if (value_kind == TYPE_POINTER) {
                                                        value_flags = ATOMIC_TYPE_FLAG_INTEGER | ATOMIC_TYPE_FLAG_ARITHMETIC;
-                                                       value_size  = get_atomic_type_size(get_intptr_kind());
+                                                       value_size  = get_type_size(type_void_ptr);
                                                } else {
                                                        break;
                                                }
@@ -9279,8 +9273,18 @@ end_error:
        statement->ifs.true_statement = true_stmt;
        rem_anchor_token(T_else);
 
+       if (true_stmt->kind == STATEMENT_EMPTY) {
+               warningf(WARN_EMPTY_BODY, HERE,
+                       "suggest braces around empty body in an ‘if’ statement");
+       }
+
        if (next_if(T_else)) {
                statement->ifs.false_statement = parse_inner_statement();
+
+               if (statement->ifs.false_statement->kind == STATEMENT_EMPTY) {
+                       warningf(WARN_EMPTY_BODY, HERE,
+                                       "suggest braces around empty body in an ‘if’ statement");
+               }
        } else if (true_stmt->kind == STATEMENT_IF &&
                        true_stmt->ifs.false_statement != NULL) {
                source_position_t const *const pos = &true_stmt->base.source_position;