#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"
return;
EXPR_LITERAL_CASES
- case EXPR_UNKNOWN:
case EXPR_INVALID:
case EXPR_STRING_LITERAL:
case EXPR_WIDE_STRING_LITERAL:
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");
}
}
return
expression_returns(expr->binary.left) &&
expression_returns(expr->binary.right);
-
- case EXPR_UNKNOWN:
- break;
}
panic("unhandled 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;
left = parser->infix_parser(left);
assert(left != NULL);
- assert(left->kind != EXPR_UNKNOWN);
}
return left;
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;
case ';':
if (!strict_mode) {
- warningf(WARN_OTHER, HERE, "stray ';' outside of function");
+ warningf(WARN_STRAY_SEMICOLON, HERE, "stray ';' outside of function");
next_token();
return;
}