re PR c++/40687 ([C++0x]: error with auto and 7.1.6.4/7 in N2914)

PR c++/40687
	* pt.c (do_auto_deduction): Diagnose inconsistent deduction.

From-SVN: r153855
This commit is contained in:
Jason Merrill 2009-11-03 12:11:08 -05:00 committed by Jason Merrill
parent 64c2f8defe
commit 2e32c99e12
4 changed files with 25 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/40687
* pt.c (do_auto_deduction): Diagnose inconsistent deduction.
2009-11-02 Dodji Seketeli <dodji@redhat.com>
PR c++/37093

View File

@ -17796,10 +17796,7 @@ make_args_non_dependent (VEC(tree,gc) *args)
tree
make_auto (void)
{
tree au;
/* ??? Is it worth caching this for multiple autos at the same level? */
au = cxx_make_type (TEMPLATE_TYPE_PARM);
tree au = cxx_make_type (TEMPLATE_TYPE_PARM);
TYPE_NAME (au) = build_decl (BUILTINS_LOCATION,
TYPE_DECL, get_identifier ("auto"), au);
TYPE_STUB_DECL (au) = TYPE_NAME (au);
@ -17877,6 +17874,19 @@ do_auto_deduction (tree type, tree init, tree auto_node)
return error_mark_node;
}
/* If the list of declarators contains more than one declarator, the type
of each declared variable is determined as described above. If the
type deduced for the template parameter U is not the same in each
deduction, the program is ill-formed. */
if (TREE_TYPE (auto_node)
&& !same_type_p (TREE_TYPE (auto_node), TREE_VEC_ELT (targs, 0)))
{
error ("inconsistent deduction for %qT: %qT and then %qT",
auto_node, TREE_TYPE (auto_node), TREE_VEC_ELT (targs, 0));
return error_mark_node;
}
TREE_TYPE (auto_node) = TREE_VEC_ELT (targs, 0);
if (processing_template_decl)
targs = add_to_template_args (current_template_args (), targs);
return tsubst (type, targs, tf_warning_or_error, NULL_TREE);

View File

@ -1,3 +1,8 @@
2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/40687
* g++.dg/cpp0x/auto3.C: Remove xfail.
2009-11-03 Tobias Burnus <burnus@net-b.de>
PR fortran/41907

View File

@ -7,7 +7,7 @@ auto x; // { dg-error "auto" }
// If the type deduced for the template parameter U is not the same in each
// deduction, the program is ill-formed.
auto i = 42, j = 42.0; // { dg-error "" "" { xfail *-*-* } }
auto i = 42, j = 42.0; // { dg-error "auto" }
// New CWG issue
auto a[2] = { 1, 2 }; // { dg-error "auto" }