mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Removal of unused code.
This commit is contained in:
@@ -2288,7 +2288,7 @@ void expr_rewrite_to_builtin_access(Expr *expr, Expr *parent, BuiltinAccessKind
|
||||
void expr_rewrite_to_string(Expr *expr_to_rewrite, const char *string);
|
||||
void expr_rewrite_to_const_zero(Expr *expr, Type *type);
|
||||
bool expr_rewrite_to_const_initializer_index(Type *list_type, ConstInitializer *list, Expr *result, unsigned index, bool from_back);
|
||||
void expr_rewrite_to_variable(Expr *expr, Decl *decl);
|
||||
|
||||
void expr_rewrite_to_binary(Expr *expr_to_rewrite, Expr *left, Expr *right, BinaryOp op);
|
||||
|
||||
bool expr_const_in_range(const ExprConst *left, const ExprConst *right, const ExprConst *right_to);
|
||||
|
||||
@@ -287,139 +287,3 @@ const char *span_to_string(SourceSpan span)
|
||||
const char *start = current + col - 1;
|
||||
return str_copy(start, length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
bool diagnostics_silence_warnings(Array *warnings)
|
||||
{
|
||||
for (unsigned i = 0; i < warnings->count; i++)
|
||||
{
|
||||
const char *warning = warnings->entries[i];
|
||||
if (strcmp("no-unused", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED);
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_PARAMETER);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-variable", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_VARIABLE);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-function", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_FUNCTION);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-type", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_TYPE);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-module", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_MODULE);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-public", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_PUBLIC);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-import", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_IMPORT);
|
||||
continue;
|
||||
}
|
||||
if (strcmp("no-unused-label", warning) == 0)
|
||||
{
|
||||
diagnostics_update_severity(DIAG_IGNORE, DIAG_UNUSED_LABEL);
|
||||
continue;
|
||||
}
|
||||
PRINT_ERROR("recipe has unknown warning: '%s'\n", warning);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void sema_warn_at(DiagnosticsType type, SourceLoc loc, const char *message, ...)
|
||||
{
|
||||
// TODO ENABLE
|
||||
return;
|
||||
SourceRange span = {.loc = loc, .length = 1};
|
||||
switch (diagnostics.severity[type])
|
||||
{
|
||||
case DIAG_IGNORE:
|
||||
return;
|
||||
case DIAG_WARN:
|
||||
break;
|
||||
case DIAG_ERROR:
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
vprint_error(span, message, args);
|
||||
va_end(args);
|
||||
diagnostics.errors++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
char buffer[256];
|
||||
vsnprintf(buffer, 256, message, args);
|
||||
if (diagnostics.severity[type])
|
||||
print_error(span, buffer, PRINT_TYPE_WARN);
|
||||
va_end(args);
|
||||
diagnostics.warnings++;
|
||||
}
|
||||
|
||||
void sema_warn_range(DiagnosticsType type, SourceRange span, const char *message, ...)
|
||||
{
|
||||
// TODO ENABLE
|
||||
return;
|
||||
switch (diagnostics.severity[type])
|
||||
{
|
||||
case DIAG_IGNORE:
|
||||
return;
|
||||
case DIAG_WARN:
|
||||
break;
|
||||
case DIAG_ERROR:
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
vprint_error(span, message, args);
|
||||
va_end(args);
|
||||
diagnostics.errors++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
char buffer[256];
|
||||
vsnprintf(buffer, 256, message, args);
|
||||
if (diagnostics.severity[type]) print_error(span, buffer, PRINT_TYPE_WARN);
|
||||
va_end(args);
|
||||
diagnostics.warnings++;
|
||||
}
|
||||
|
||||
unsigned errors()
|
||||
{
|
||||
return diagnostics.errors;
|
||||
}
|
||||
|
||||
bool error_found()
|
||||
{
|
||||
return diagnostics.errors > 0;
|
||||
}
|
||||
*/
|
||||
@@ -939,18 +939,6 @@ Expr *expr_variable(Decl *decl)
|
||||
return expr;
|
||||
}
|
||||
|
||||
void expr_rewrite_to_variable(Expr *expr, Decl *decl)
|
||||
{
|
||||
expr->expr_kind = EXPR_IDENTIFIER;
|
||||
if (decl->resolve_status == RESOLVE_DONE)
|
||||
{
|
||||
expr_resolve_ident(expr, decl);
|
||||
return;
|
||||
}
|
||||
expr->identifier_expr.ident = decl->name;
|
||||
expr->resolve_status = RESOLVE_NOT_DONE;
|
||||
}
|
||||
|
||||
void expr_rewrite_insert_deref(Expr *original)
|
||||
{
|
||||
// Assume *(&x) => x
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "compiler_internal.h"
|
||||
|
||||
#include <llvm/Config/llvm-config.h> // for LLVM_VERSION_STRING
|
||||
#if PLATFORM_POSIX
|
||||
#include <glob.h>
|
||||
#endif
|
||||
|
||||
@@ -991,7 +991,7 @@ static bool parse_attributes_for_global(ParseContext *c, Decl *decl)
|
||||
*/
|
||||
bool parse_attributes(ParseContext *c, Attr ***attributes_ref, Visibility *visibility_ref, bool *builtin_ref, bool *cond_ref)
|
||||
{
|
||||
Visibility visibility = -1;
|
||||
Visibility visibility = -1; // NOLINT
|
||||
if (cond_ref) *cond_ref = false;
|
||||
while (1)
|
||||
{
|
||||
@@ -999,7 +999,7 @@ bool parse_attributes(ParseContext *c, Attr ***attributes_ref, Visibility *visib
|
||||
if (!parse_attribute(c, &attr, false)) return false;
|
||||
if (!attr) return true;
|
||||
bool parsed_builtin = false;
|
||||
Visibility parsed_visibility = -1;
|
||||
Visibility parsed_visibility = -1; // NOLINT
|
||||
if (!attr->is_custom)
|
||||
{
|
||||
// This is important: if we would allow user defined attributes,
|
||||
@@ -1747,27 +1747,6 @@ static bool parse_macro_params(ParseContext *c, Decl *macro)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* define_parameters ::= expr (<',' expr)* '>)'
|
||||
*
|
||||
* @return NULL if parsing failed, otherwise a list of Type*
|
||||
*/
|
||||
static inline Expr **parse_generic_parameters(ParseContext *c)
|
||||
{
|
||||
Expr **params = NULL;
|
||||
while (!try_consume(c, TOKEN_RGENPAR))
|
||||
{
|
||||
ASSIGN_EXPR_OR_RET(Expr *arg, parse_expr(c), NULL);
|
||||
vec_add(params, arg);
|
||||
TokenType tok = c->tok;
|
||||
if (tok != TOKEN_RGENPAR)
|
||||
{
|
||||
TRY_CONSUME_OR_RET(TOKEN_COMMA, "Expected ',' after the argument.", NULL);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
static inline void decl_add_type(Decl *decl, TypeKind kind)
|
||||
{
|
||||
Type *type = type_new(kind, decl->name);
|
||||
|
||||
@@ -866,11 +866,6 @@ static bool rule_slice_to_ptr(CastContext *cc, bool is_explicit, bool is_silent)
|
||||
return sema_cast_error(cc, may_explicit, is_silent);
|
||||
}
|
||||
|
||||
static bool rule_untyped_to_struct(CastContext *cc, bool is_explicit, bool is_silent)
|
||||
{
|
||||
TODO
|
||||
}
|
||||
|
||||
static bool rule_slice_to_slice(CastContext *cc, bool is_explicit, bool is_silent)
|
||||
{
|
||||
Type *from_type = cc->from_type;
|
||||
|
||||
@@ -2970,7 +2970,7 @@ static inline bool sema_analyse_ct_for_stmt(SemaContext *context, Ast *statement
|
||||
current = &compound_stmt->next;
|
||||
|
||||
// Copy and evaluate all the expressions in "incr"
|
||||
FOREACH_BEGIN(Expr *expr, incr_list)
|
||||
FOREACH_BEGIN(Expr *expr, incr_list) // NOLINT
|
||||
if (!sema_analyse_ct_expr(context, copy_expr_single(expr))) goto FAILED;
|
||||
FOREACH_END();
|
||||
}
|
||||
@@ -3003,8 +3003,7 @@ static inline bool sema_analyse_statement_inner(SemaContext *context, Ast *state
|
||||
case AST_BREAK_STMT:
|
||||
return sema_analyse_break_stmt(context, statement);
|
||||
case AST_CASE_STMT:
|
||||
SEMA_ERROR(statement, "Unexpected 'case' outside of switch");
|
||||
return false;
|
||||
RETURN_SEMA_ERROR(statement, "Unexpected 'case' outside of switch");
|
||||
case AST_COMPOUND_STMT:
|
||||
return sema_analyse_compound_stmt(context, statement);
|
||||
case AST_CONTINUE_STMT:
|
||||
@@ -3018,8 +3017,7 @@ static inline bool sema_analyse_statement_inner(SemaContext *context, Ast *state
|
||||
case AST_DECLARE_STMT:
|
||||
return sema_analyse_declare_stmt(context, statement);
|
||||
case AST_DEFAULT_STMT:
|
||||
SEMA_ERROR(statement, "Unexpected 'default' outside of switch");
|
||||
return false;
|
||||
RETURN_SEMA_ERROR(statement, "Unexpected 'default' outside of switch");
|
||||
case AST_DEFER_STMT:
|
||||
return sema_analyse_defer_stmt(context, statement);
|
||||
case AST_EXPR_STMT:
|
||||
|
||||
Reference in New Issue
Block a user