aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-03 12:11:08 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-11-03 12:11:08 -0500
commit2e32c99e12b96854cccb5cf037718a6cb1df1e72 (patch)
tree605793a803de29086d4e960d309080a408b7b078
parent64c2f8defe31677024073ed70b5fbdbc52d0bff4 (diff)
downloadgcc-2e32c99e12b96854cccb5cf037718a6cb1df1e72.zip
gcc-2e32c99e12b96854cccb5cf037718a6cb1df1e72.tar.gz
gcc-2e32c99e12b96854cccb5cf037718a6cb1df1e72.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto3.C2
4 files changed, 25 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 10fa16a..6c7bdc6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5af348a..db2f969 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 859b5f1..ab594d7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto3.C b/gcc/testsuite/g++.dg/cpp0x/auto3.C
index 3cea856..f792c07 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto3.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C
@@ -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" }