diff options
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c9cac55..091edd5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5488,11 +5488,20 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, DECL_INITIALIZED_IN_CLASS_P (decl) = 1; auto_node = type_uses_auto (type); - if (auto_node && !type_dependent_expression_p (init)) + if (auto_node) { - type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node); - if (type == error_mark_node) - return; + if (init == NULL_TREE) + { + error ("declaration of %q#D has no initializer", decl); + TREE_TYPE (decl) = error_mark_node; + return; + } + else if (!type_dependent_expression_p (init)) + { + type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node); + if (type == error_mark_node) + return; + } } if (processing_template_decl) |