diff options
Diffstat (limited to 'lib/Parser')
| -rw-r--r-- | lib/Parser/Parser.cc | 8 | ||||
| -rw-r--r-- | lib/Parser/ParserFunction.cc | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Parser/Parser.cc b/lib/Parser/Parser.cc index 9563650..260472c 100644 --- a/lib/Parser/Parser.cc +++ b/lib/Parser/Parser.cc @@ -542,7 +542,15 @@ std::unique_ptr<StmtAST> Parser::ParseStatementImpl() { return nullptr; } std::string Name = Lex.IdentifierStr; + int Line = Lex.getLine(); getNextToken(); + if (CurTok == '[' || CurTok == '.' || CurTok == '^') { + // Consume the whole designator so it cannot replay as statements. + std::vector<DesignatorAccess> Dummy; + ParseDesignatorSuffix(Dummy); + fprintf(stderr, "Error: INPUT target must be a plain variable at line %d\n", Line); + return nullptr; + } return std::make_unique<InputStmtAST>(Name); } else if (CurTok == tok_output) { diff --git a/lib/Parser/ParserFunction.cc b/lib/Parser/ParserFunction.cc index 776a980..81db2c7 100644 --- a/lib/Parser/ParserFunction.cc +++ b/lib/Parser/ParserFunction.cc @@ -106,6 +106,13 @@ std::optional<std::vector<ParamDecl>> Parser::ParsePrototypeArgs(bool AllowByRef return std::nullopt; } + for (const ParamDecl &Prev : Params) { + if (Prev.Name == P.Name) { + fprintf(stderr, "Error: Duplicate parameter name '%s' at line %d\n", + P.Name.c_str(), Lex.getLine()); + return std::nullopt; + } + } Params.push_back(std::move(P)); if (CurTok == ')') break; @@ -114,6 +121,10 @@ std::optional<std::vector<ParamDecl>> Parser::ParsePrototypeArgs(bool AllowByRef return std::nullopt; } getNextToken(); + if (CurTok == ')') { + fprintf(stderr, "Error: Expected another parameter after ',' at line %d\n", Lex.getLine()); + return std::nullopt; + } } getNextToken(); return Params; |
