summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-16 22:36:32 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-16 22:36:32 +0000
commit084cb9d4b849089ab31ef7900b04749b01b5e55f (patch)
tree7dc323a49ae46cc57046d24153a6434a68d19682
parent815e12a49cecd7326dce20e4e85bb53e5d7c0495 (diff)
downloadgcc-084cb9d4b849089ab31ef7900b04749b01b5e55f.tar.gz
PR c++/38877
* tree.c (lvalue_p_1): Allow non-fields in COMPONENT_REF. * init.c (build_new): Don't call describable_type unless we have an auto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143446 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/init.c5
-rw-r--r--gcc/cp/tree.c8
-rw-r--r--gcc/testsuite/g++.dg/template/lvalue1.C31
4 files changed, 43 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ff0de590099..a58d4ac27d5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2009-01-16 Jason Merrill <jason@redhat.com>
+ PR c++/38877
+ * tree.c (lvalue_p_1): Allow non-fields in COMPONENT_REF.
+ * init.c (build_new): Don't call describable_type unless we
+ have an auto.
+
PR c++/29470
* pt.c (tsubst_decl) [USING_DECL]: Propagate access flags.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 1285f160f00..f2b79f18899 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2334,11 +2334,10 @@ build_new (tree placement, tree type, tree nelts, tree init,
orig_nelts = nelts;
orig_init = init;
- if (nelts == NULL_TREE && init != void_zero_node && list_length (init) == 1
- && describable_type (TREE_VALUE (init)))
+ if (nelts == NULL_TREE && init != void_zero_node && list_length (init) == 1)
{
tree auto_node = type_uses_auto (type);
- if (auto_node)
+ if (auto_node && describable_type (TREE_VALUE (init)))
type = do_auto_deduction (type, TREE_VALUE (init), auto_node);
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 3347bfb9f0b..04fc7e930aa 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -114,9 +114,11 @@ lvalue_p_1 (tree ref,
;
else if (is_overloaded_fn (TREE_OPERAND (ref, 1)))
/* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
- situations. */
- op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
- treat_class_rvalues_as_lvalues);
+ situations. If we're seeing a COMPONENT_REF, it's a non-static
+ member, so it isn't an lvalue. */
+ op1_lvalue_kind = clk_none;
+ else if (TREE_CODE (TREE_OPERAND (ref, 1)) != FIELD_DECL)
+ /* This can be IDENTIFIER_NODE in a template. */;
else if (DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
{
/* Clear the ordinary bit. If this object was a class
diff --git a/gcc/testsuite/g++.dg/template/lvalue1.C b/gcc/testsuite/g++.dg/template/lvalue1.C
new file mode 100644
index 00000000000..9def2a18ce4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/lvalue1.C
@@ -0,0 +1,31 @@
+// PR c++/38877
+
+template<class _T1, class _T2>
+struct pair
+{
+ typedef _T1 first_type;
+ typedef _T2 second_type;
+ _T1 first;
+ _T2 second;
+ pair () : first(), second() { }
+ pair(const _T1& __a, const _T2& __b)
+ : first(__a), second(__b) { }
+};
+
+template<class _T1, class _T2>
+inline pair<_T1, _T2>
+make_pair(_T1 __x, _T2 __y)
+{
+ return pair<_T1, _T2>(__x, __y);
+}
+
+template <int dim> class bar;
+
+template <int dim>
+pair<bar<dim> *, unsigned int>
+foo (unsigned int position)
+{
+ const pair<int,unsigned int> tmp;
+ return make_pair (new bar<dim>(tmp.first),
+ position);
+ }