mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-16 06:11:15 +00:00
[qfcc] Be more const-correct with expressions
Diagnostics that return an expression now return const, and fixes error not returning an error expression.
This commit is contained in:
parent
f3ca0c9222
commit
261ea0c4de
6 changed files with 32 additions and 30 deletions
|
@ -31,6 +31,8 @@
|
|||
#ifndef __diagnostic_h
|
||||
#define __diagnostic_h
|
||||
|
||||
typedef struct expr_s expr_t;
|
||||
|
||||
/** \defgroup qfcc_diagnostic Diagnostic Messages
|
||||
\ingroup qfcc
|
||||
*/
|
||||
|
@ -42,37 +44,37 @@ extern diagnostic_hook error_hook;
|
|||
extern diagnostic_hook warning_hook;
|
||||
extern diagnostic_hook notice_hook;
|
||||
|
||||
struct expr_s *_error (const struct expr_s *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
const expr_t *_error (const expr_t *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6)));
|
||||
#define error(e, fmt...) _error(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
void _internal_error (const struct expr_s *e, const char *file, int line,
|
||||
void _internal_error (const expr_t *e, const char *file, int line,
|
||||
const char *func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6), noreturn));
|
||||
#define internal_error(e, fmt...) _internal_error(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
struct expr_s *_warning (const struct expr_s *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
const expr_t *_warning (const expr_t *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6)));
|
||||
#define warning(e, fmt...) _warning(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
struct expr_s *_notice (const struct expr_s *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
const expr_t *_notice (const expr_t *e, const char *file,
|
||||
int line, const char *func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6)));
|
||||
#define notice(e, fmt...) _notice(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
void _debug (const struct expr_s *e, const char *file, int line,
|
||||
void _debug (const expr_t *e, const char *file, int line,
|
||||
const char *func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6)));
|
||||
#define debug(e, fmt...) _debug(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
void _bug (const struct expr_s *e, const char *file, int line,
|
||||
void _bug (const expr_t *e, const char *file, int line,
|
||||
const char * func, const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF, 5, 6)));
|
||||
#define bug(e, fmt...) _bug(e, __FILE__, __LINE__, __FUNCTION__, fmt)
|
||||
|
||||
void print_srcline (int rep, const struct expr_s *e);
|
||||
void print_srcline (int rep, const expr_t *e);
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
@ -360,11 +360,11 @@ extern const char *expr_names[];
|
|||
\param op The opcode of the expression.
|
||||
\return \a e1 with its type set to ex_error.
|
||||
*/
|
||||
expr_t *type_mismatch (const expr_t *e1, const expr_t *e2, int op);
|
||||
const expr_t *type_mismatch (const expr_t *e1, const expr_t *e2, int op);
|
||||
|
||||
expr_t *param_mismatch (const expr_t *e, int param, const char *fn,
|
||||
type_t *t1, type_t *t2);
|
||||
expr_t *test_error (const expr_t *e, type_t *t);
|
||||
const expr_t *param_mismatch (const expr_t *e, int param, const char *fn,
|
||||
struct type_s *t1, struct type_s *t2);
|
||||
const expr_t *test_error (const expr_t *e, struct type_s *t);
|
||||
|
||||
extern expr_t *local_expr;
|
||||
|
||||
|
@ -540,7 +540,7 @@ expr_t *new_unary_expr (int op, const expr_t *e1);
|
|||
*/
|
||||
expr_t *new_horizontal_expr (int op, const expr_t *vec, type_t *type);
|
||||
|
||||
expr_t *new_swizzle_expr (const expr_t *src, const char *swizzle);
|
||||
const expr_t *new_swizzle_expr (const expr_t *src, const char *swizzle);
|
||||
|
||||
expr_t *new_extend_expr (const expr_t *src, type_t *type, int ext, bool rev);
|
||||
|
||||
|
|
|
@ -208,14 +208,14 @@ _bug (const expr_t *e, const char *file, int line, const char *func,
|
|||
va_end (args);
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
_notice (const expr_t *e, const char *file, int line, const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (options.notices.silent)
|
||||
return (expr_t *) e;
|
||||
return e;
|
||||
|
||||
va_start (args, fmt);
|
||||
if (options.notices.promote) {
|
||||
|
@ -237,10 +237,10 @@ _notice (const expr_t *e, const char *file, int line, const char *func,
|
|||
dstring_delete (message);
|
||||
}
|
||||
va_end (args);
|
||||
return (expr_t *) e;
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
_warning (const expr_t *e, const char *file, int line, const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
|
@ -249,7 +249,7 @@ _warning (const expr_t *e, const char *file, int line, const char *func,
|
|||
va_start (args, fmt);
|
||||
__warning (e, file, line, func, fmt, args);
|
||||
va_end (args);
|
||||
return (expr_t *) e;
|
||||
return e;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -263,7 +263,7 @@ _internal_error (const expr_t *e, const char *file, int line,
|
|||
va_end (args);
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
_error (const expr_t *e, const char *file, int line, const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
|
@ -292,5 +292,5 @@ _error (const expr_t *e, const char *file, int line, const char *func,
|
|||
|
||||
expr_t *err = new_expr ();
|
||||
err->type = ex_error;
|
||||
return (expr_t *) e;
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ extract_type (const expr_t *e)
|
|||
return ev_type_count;
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
type_mismatch (const expr_t *e1, const expr_t *e2, int op)
|
||||
{
|
||||
if (options.verbosity >= 2) {
|
||||
|
@ -226,7 +226,7 @@ type_mismatch (const expr_t *e1, const expr_t *e2, int op)
|
|||
get_type_string (get_type (e2)));
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
param_mismatch (const expr_t *e, int param, const char *fn, type_t *t1, type_t *t2)
|
||||
{
|
||||
return error (e, "type mismatch for parameter %d of %s: "
|
||||
|
@ -234,7 +234,7 @@ param_mismatch (const expr_t *e, int param, const char *fn, type_t *t1, type_t *
|
|||
get_type_string (t2));
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
test_error (const expr_t *e, type_t *t)
|
||||
{
|
||||
dstring_t *s = dstring_newstr ();
|
||||
|
@ -591,7 +591,7 @@ new_horizontal_expr (int op, const expr_t *vec, type_t *type)
|
|||
return e;
|
||||
}
|
||||
|
||||
expr_t *
|
||||
const expr_t *
|
||||
new_swizzle_expr (const expr_t *src, const char *swizzle)
|
||||
{
|
||||
src = convert_name (src);
|
||||
|
@ -2076,7 +2076,7 @@ build_function_call (const expr_t *fexpr, const type_t *ftype, const expr_t *par
|
|||
{
|
||||
int param_count = 0;
|
||||
expr_t *call;
|
||||
expr_t *err = 0;
|
||||
const expr_t *err = 0;
|
||||
|
||||
int arg_count = params ? list_count (¶ms->list) :0;
|
||||
const expr_t *arguments[arg_count];
|
||||
|
|
|
@ -704,7 +704,7 @@ const expr_t *
|
|||
method_check_params (method_t *method, const expr_t *args)
|
||||
{
|
||||
int i, param_count;
|
||||
expr_t *err = 0;
|
||||
const expr_t *err = 0;
|
||||
type_t *mtype = method->type;
|
||||
|
||||
if (mtype->t.func.num_params == -1)
|
||||
|
|
|
@ -55,8 +55,8 @@ void codespace_addcode (codespace_t *codespace, struct dstatement_s *code, int s
|
|||
__attribute__((const)) int function_parms (function_t *f, byte *parm_size) {return 0;}
|
||||
void def_to_ddef (def_t *def, ddef_t *ddef, int aux) {}
|
||||
__attribute__((noreturn)) void _internal_error (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {abort();}
|
||||
__attribute__((const)) expr_t *_warning (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {return 0;}
|
||||
__attribute__((const)) expr_t *_error (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {return 0;}
|
||||
__attribute__((const)) const expr_t *_warning (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {return 0;}
|
||||
__attribute__((const)) const expr_t *_error (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {return 0;}
|
||||
__attribute__((const)) symbol_t *make_structure (const char *name, int su, struct_def_t *defs, type_t *type) {return 0;}
|
||||
__attribute__((const)) symbol_t *symtab_addsymbol (symtab_t *symtab, symbol_t *symbol) {return 0;}
|
||||
__attribute__((const)) symbol_t *new_symbol_type (const char *name, type_t *type) {return 0;}
|
||||
|
|
Loading…
Reference in a new issue