[qfcc] Apply suspenders and a belt to the dimension check

Maybe there's a different trick to making gcc see that the dimension was
already check, but this works nicely size if the two calculations
differ, there are bigger problems.
This commit is contained in:
Bill Currie 2024-09-24 11:17:01 +09:00
parent 5a928581ab
commit f4d8af400e

View file

@ -49,6 +49,8 @@
#include "tools/qfcc/include/type.h"
#include "tools/qfcc/include/value.h"
#define MAX_SIGNATURE 16
static struct DARRAY_TYPE (algebra_t *) algebras = DARRAY_STATIC_INIT (16);
static void
@ -234,6 +236,9 @@ algebra_init (algebra_t *a)
int m = a->minus;
int z = a->zero;
int d = p + m + z;
if (d > MAX_SIGNATURE) {
internal_error (0, "algebra too large");
}
metric_init (&a->metric, p, m, z);
a->dimension = d;
a->num_components = 1 << d;
@ -380,7 +385,7 @@ algebra_type (const type_t *type, const expr_t *params)
error (err, "signature must be positive");
return type_default;
}
if (dim > 16) {
if (dim > MAX_SIGNATURE) {
error (err, "signature too large (that's %zd components!)",
((size_t) 1) << dim);
return type_default;