aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/cp/typeck.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto14.C29
5 files changed, 48 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 33fbcef..448b558 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-01 Jason Merrill <jason@redhat.com>
+
+ PR c++/40306
+ PR c++/40307
+ * decl.c (cp_finish_decl): Handle auto deduction from ().
+ * typeck.c (build_x_indirect_ref): Handle dereferencing an operand
+ with dependent type that is known to be a pointer.
+
2009-06-02 Simon Martin <simartin@users.sourceforge.net>
PR c++/38089
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a626a71..645ac7e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5531,7 +5531,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
TREE_TYPE (decl) = error_mark_node;
return;
}
- else if (describable_type (init))
+ if (TREE_CODE (init) == TREE_LIST)
+ init = build_x_compound_expr_from_list (init, "initializer");
+ if (describable_type (init))
{
type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node);
if (type == error_mark_node)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index eb28a3d2..6f6bd39 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2449,6 +2449,10 @@ build_x_indirect_ref (tree expr, const char *errorstring,
if (processing_template_decl)
{
+ /* Retain the type if we know the operand is a pointer so that
+ describable_type doesn't make auto deduction break. */
+ if (TREE_TYPE (expr) && POINTER_TYPE_P (TREE_TYPE (expr)))
+ return build_min (INDIRECT_REF, TREE_TYPE (TREE_TYPE (expr)), expr);
if (type_dependent_expression_p (expr))
return build_min_nt (INDIRECT_REF, expr);
expr = build_non_dependent_expr (expr);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6865ff2..9743b5d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-02 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/auto14.C: New.
+
2009-06-02 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/alignment6.adb: Remove XFAIL.
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto14.C b/gcc/testsuite/g++.dg/cpp0x/auto14.C
new file mode 100644
index 0000000..cb2c4e0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto14.C
@@ -0,0 +1,29 @@
+// PR c++/40306, c++/40307
+// { dg-options "-std=c++0x" }
+// { dg-do run }
+
+template< typename T >
+struct test {
+ test run() {
+ auto tmp = *this;
+ return tmp;
+ }
+ test run_pass() {
+ test tmp( *this );
+ return tmp;
+ }
+
+ test run_fail() {
+ auto tmp( *this );
+ return tmp;
+ }
+};
+
+int main()
+{
+ test<int> x;
+ x.run();
+ x.run_pass();
+ x.run_fail();
+ return 0;
+}