]> git.draconx.ca Git - cdecl99.git/blobdiff - src/parse.y
libcdecl: Remove error code argument from cdecl__err.
[cdecl99.git] / src / parse.y
index 14d593ef1622f57a97d0b5bbb26023a07ce0fafb..03fa1395a6df02fa27f7ec864998c6251c143388 100644 (file)
@@ -1,7 +1,7 @@
 %code top {
 /*
  *  Parser for C declarations.
- *  Copyright © 2011-2012, 2021, 2023 Nick Bowler
+ *  Copyright © 2011-2012, 2021, 2023-2024 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -120,6 +120,7 @@ static size_t yytnamerr_copy(char *dst, const char *src)
 
 %code requires {
 #include <inttypes.h>
+#include <stdbool.h>
 }
 
 %code provides {
@@ -131,7 +132,7 @@ const char *cdecl__token_name(unsigned token);
 %union {
        uintmax_t uintval;
        unsigned spectype;
-       _Bool boolval;
+       bool boolval;
        struct cdecl_declspec *declspec;
        struct cdecl_declarator *declarator;
        struct cdecl *decl;
@@ -617,11 +618,16 @@ const char *cdecl__token_name(unsigned token)
        return yytname[YYTRANSLATE(token)];
 }
 
-static void
+/*
+ * Current versions of GCC (up to 13) want to inline this function into the
+ * parser even when optimizing for size and the results are not great, so
+ * try to prevent such inlining.
+ */
+CDECL__NOINLINE static void
 yyerror(YYLTYPE *loc, yyscan_t scanner, struct cdecl **out, const char *err)
 {
        if (strstr(err, yytname[YYTRANSLATE(T_LEX_ERROR)]))
                return;
 
-       cdecl__err(CDECL_ENOPARSE, "%s", err);
+       cdecl__err("%s", err);
 }