aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-10-16 14:06:24 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-10-16 14:06:24 +0000
commit7cfac5953a129fe78668db20cdf2533125349dea (patch)
treeffa08c0a95e67f0e44a6a971e67c65936e47ad1f /gcc
parent588c2d1c2f7303efadc5159cab5af58d78d1c405 (diff)
downloadgcc-7cfac5953a129fe78668db20cdf2533125349dea.zip
gcc-7cfac5953a129fe78668db20cdf2533125349dea.tar.gz
gcc-7cfac5953a129fe78668db20cdf2533125349dea.tar.bz2
decl.c (expand_static_init): Build cleanups before entering the anonymous function used to do them to avoid...
* decl.c (expand_static_init): Build cleanups before entering the anonymous function used to do them to avoid access-checking confusion. * decl.c (grokfndecl): Add back call to cplus_decl_attributes accidentally removed by previous change, and make DECL_RTL here. * class.c (add_method): Don't make DECL_RTL here. From-SVN: r23138
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/class.c3
-rw-r--r--gcc/cp/decl.c12
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/static3.C14
4 files changed, 33 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4fa45af..0569dd3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,13 @@
1998-10-16 Mark Mitchell <mark@markmitchell.com>
+ * decl.c (expand_static_init): Build cleanups before entering the
+ anonymous function used to do them to avoid access-checking
+ confusion.
+
+ * decl.c (grokfndecl): Add back call to cplus_decl_attributes
+ accidentally removed by previous change, and make DECL_RTL here.
+ * class.c (add_method): Don't make DECL_RTL here.
+
* pt.c (for_each_template_parm): Don't examine uninstantiated
default arguments.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 2bc8f37..68f65f6 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1270,9 +1270,6 @@ add_method (type, fields, method)
}
}
- /* Create RTL for the METHOD. */
- make_decl_rtl (method, NULL_PTR, 1);
-
/* Actually insert the new method. */
TREE_VEC_ELT (method_vec, i)
= build_overload (method, TREE_VEC_ELT (method_vec, i));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f296fa2..80ee017 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7814,8 +7814,13 @@ expand_static_init (decl, init)
pop_obstacks ();
}
+ /* Call build_cleanup before we enter the anonymous function
+ so that any access checks will be done relative to the
+ current scope, rather than the scope of the anonymous
+ function. */
+ fcall = build_cleanup (decl);
cleanup = start_anon_func ();
- expand_expr_stmt (build_cleanup (decl));
+ expand_expr_stmt (fcall);
end_anon_func ();
mark_addressable (cleanup);
cleanup = build_unary_op (ADDR_EXPR, cleanup, 0);
@@ -8235,6 +8240,11 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
if (ctype == NULL_TREE || check)
return decl;
+ if (attrlist)
+ cplus_decl_attributes (decl, TREE_PURPOSE (attrlist),
+ TREE_VALUE (attrlist));
+ make_decl_rtl (decl, NULL_PTR, 1);
+
if (virtualp)
{
DECL_VIRTUAL_P (decl) = 1;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/static3.C b/gcc/testsuite/g++.old-deja/g++.other/static3.C
new file mode 100644
index 0000000..b75771e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/static3.C
@@ -0,0 +1,14 @@
+// Build don't link:
+
+class S
+{
+ ~S();
+public:
+ friend void f();
+};
+
+
+S::~S()
+{
+ static S s;
+}