OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 May 2001 11:47:49 +0000 (11:47 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 May 2001 11:47:49 +0000 (11:47 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41721 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.pt/ref4.C [new file with mode: 0644]

index 5255f15..b082ce2 100644 (file)
@@ -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.
index 4d4d033..d2a1c95 100644 (file)
@@ -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
index bc82921..12d5b6e 100644 (file)
@@ -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 (file)
index 0000000..1291dc1
--- /dev/null
@@ -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> ();
+}