]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/18464 (error message about "non-lvalue in unary '&'" when using ?: operator)
authorMark Mitchell <mark@codesourcery.com>
Sun, 1 May 2005 23:26:25 +0000 (23:26 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 1 May 2005 23:26:25 +0000 (23:26 +0000)
PR c++/18464
* call.c (build_this): In templates, do not bother with
build_unary_op.
* typeck.c (unary_complex_lvalue): In a template, always refuse
simplifications.

PR c++/18464
* g++.dg/template/cond5.C: New test.

From-SVN: r99084

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog

index 2622d073203bb057ce1164fa9eb1ea2505e666fa..51dc307d5e4fcd044ac5a694ec855ab7c25e91e9 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/18464
+       * call.c (build_this): In templates, do not bother with
+       build_unary_op.
+       * typeck.c (unary_complex_lvalue): In a template, always refuse
+       simplifications.
+
 2005-04-25  Roger Sayle  <roger@eyesopen.com>
            Mark Mitchell  <mark@codesourcery.com>
 
index 14b877cc415f78a9a7b1afa0f5919f38b60999d3..aeed3155df4b6c7ab716ce4d8aa6d0fcd406a275 100644 (file)
@@ -2203,10 +2203,18 @@ any_strictly_viable (struct z_candidate *cands)
   return false;
 }
 
+/* OBJ is being used in an expression like "OBJ.f (...)".  In other
+   words, it is about to become the "this" pointer for a member
+   function call.  Take the address of the object.  */
+
 static tree
 build_this (tree obj)
 {
-  /* Fix this to work on non-lvalues.  */
+  /* In a template, we are only concerned about the type of the
+     expression, so we can take a shortcut.  */
+  if (processing_template_decl)
+    return build_address (obj);
+
   return build_unary_op (ADDR_EXPR, obj, 0);
 }
 
index 634ca6685fbf1a4bd3bd37500cd6e1aa1f5c8459..3af17a8b95f0f46140af3719e5a4d6b6f2233fa2 100644 (file)
@@ -4166,11 +4166,18 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert)
    for certain kinds of expressions which are not really lvalues
    but which we can accept as lvalues.
 
-   If ARG is not a kind of expression we can handle, return zero.  */
+   If ARG is not a kind of expression we can handle, return
+   NULL_TREE.  */
    
 tree
 unary_complex_lvalue (enum tree_code code, tree arg)
 {
+  /* Inside a template, making these kinds of adjustments is
+     pointless; we are only concerned with the type of the
+     expression.  */
+  if (processing_template_decl)
+    return NULL_TREE;
+
   /* Handle (a, b) used as an "lvalue".  */
   if (TREE_CODE (arg) == COMPOUND_EXPR)
     {
index 67bc542aa9784634e2874bc3d1c70f49a7412005..f179a5cc7de5827b3af03eba99afd714d2ce0752 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/18464
+       * g++.dg/template/cond5.C: New test.
+
 2005-05-01  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c/21213