OSDN Git Service

* typeck.c (qualify_type): Remove.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Oct 2000 18:41:49 +0000 (18:41 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Oct 2000 18:41:49 +0000 (18:41 +0000)
(composite_pointer_type): Fix handling of conversions to `cv void*'.

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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/g++.old-deja/g++.other/cvqual1.C [new file with mode: 0644]

index c2d2872..262405c 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-16  Mark Mitchell  <mark@codesourcery.com>
+
+       * typeck.c (qualify_type): Remove.
+       (composite_pointer_type): Fix handling of conversions to `cv void*'.
+
 2000-10-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * Makefile.in (parse.c, parse.h): Fix think-o in last patch.
index f6f7efd..c265808 100644 (file)
@@ -57,7 +57,6 @@ static tree common_base_type PARAMS ((tree, tree));
 static tree lookup_anon_field PARAMS ((tree, tree));
 static tree pointer_diff PARAMS ((tree, tree, tree));
 static tree build_component_addr PARAMS ((tree, tree));
-static tree qualify_type PARAMS ((tree, tree));
 static tree qualify_type_recursive PARAMS ((tree, tree));
 static tree get_delta_difference PARAMS ((tree, tree, int));
 static int comp_cv_target_types PARAMS ((tree, tree, int));
@@ -196,18 +195,6 @@ type_unknown_p (exp)
              && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node));
 }
 
-/* Return a variant of TYPE which has all the type qualifiers of LIKE
-   as well as those of TYPE.  */
-
-static tree
-qualify_type (type, like)
-     tree type, like;
-{
-  /* @@ Must do member pointers here.  */
-  return cp_build_qualified_type (type, (CP_TYPE_QUALS (type) 
-                                        | CP_TYPE_QUALS (like)));
-}
-
 /* Return a pointer or pointer to member type similar to T1, with a
    cv-qualification signature that is the union of the cv-qualification
    signatures of T1 and T2: [expr.rel], [expr.eq].  */
@@ -473,17 +460,34 @@ composite_pointer_type (t1, t2, arg1, arg2, location)
   if (TYPE_PTRMEMFUNC_P (t2))
     t2 = TYPE_PTRMEMFUNC_FN_TYPE (t2);
   
-  if (VOID_TYPE_P (TREE_TYPE (t1)))
+  /* We have:
+
+       [expr.rel]
+
+       If one of the operands has type "pointer to cv1 void*", then
+       the other has type "pointer to cv2T", and the composite pointer
+       type is "pointer to cv12 void", where cv12 is the union of cv1
+       and cv2.
+
+    If either type is a pointer to void, make sure it is T1.  */
+  if (VOID_TYPE_P (TREE_TYPE (t2)))
     {
-      if (pedantic && TYPE_PTRFN_P (t2))
-       pedwarn ("ISO C++ forbids %s between pointer of type `void *' and pointer-to-function", location);
-      result_type = qualify_type (t1, t2);
+      tree t;
+      t = t1;
+      t1 = t2;
+      t2 = t;
     }
-  else if (VOID_TYPE_P (TREE_TYPE (t2)))
+  /* Now, if T1 is a pointer to void, merge the qualifiers.  */
+  if (VOID_TYPE_P (TREE_TYPE (t1)))
     {
-      if (pedantic && TYPE_PTRFN_P (t1))
+      if (pedantic && TYPE_PTRFN_P (t2))
        pedwarn ("ISO C++ forbids %s between pointer of type `void *' and pointer-to-function", location);
-      result_type = qualify_type (t2, t1);
+      t1 = TREE_TYPE (t1);
+      t2 = TREE_TYPE (t2);
+      result_type = cp_build_qualified_type (void_type_node,
+                                            (CP_TYPE_QUALS (t1)
+                                             | CP_TYPE_QUALS (t2)));
+      result_type = build_pointer_type (result_type);
     }
   else
     {
diff --git a/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C b/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C
new file mode 100644 (file)
index 0000000..14a180c
--- /dev/null
@@ -0,0 +1,10 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+int i = 3;
+void *pv=&i;
+const void* pcv=&i;
+int main() 
+{ 
+    pcv = 0 ? pv : pcv;
+}