public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Two !$omp declare simd fixes (PR fortran/62076)
@ 2014-08-14 16:48 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2014-08-14 16:48 UTC (permalink / raw)
  To: gcc-patches, fortran

Hi!

I've committed following fix for two issues revealed e.g. by valgrind
on some of the udr*.f90 testcases.
buffer could be uninitialized, and gfc_free_omp_udr could free symbols
in the combiner_ns (or initializer_ns) when freeing those whole namespaces,
so if some symbols were queued for commit/undo, it is bad to first free
the symbols and then try to undo them.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 4.9 branch.

2014-08-14  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/62076
	* openmp.c (gfc_match_omp_clauses): When failed to match
	operator name, defined op name or name, set buffer to
	empty string.  Don't call gfc_find_omp_udr if buffer is empty
	string.
	(gfc_match_omp_declare_reduction): Call gfc_undo_symbols ()
	before calling gfc_free_omp_udr.

--- gcc/fortran/openmp.c.jj	2014-08-12 15:42:44.239327384 +0200
+++ gcc/fortran/openmp.c	2014-08-14 12:17:20.554565218 +0200
@@ -464,7 +464,11 @@ gfc_match_omp_clauses (gfc_omp_clauses *
 		      || !gfc_add_intrinsic (&sym->attr, NULL)))
 		rop = OMP_REDUCTION_NONE;
 	    }
-	  gfc_omp_udr *udr = gfc_find_omp_udr (gfc_current_ns, buffer, NULL);
+	  else
+	    buffer[0] = '\0';
+	  gfc_omp_udr *udr
+	    = (buffer[0]
+	       ? gfc_find_omp_udr (gfc_current_ns, buffer, NULL) : NULL);
 	  gfc_omp_namelist **head = NULL;
 	  if (rop == OMP_REDUCTION_NONE && udr)
 	    rop = OMP_REDUCTION_USER;
@@ -1240,6 +1244,7 @@ gfc_match_omp_declare_reduction (void)
 	 syntax:
 	  gfc_current_locus = old_loc;
 	  gfc_current_ns = combiner_ns->parent;
+	  gfc_undo_symbols ();
 	  gfc_free_omp_udr (omp_udr);
 	  return MATCH_ERROR;
 	}

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-14 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-14 16:48 [committed] Two !$omp declare simd fixes (PR fortran/62076) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).