Commit 0a3098bb by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/37965 (ICE with invalid auto variable in template)

	PR c++/37965
	* decl.c (cp_finish_decl): Diagnose type_uses_auto type with
	no initializer.

	* g++.dg/cpp0x/auto7.C: New test.

From-SVN: r141501
parent 728a8a74
2008-10-31 Jakub Jelinek <jakub@redhat.com>
PR c++/37965
* decl.c (cp_finish_decl): Diagnose type_uses_auto type with
no initializer.
2008-10-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org> 2008-10-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 11492 PR 11492
......
...@@ -5488,12 +5488,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -5488,12 +5488,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
DECL_INITIALIZED_IN_CLASS_P (decl) = 1; DECL_INITIALIZED_IN_CLASS_P (decl) = 1;
auto_node = type_uses_auto (type); auto_node = type_uses_auto (type);
if (auto_node && !type_dependent_expression_p (init)) if (auto_node)
{
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); type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node);
if (type == error_mark_node) if (type == error_mark_node)
return; return;
} }
}
if (processing_template_decl) if (processing_template_decl)
{ {
......
2008-10-31 Jakub Jelinek <jakub@redhat.com>
PR c++/37965
* g++.dg/cpp0x/auto7.C: New test.
2008-10-31 Mikael Morin <mikael.morin@tele2.fr> 2008-10-31 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35840 PR fortran/35840
......
// PR c++/37965
// Negative test for auto
// { dg-options "-std=c++0x" }
auto i = 6;
auto j; // { dg-error "has no initializer" }
template<int> struct A
{
static auto k = 7;
static auto l; // { dg-error "has no initializer" }
auto m; // { dg-error "has no initializer" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment