From 9c723da7682964d966c92633f09291e7c57e5fdb Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 30 May 2020 17:54:22 +0200 Subject: [PATCH] Change format of errror on oplist This is to enable M_GLOBAL_OPLIST_OR_DEF to properly expand the erroneous oplist to the backend generator, that will report the error. As such the erreneous oplist is surrounded by two pairs of brackets (()) --- m-core.h | 7 ++++++- m-tuple.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/m-core.h b/m-core.h index 11c69b6b..8e79de31 100644 --- a/m-core.h +++ b/m-core.h @@ -2514,13 +2514,18 @@ m_core_hash (const void *str, size_t length) /* If a symbol composed of M_OPL_##a() exists and is defined as an oplist, it returns it otherwise it returns M_DEFAULT_OPLIST. Global oplist is limited to typedef types. + NOTE1: It first tests if the type doesn't start with a parenthesis, + in which case concatenation cannot be used. + NOTE: It doesn't test if M_OPL_##a() is exactly an oplist (M_OPLIST_P) + but rather than if it starts with parenthesis: this is to allow + M_OPL_a() to expand into an invalid oplist ((M_LIB_ERRROR())) */ #define M_GLOBAL_OPLIST_OR_DEF(a) \ M_IF( M_PARENTHESIS_P(a))(M_GLOBALI_OPLIST_DEFAULT1, M_GLOBALI_OPLIST_OR_DEF_ELSE)(a) #define M_GLOBALI_OPLIST_DEFAULT1(a) M_GLOBALI_OPLIST_DEFAULT2 #define M_GLOBALI_OPLIST_DEFAULT2() M_DEFAULT_OPLIST #define M_GLOBALI_OPLIST_OR_DEF_ELSE(a) M_GLOBALI_OPLIST_OR_DEF_ELSE2(a, M_C(M_OPL_, a)()) -#define M_GLOBALI_OPLIST_OR_DEF_ELSE2(a, op) M_IF( M_OPLIST_P(op))(M_C(M_OPL_, a), M_GLOBALI_OPLIST_DEFAULT2) +#define M_GLOBALI_OPLIST_OR_DEF_ELSE2(a, op) M_IF( M_PARENTHESIS_P(op))(M_C(M_OPL_, a), M_GLOBALI_OPLIST_DEFAULT2) /* Register simple classic C types (no qualifier) */ diff --git a/m-tuple.h b/m-tuple.h index c5c136cf..f7e010c6 100644 --- a/m-tuple.h +++ b/m-tuple.h @@ -578,7 +578,7 @@ namespace m_tuple { /* Prepare a clean compilation failure */ #define TUPLEI_OPLIST_FAILURE(name, ...) \ - M_LIB_ERROR(ONE_ARGUMENT_OF_TUPLE_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__) + ((M_LIB_ERROR(ONE_ARGUMENT_OF_TUPLE_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__))) #define TUPLEI_OPLIST_P3(name, ...) \ (M_IF_METHOD_ALL(INIT, __VA_ARGS__)(INIT(M_C(name,_init)),), \