From ca76fb335ae7b3f820beeeed5667950e7489711e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 28 Mar 2025 15:31:53 -0400 Subject: Add compiler guards for GCC directives --- src/typecheck.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/typecheck.c') 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); -- cgit v1.2.3