This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PR c++/20022, obvious] fix -fno-access-control crash


We shouldn't assume deferred_access_stack is initialized and
short-circuit the call to get_deferred_access_check().  This patch
fixes -fno-access-control such that it doesn't crash for any
non-trivial testcase.  I'm checking it in as obvious.  Tested on
x86_64-linux-gnu.

Index: gcc/cp/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR c++/20022
	* semantics.c (perform_deferred_access_checks): Use
	get_deferred_access_checks to get the top of the stack.

Index: gcc/cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.460
diff -u -p -r1.460 semantics.c
--- gcc/cp/semantics.c 3 Feb 2005 00:02:02 -0000 1.460
+++ gcc/cp/semantics.c 17 Feb 2005 16:36:37 -0000
@@ -285,8 +285,7 @@ perform_deferred_access_checks (void)
 {
   tree deferred_check;
 
-  for (deferred_check = (VEC_last (deferred_access, deferred_access_stack)
-			 ->deferred_access_checks);
+  for (deferred_check = get_deferred_access_checks ();
        deferred_check;
        deferred_check = TREE_CHAIN (deferred_check))
     /* Check access.  */
Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR c++/20022
	* g++.dg/other/access3.C: New.

Index: gcc/testsuite/g++.dg/other/access3.C
===================================================================
RCS file: gcc/testsuite/g++.dg/other/access3.C
diff -N gcc/testsuite/g++.dg/other/access3.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/other/access3.C 17 Feb 2005 16:36:51 -0000
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-fno-access-control" }
+
+// PR c++/20022
+
+// Make sure -fno-access-control doesn't crash, and actually grants at
+// least some access.
+
+class B {
+  enum A {};
+};
+
+B::A r;
-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]