aboutsummaryrefslogtreecommitdiff
path: root/src/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-28 15:31:53 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-28 15:31:53 -0400
commitca76fb335ae7b3f820beeeed5667950e7489711e (patch)
treee0ef48cce92aeeb92241ef98c65bf3af84c05ca4 /src/typecheck.c
parent4de0fee8f694503b453e04084caaab55f8670b6c (diff)
Add compiler guards for GCC directives
Diffstat (limited to 'src/typecheck.c')
-rw-r--r--src/typecheck.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/typecheck.c b/src/typecheck.c
index 7920abc7..861431e0 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -21,8 +21,10 @@
type_t *parse_type_ast(env_t *env, type_ast_t *ast)
{
+#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
+#endif
switch (ast->tag) {
case VarTypeAST: {
const char *name = Match(ast, VarTypeAST)->name;
@@ -134,7 +136,9 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast)
}
case UnknownTypeAST: code_err(ast, "I don't know how to get this type");
}
+#ifdef __GNUC__
#pragma GCC diagnostic pop
+#endif
errx(1, "Unreachable");
}
@@ -564,8 +568,10 @@ type_t *get_clause_type(env_t *env, type_t *subject_t, when_clause_t *clause)
type_t *get_type(env_t *env, ast_t *ast)
{
if (!ast) return NULL;
+#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
+#endif
switch (ast->tag) {
case None: {
if (!Match(ast, None)->type)
@@ -1398,7 +1404,9 @@ type_t *get_type(env_t *env, ast_t *ast)
case Unknown: code_err(ast, "I can't figure out the type of: ", ast_to_str(ast));
case Deserialize: return parse_type_ast(env, Match(ast, Deserialize)->type);
}
+#ifdef __GNUC__
#pragma GCC diagnostic pop
+#endif
code_err(ast, "I can't figure out the type of: ", ast_to_str(ast));
}
@@ -1544,13 +1552,17 @@ PUREFUNC bool is_constant(env_t *env, ast_t *ast)
case TextLiteral: {
CORD literal = Match(ast, TextLiteral)->cord;
CORD_pos i;
+#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
+#endif
CORD_FOR(i, literal) {
if (!isascii(CORD_pos_fetch(i)))
return false; // Non-ASCII requires grapheme logic, not constant
}
+#ifdef __GNUC__
#pragma GCC diagnostic pop
+#endif
return true; // Literal ASCII string, OK
}
case Not: return is_constant(env, Match(ast, Not)->value);