]> git.draconx.ca Git - cdecl99.git/blobdiff - src/parse-decl.c
Fix yyerror's signature.
[cdecl99.git] / src / parse-decl.c
index 059f5f770a2d6ecbb7af799a89f10363d54b93f0..0cf830d8f5faa2f31c13106a1f475c6cddc24d1b 100644 (file)
@@ -373,12 +373,18 @@ static bool forall_declarators(struct cdecl *decl,
 struct cdecl *cdecl_parse_decl(const char *declstr)
 {
        YY_BUFFER_STATE state;
+       yyscan_t scanner;
        struct cdecl *decl;
        int rc;
 
-       state = yy_scan_string(declstr);
-       rc = yyparse(&decl);
-       yy_delete_buffer(state);
+       rc = yylex_init(&scanner);
+       if (rc != 0)
+               return NULL;
+
+       state = yy_scan_string(declstr, scanner);
+       rc = yyparse(scanner, &decl);
+       yy_delete_buffer(state, scanner);
+       yylex_destroy(scanner);
 
        if (rc != 0)
                return NULL;
@@ -395,6 +401,11 @@ struct cdecl *cdecl_parse_decl(const char *declstr)
 
                if (!valid_declspecs(i, true))
                        goto err;
+
+               if (is_abstract(i->declarators) && (i != decl || i->next)) {
+                       fprintf(stderr, "mixing type names and declarations is not allowed\n");
+                       goto err;
+               }
        }
 
        return decl;