diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-04-18 23:18:45 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-04-18 23:18:45 -0400 |
commit | 919121bdf572b632cc5bfbbee502664682b26ab8 (patch) | |
tree | 528a83bb716851152ebc12aee385417b8f407601 /dimension/realize.c | |
parent | 004d63c0c199a1544dc9b3af9cdd3367a6969d23 (diff) | |
download | dimension-919121bdf572b632cc5bfbbee502664682b26ab8.tar.xz |
Give backtraces for diagnostics from macros and include files.
Partly this means that dmnsn_diagnostic() can't be called anywhere except
during parsing, because the dmnsn_parse_location::parent pointers dangle.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r-- | dimension/realize.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/dimension/realize.c b/dimension/realize.c index b6c6a60..8a1f024 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -21,6 +21,7 @@ #include "parse.h" #include "utility.h" #include <math.h> +#include <fenv.h> #include <stdio.h> #include <stdbool.h> @@ -31,8 +32,13 @@ dmnsn_realize_integer(dmnsn_astnode astnode) case DMNSN_AST_INTEGER: return *(long *)astnode.ptr; case DMNSN_AST_FLOAT: - dmnsn_diagnostic(astnode.location, "WARNING: float rounded to integer"); - return *(double *)astnode.ptr; + { + feclearexcept(FE_ALL_EXCEPT); + long ret = lrint(*(double *)astnode.ptr); + if (fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) + dmnsn_error(DMNSN_SEVERITY_HIGH, "Float out of range of integer."); + return ret; + } default: dmnsn_assert(false, "Invalid integer."); @@ -191,7 +197,7 @@ dmnsn_realize_global_settings(dmnsn_astnode astnode, dmnsn_scene *scene) switch (item.type) { case DMNSN_AST_ASSUMED_GAMMA: - dmnsn_diagnostic(item.location, "WARNING: assumed_gamma not supported"); + /* assumed_gamma not supported */ break; case DMNSN_AST_MAX_TRACE_LEVEL: @@ -756,9 +762,7 @@ dmnsn_realize_light_source_modifiers(dmnsn_astnode astnode, dmnsn_light *light) case DMNSN_AST_PIGMENT: case DMNSN_AST_FINISH: case DMNSN_AST_INTERIOR: - dmnsn_diagnostic(modifier.location, - "WARNING: ignoring %s applied to light source", - dmnsn_astnode_string(modifier.type)); + /* Ignore other object modifiers */ break; default: |