aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2001-01-02 10:20:30 -0500
committerJason Merrill <jason@gcc.gnu.org>2001-01-02 10:20:30 -0500
commit3c8c2a0ae2bafe9c93e792fb18134e47cb8a469a (patch)
treecd408a5dd602099854e1d566db6edd18575f2d07
parent8515dc81527794ee3437aa38b56fbfe7e887fc70 (diff)
downloadgcc-3c8c2a0ae2bafe9c93e792fb18134e47cb8a469a.zip
gcc-3c8c2a0ae2bafe9c93e792fb18134e47cb8a469a.tar.gz
gcc-3c8c2a0ae2bafe9c93e792fb18134e47cb8a469a.tar.bz2
typeck.c (strip_all_pointer_quals): Also strip quals from pointer-to-member types.
* typeck.c (strip_all_pointer_quals): Also strip quals from pointer-to-member types. * Make-lang.in (cp/TAGS): Use --no-globals. Ignore parse.c, and treat parse.y as C. * call.c (build_new_method_call): Do evaluate the object parameter when accessing a static member. * typeck.c (build_component_ref): Likewise. From-SVN: r38619
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/Make-lang.in6
-rw-r--r--gcc/cp/call.c17
-rw-r--r--gcc/cp/typeck.c8
-rw-r--r--gcc/testsuite/g++.old-deja/g++.martin/eval1.C1
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/cast7.C11
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/static16.C24
7 files changed, 73 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a3bf42d..43ca3b4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+2001-01-02 Jason Merrill <jason@redhat.com>
+
+ * typeck.c (strip_all_pointer_quals): Also strip quals from
+ pointer-to-member types.
+
+ * Make-lang.in (cp/TAGS): Use --no-globals. Ignore parse.c, and treat
+ parse.y as C.
+
+ * call.c (build_new_method_call): Do evaluate the object parameter
+ when accessing a static member.
+ * typeck.c (build_component_ref): Likewise.
+
2001-01-02 Andreas Jaeger <aj@suse.de>
* decl.c (cp_missing_noreturn_ok_p): New.
@@ -32,6 +44,9 @@
2000-12-22 Jason Merrill <jason@redhat.com>
+ * pt.c (more_specialized): Don't optimize len==0.
+ (fn_type_unification): If we're adding the return type, increase len.
+
* typeck.c (build_binary_op): Fix pmf comparison logic.
* call.c (joust): Use DECL_NONSTATIC_MEMBER_FUNCTION_P, not
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 0c1347a..ba03731 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -279,9 +279,7 @@ cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
# Update the tags table.
cp/TAGS: force
cd $(srcdir)/cp ; \
- etags *.c *.h ; \
- echo 'l' | tr 'l' '\f' >> TAGS ; \
- echo 'parse.y,0' >> TAGS ; \
- etags -a ../*.h ../*.c;
+ etags --no-globals -l c `echo *.c | sed 's/parse.c//'` \
+ parse.y *.h ../*.c ../*.h;
.PHONY: cp/TAGS
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c8aed73..3c1f9aa 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4278,6 +4278,7 @@ build_new_method_call (instance, name, args, basetype_path, flags)
tree pretty_name;
tree user_args;
tree templates = NULL_TREE;
+ tree call;
int template_only = 0;
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -4492,10 +4493,18 @@ build_new_method_call (instance, name, args, basetype_path, flags)
|| resolves_to_fixed_type_p (instance, 0)))
flags |= LOOKUP_NONVIRTUAL;
- return build_over_call
- (cand,
- TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE ? mem_args : args,
- flags);
+ if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE)
+ call = build_over_call (cand, mem_args, flags);
+ else
+ {
+ call = build_over_call (cand, args, flags);
+ /* Do evaluate the object parameter in a call to a static member
+ function. */
+ if (TREE_SIDE_EFFECTS (instance))
+ call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
+ }
+
+ return call;
}
/* Returns non-zero iff standard conversion sequence ICS1 is a proper
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 23efc90..443fb2d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2208,6 +2208,11 @@ build_component_ref (datum, component, basetype_path, protect)
mark_used (field);
else
TREE_USED (field) = 1;
+
+ /* Do evaluate the object when accessing a static member. */
+ if (TREE_SIDE_EFFECTS (datum))
+ field = build (COMPOUND_EXPR, TREE_TYPE (field), datum, field);
+
return field;
}
}
@@ -7131,6 +7136,9 @@ strip_all_pointer_quals (type)
{
if (TREE_CODE (type) == POINTER_TYPE)
return build_pointer_type (strip_all_pointer_quals (TREE_TYPE (type)));
+ else if (TREE_CODE (type) == OFFSET_TYPE)
+ return build_offset_type (TYPE_OFFSET_BASETYPE (type),
+ strip_all_pointer_quals (TREE_TYPE (type)));
else
return TYPE_MAIN_VARIANT (type);
}
diff --git a/gcc/testsuite/g++.old-deja/g++.martin/eval1.C b/gcc/testsuite/g++.old-deja/g++.martin/eval1.C
index e8a19f6..6488da5 100644
--- a/gcc/testsuite/g++.old-deja/g++.martin/eval1.C
+++ b/gcc/testsuite/g++.old-deja/g++.martin/eval1.C
@@ -1,5 +1,4 @@
// Postfix expression must be evaluated even if accessing a static member.
-// execution test - XFAIL *-*-*
struct S
{
diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast7.C b/gcc/testsuite/g++.old-deja/g++.other/cast7.C
new file mode 100644
index 0000000..8cdaa99
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/cast7.C
@@ -0,0 +1,11 @@
+// Test that we can add cv-quals in a static cast to a pointer-to-base type.
+
+struct A { int i; };
+struct B : public A {};
+
+int main()
+{
+ int B::* bp = &B::i;
+ const int A::* ap = static_cast<const int A::*>(bp);
+ return ap != bp;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/static16.C b/gcc/testsuite/g++.old-deja/g++.other/static16.C
new file mode 100644
index 0000000..0fbaea8
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/static16.C
@@ -0,0 +1,24 @@
+// Test that we properly evaluate the object parameter when accessing static
+// members.
+
+struct A {
+ static void f () {}
+ static int i;
+};
+
+int A::i;
+
+int c = 0;
+
+A g ()
+{
+ ++c;
+ return A();
+}
+
+int main ()
+{
+ g().f();
+ g().i = 42;
+ return (c != 2);
+}