File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -3154,6 +3154,28 @@ Check_types_traverse::variable(Named_object* named_object)
3154
3154
reason.c_str ());
3155
3155
var->clear_init ();
3156
3156
}
3157
+ else if (init != NULL
3158
+ && init->func_expression () != NULL )
3159
+ {
3160
+ Named_object* no = init->func_expression ()->named_object ();
3161
+ Function_type* fntype;
3162
+ if (no->is_function ())
3163
+ fntype = no->func_value ()->type ();
3164
+ else if (no->is_function_declaration ())
3165
+ fntype = no->func_declaration_value ()->type ();
3166
+ else
3167
+ go_unreachable ();
3168
+
3169
+ // Builtin functions cannot be used as function values for variable
3170
+ // initialization.
3171
+ if (fntype->is_builtin ())
3172
+ {
3173
+ error_at (init->location (),
3174
+ " invalid use of special builtin function %qs; "
3175
+ " must be called" ,
3176
+ no->message_name ().c_str ());
3177
+ }
3178
+ }
3157
3179
else if (!var->is_used ()
3158
3180
&& !var->is_global ()
3159
3181
&& !var->is_parameter ()
You can’t perform that action at this time.
0 commit comments