Commit 2e32c99e by Jason Merrill Committed by Jason Merrill

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
parent 64c2f8de
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> 2009-11-02 Dodji Seketeli <dodji@redhat.com>
PR c++/37093 PR c++/37093
......
...@@ -17796,10 +17796,7 @@ make_args_non_dependent (VEC(tree,gc) *args) ...@@ -17796,10 +17796,7 @@ make_args_non_dependent (VEC(tree,gc) *args)
tree tree
make_auto (void) make_auto (void)
{ {
tree au; tree au = cxx_make_type (TEMPLATE_TYPE_PARM);
/* ??? Is it worth caching this for multiple autos at the same level? */
au = cxx_make_type (TEMPLATE_TYPE_PARM);
TYPE_NAME (au) = build_decl (BUILTINS_LOCATION, TYPE_NAME (au) = build_decl (BUILTINS_LOCATION,
TYPE_DECL, get_identifier ("auto"), au); TYPE_DECL, get_identifier ("auto"), au);
TYPE_STUB_DECL (au) = TYPE_NAME (au); TYPE_STUB_DECL (au) = TYPE_NAME (au);
...@@ -17877,6 +17874,19 @@ do_auto_deduction (tree type, tree init, tree auto_node) ...@@ -17877,6 +17874,19 @@ do_auto_deduction (tree type, tree init, tree auto_node)
return error_mark_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) if (processing_template_decl)
targs = add_to_template_args (current_template_args (), targs); targs = add_to_template_args (current_template_args (), targs);
return tsubst (type, targs, tf_warning_or_error, NULL_TREE); return tsubst (type, targs, tf_warning_or_error, NULL_TREE);
......
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> 2009-11-03 Tobias Burnus <burnus@net-b.de>
PR fortran/41907 PR fortran/41907
......
...@@ -7,7 +7,7 @@ auto x; // { dg-error "auto" } ...@@ -7,7 +7,7 @@ auto x; // { dg-error "auto" }
// If the type deduced for the template parameter U is not the same in each // If the type deduced for the template parameter U is not the same in each
// deduction, the program is ill-formed. // 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 // New CWG issue
auto a[2] = { 1, 2 }; // { dg-error "auto" } auto a[2] = { 1, 2 }; // { dg-error "auto" }
......
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