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]

[gomp] fix g++.dg/gomp/sharing-1.C


Ug.  So we have

cp/mangle.c:1431

  if (DECL_DISCRIMINATOR_P (entity) && DECL_LANG_SPECIFIC (entity))
    discriminator = DECL_DISCRIMINATOR (entity);

As DECL_DISCRIMINATOR_P doesn't check DECL_LANG_SPECIFIC itself,
but DECL_DISCRIMINATOR is in fact inside, one can crash here merely
by allocating DECL_LANG_SPECIFIC.

Since I don't really understand DECL_DISCRIMINATOR vs DECL_ACCESS,
the safest thing to do seems to be to make sure the selector bit
gets set when DECL_DISCRIMINATOR_P is already true.


r~


        * semantics.c (finish_omp_threadprivate): Set decl_flags.u2sel
        when necessary.

Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.475.4.16
diff -u -p -d -r1.475.4.16 semantics.c
--- semantics.c	21 Oct 2005 23:40:04 -0000	1.475.4.16
+++ semantics.c	22 Oct 2005 00:52:46 -0000
@@ -3547,7 +3547,14 @@ finish_omp_threadprivate (tree vars)
 	{
 	  /* Allocate a LANG_SPECIFIC structure for V, if needed.  */
 	  if (DECL_LANG_SPECIFIC (v) == NULL)
-	    retrofit_lang_decl (v);
+	    {
+	      retrofit_lang_decl (v);
+
+	      /* Make sure that DECL_DISCRIMINATOR_P continues to be true
+		 after the allocation of the lang_decl structure.  */
+	      if (DECL_DISCRIMINATOR_P (v))
+		DECL_LANG_SPECIFIC (v)->decl_flags.u2sel = 1;
+	    }
 
 	  DECL_TLS_MODEL (v) = decl_default_tls_model (v);
 	  CP_DECL_THREADPRIVATE_P (v) = 1;


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