diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-07-23 18:35:18 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-07-23 18:35:18 +0300 |
commit | f2fc8861fe241683ccc4bf026fbeeefe6ba1e04e (patch) | |
tree | a68a8d8ffa6d47c1ddd923d2dc9efd3777efcb0f /src | |
parent | 09e6cad37d4559f83cd27075f0c7c1524d502321 (diff) | |
download | ngc-master.tar.gz ngc-master.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -723,10 +723,12 @@ static void expand_instance(char *id, char *instance) if (tokens_len(&type_params) != tokens_len(&type_args)) { fprintf(stderr, "mismatch type params vs args\n"); - drop_tokens(&type_traits); - drop_tokens(&type_params); - drop_tokens(&type_args); - goto cleanup; + abort(); + } + + if (tokens_len(&type_traits) != tokens_len(&type_args)) { + fprintf(stderr, "mismatch type traits vs args\n"); + abort(); } for (size_t i = 0; i < tokens_len(&type_params); ++i) { @@ -754,20 +756,25 @@ static void expand_instance(char *id, char *instance) if (tokens_len(&const_params) != tokens_len(&const_args)) { fprintf(stderr, "mismatch const params vs args\n"); - drop_tokens(&const_types); - drop_tokens(&const_params); - drop_tokens(&const_args); - goto cleanup; + abort(); + } + + if (tokens_len(&const_types) != tokens_len(&const_args)) { + fprintf(stderr, "mismatch const types vs args\n"); + abort(); } for (size_t i = 0; i < tokens_len(&const_params); ++i) { + char *type = *tokens_at(&const_types, i); char *name = *tokens_at(&const_params, i); - char *type = *tokens_at(&const_args, i); + char *arg = *tokens_at(&const_args, i); - body = replace_id(body, name, type); + printf("_Static_assert(_Generic((%s), %s: 1, default: 0));\n", arg, type); + + body = replace_id(body, name, arg); if (super) - super = replace_id(super, name, type); + super = replace_id(super, name, arg); } if (super) |