aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-07-17 20:16:23 +0300
committerVeikka Tuominen <git@vexu.eu>2020-07-18 16:45:07 +0300
commit596ca6cf70cf43c27e31bbcfc36bcdc70b13897a (patch)
tree1f6915d289cf77ac70d7a7f23ca7f2b6f73e4aa6 /src/analyze.cpp
parent78962eeeda07d613ebdfd239082268a6702c19db (diff)
downloadzig-596ca6cf70cf43c27e31bbcfc36bcdc70b13897a.tar.gz
zig-596ca6cf70cf43c27e31bbcfc36bcdc70b13897a.zip
allow non-pointer extern opaque variables
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 67c900507d..66f3f28b50 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3823,15 +3823,18 @@ static Error resolve_decl_container(CodeGen *g, TldContainer *tld_container) {
}
}
-ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry) {
+ZigType *validate_var_type(CodeGen *g, AstNodeVariableDeclaration *source_node, ZigType *type_entry) {
switch (type_entry->id) {
case ZigTypeIdInvalid:
return g->builtin_types.entry_invalid;
+ case ZigTypeIdOpaque:
+ if (source_node->is_extern)
+ return type_entry;
+ ZIG_FALLTHROUGH;
case ZigTypeIdUnreachable:
case ZigTypeIdUndefined:
case ZigTypeIdNull:
- case ZigTypeIdOpaque:
- add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",
+ add_node_error(g, source_node->type, buf_sprintf("variable of type '%s' not allowed",
buf_ptr(&type_entry->name)));
return g->builtin_types.entry_invalid;
case ZigTypeIdComptimeFloat:
@@ -3973,7 +3976,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
} else {
tld_var->analyzing_type = true;
ZigType *proposed_type = analyze_type_expr(g, tld_var->base.parent_scope, var_decl->type);
- explicit_type = validate_var_type(g, var_decl->type, proposed_type);
+ explicit_type = validate_var_type(g, var_decl, proposed_type);
}
}