aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2000-10-16 18:41:49 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2000-10-16 18:41:49 +0000
commit634790f4bda50db3cde193beeb9141b7a079ac21 (patch)
treebec41353bb57585688f9c8d2f039941dbe3eb3e4 /gcc
parentebd5daee50cb7f127bf034da15ae9eb47fe0b2f4 (diff)
downloadgcc-634790f4bda50db3cde193beeb9141b7a079ac21.zip
gcc-634790f4bda50db3cde193beeb9141b7a079ac21.tar.gz
gcc-634790f4bda50db3cde193beeb9141b7a079ac21.tar.bz2
typeck.c (qualify_type): Remove.
* typeck.c (qualify_type): Remove. (composite_pointer_type): Fix handling of conversions to `cv void*'. From-SVN: r36889
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c44
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/cvqual1.C10
3 files changed, 39 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c2d2872..262405c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f6f7efd..c265808 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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
index 0000000..14a180c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C
@@ -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;
+}