diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-08-20 18:35:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-20 18:35:31 -0400 |
| commit | 9cfcd0c29677e11f76846b006757ff49e05e3d6f (patch) | |
| tree | 285973ffaab76ee3ca831a9663f15be62c44d32b /src/parser.cpp | |
| parent | 1ca49b92c650e9b8988a35983e202cdb9c7ba6e7 (diff) | |
| parent | 717e2a365d9b5103f855668e4765cc154203a2bf (diff) | |
| download | zig-9cfcd0c29677e11f76846b006757ff49e05e3d6f.tar.gz zig-9cfcd0c29677e11f76846b006757ff49e05e3d6f.zip | |
Merge pull request #6103 from Vexu/extern
Disallow extern variables with initializers.
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 26233ec6a4..1253baf9ea 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -680,6 +680,9 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B AstNode *var_decl = ast_parse_var_decl(pc); if (var_decl != nullptr) { assert(var_decl->type == NodeTypeVariableDeclaration); + if (first->id == TokenIdKeywordExtern && var_decl->data.variable_declaration.expr != nullptr) { + ast_error(pc, first, "extern variables have no initializers"); + } var_decl->line = first->start_line; var_decl->column = first->start_column; var_decl->data.variable_declaration.threadlocal_tok = thread_local_kw; |
