aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-05-01 11:47:49 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-05-01 11:47:49 +0000
commit4b48a93e898353dc4bbe1bec80ec56736fc16beb (patch)
tree29e5979336ab2d00b77103686f6ca6668cc06e01 /gcc
parent1bcea8d764215f8b04d69c5e8a991b715db54304 (diff)
downloadgcc-4b48a93e898353dc4bbe1bec80ec56736fc16beb.zip
gcc-4b48a93e898353dc4bbe1bec80ec56736fc16beb.tar.gz
gcc-4b48a93e898353dc4bbe1bec80ec56736fc16beb.tar.bz2
call.c (build_new_op): Convert args from reference here.
cp: * call.c (build_new_op): Convert args from reference here. (build_conditional_expr): Don't convert here. testsuite: * g++.old-deja/g++.pt/ref4.C: New test. From-SVN: r41721
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c11
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/ref4.C25
4 files changed, 40 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5255f15..b082ce2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
+ * call.c (build_new_op): Convert args from reference here.
+ (build_conditional_expr): Don't convert here.
+
+2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
+
* spew.c (last_token_id): New static variable.
(read_token): Set it here.
(yyerror): Use it here.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4d4d033..d2a1c95 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2892,11 +2892,6 @@ build_conditional_expr (arg1, arg2, arg3)
|| TREE_TYPE (arg3) == error_mark_node)
return error_mark_node;
- /* Convert from reference types to ordinary types; no expressions
- really have reference type in C++. */
- arg2 = convert_from_reference (arg2);
- arg3 = convert_from_reference (arg3);
-
/* [expr.cond]
If either the second or the third operand has type (possibly
@@ -3244,6 +3239,12 @@ build_new_op (code, flags, arg1, arg2, arg3)
if (arg3 && TREE_CODE (arg3) == OFFSET_REF)
arg3 = resolve_offset_ref (arg3);
+ arg1 = convert_from_reference (arg1);
+ if (arg2)
+ arg2 = convert_from_reference (arg2);
+ if (arg3)
+ arg3 = convert_from_reference (arg3);
+
if (code == COND_EXPR)
{
if (arg2 == NULL_TREE
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bc82921..12d5b6e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.pt/ref4.C: New test.
+
2001-04-30 Richard Henderson <rth@redhat.com>
* gcc.dg/20000724-1.c: Revert last change.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ref4.C b/gcc/testsuite/g++.old-deja/g++.pt/ref4.C
new file mode 100644
index 0000000..1291dc1
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/ref4.C
@@ -0,0 +1,25 @@
+// Build don't link:
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com>
+
+// Bug 2664. We failed to convert_from_reference for non-type
+// template parms.
+
+struct cow { };
+
+cow c;
+
+void func (cow &c) {}
+void operator-(cow &c) {}
+
+template<cow &C> void test()
+{
+ func(C); //OK
+ -C; //bogus error
+}
+
+int main()
+{
+ test<c> ();
+}