#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "semantics.h"
#include "ast.h"
#define NEW(type) ((type *)malloc(sizeof(type)))
#define CHECK_TYPE(p, _type) assert(p->type == _type)
#define ERROR(ast) print_error(err_buff, NULL, (ast)->loc.row, (ast)->loc.col, 0)
#define WARNING(ast) print_error(err_buff, NULL, (ast)->loc.row, (ast)->loc.col, 1)
#define NOT_IGNORE_VOID(et, ast) \
if (et->type == CVOID) \
do \
{ \
sprintf(err_buff, "void value not ignored as it ought to be"); \
ERROR(ast); \
} while (0)
#define INCOMP_TYPE(ast) \
do { \
sprintf(err_buff, "incompatible types when assigning"); \
ERROR(ast); \
} while (0)
/* pointer to function conversion (std 6.3.2/4) */
#define FUNC_POINTER_CONV(t) \
do { \
if ((t)->type == CFUNC) \
{ \
CType_t f = ctype_create("", CPTR, p); \
f->rec.ref = t; \
t = f; \
} \
} while (0)
#define CHECK_CVOID(name, ast) \
if (type_spec->type == CVOID) \
do { \
sprintf(err_buff, "variable or field '%s' declared void", name); \
ERROR(ast); \
} while (0)