[UPC 22/22] libgupc test suite

Gary Funck gary@intrepid.com
Tue Dec 1 06:06:00 GMT 2015


Background
----------

An overview email, describing the UPC-related changes is here:
  https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00005.html

The GUPC branch is described here:
  http://gcc.gnu.org/projects/gupc.html

The UPC-related source code differences are summarized here:
  http://gccupc.org/gupc-changes

All languages (c, c++, fortran, go, lto, objc, obj-c++) have been
bootstrapped; no test suite regressions were introduced,
relative to the GCC trunk.

If you are on the cc-list, your name was chosen either
because you are listed as a maintainer for the area that
applies to the patches described in this email, or you
were a frequent contributor of patches made to files listed
in this email.

In the change log entries included in each patch, the directory
containing the affected files is listed, followed by the files.
When the patches are applied, the change log entries will be
distributed to the appropriate ChangeLog file.

Overview
--------

The libgupc test suite introduces 30/so runtime tests that
exercise various UPC capabilities.  The first 10/so tests
exercise increasingly complex language constructs.  test18.upc
is a catch all regression test.

The Makefile, and *.exp files are derived from the libgomp
testsuite with customizations for UPC.

These tests are run via 'make check-target-libgupc' at
the top level of the build tree.

libgupc/testsuite/lib/libgupc-dg.exp will support running
tests for both the default 'smp' configuration and the
experimental 'portals4' configuration.

2015-11-30  Gary Funck  <gary@intrepid.com>

	libgupc/testsuite/
	* Makefile.am: New.
	* Makefile.in: New.
	libgupc/testsuite/config/
	* default.exp: New.
	libgupc/testsuite/lib/
	* libgupc-dg.exp: New.
	* libgupc.exp: New.
	libgupc/testsuite/libgupc.upc/
	* upc.exp: New.
	libgupc/testsuite/libgupc.upc/intrepid/
	* ChangeLog: New.
	* test00.upc: New.
	* test01.upc: New.
	* test02.upc: New.
	* test03.upc: New.
	* test04.upc: New.
	* test05.upc: New.
	* test06.upc: New.
	* test07.upc: New.
	* test07_sep.upc: New.
	* test08.upc: New.
	* test08_sep.upc: New.
	* test09.upc: New.
	* test10.upc: New.
	* test11.upc: New.
	* test12.upc: New.
	* test13.upc: New.
	* test14.upc: New.
	* test15.upc: New.
	* test16.upc: New.
	* test17.upc: New.
	* test18.upc: New.
	* test19.upc: New.
	* test20.upc: New.
	* test21.upc: New.
	* test22.upc: New.
	* test23.upc: New.
	* test24.upc: New.
	* test25.upc: New.
	* test26.upc: New.
	* test27.upc: New.
	* test28.upc: New.
	* test29.upc: New.
	* test30.upc: New.
	* test31.upc: New.

Index: libgupc/testsuite/Makefile.am
===================================================================
--- libgupc/testsuite/Makefile.am	(.../trunk)	(revision 0)
+++ libgupc/testsuite/Makefile.am	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,13 @@
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = foreign dejagnu
+
+# May be used by various substitution variables.
+gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
+
+EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
+	   echo $(top_builddir)/../expect/expect; else echo expect; fi)
+
+_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
+	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
+RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
Index: libgupc/testsuite/Makefile.in
===================================================================
--- libgupc/testsuite/Makefile.in	(.../trunk)	(revision 0)
+++ libgupc/testsuite/Makefile.in	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,509 @@
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = testsuite
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+	$(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/enable.m4 \
+	$(top_srcdir)/../config/futex.m4 \
+	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/multi.m4 \
+	$(top_srcdir)/../config/override.m4 \
+	$(top_srcdir)/../config/stdint.m4 \
+	$(top_srcdir)/../config/tls.m4 $(top_srcdir)/../ltoptions.m4 \
+	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
+	$(top_srcdir)/../lt~obsolete.m4 \
+	$(top_srcdir)/ax_prog_doxygen.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+DEJATOOL = $(PACKAGE)
+RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADDR2LINE = @ADDR2LINE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOXYGEN_AUTHOR = @DOXYGEN_AUTHOR@
+DOXYGEN_DATE = @DOXYGEN_DATE@
+DOXYGEN_DATETIME = @DOXYGEN_DATETIME@
+DOXYGEN_HTML_LOGO = @DOXYGEN_HTML_LOGO@
+DOXYGEN_LOGO = @DOXYGEN_LOGO@
+DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@
+DOXYGEN_TITLE = @DOXYGEN_TITLE@
+DOXYGEN_VERSION = @DOXYGEN_VERSION@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DX_CONFIG = @DX_CONFIG@
+DX_DOCDIR = @DX_DOCDIR@
+DX_DOT = @DX_DOT@
+DX_DOXYGEN = @DX_DOXYGEN@
+DX_DVIPS = @DX_DVIPS@
+DX_EGREP = @DX_EGREP@
+DX_ENV = @DX_ENV@
+DX_FILE = @DX_FILE@
+DX_FLAG_chi = @DX_FLAG_chi@
+DX_FLAG_chm = @DX_FLAG_chm@
+DX_FLAG_doc = @DX_FLAG_doc@
+DX_FLAG_dot = @DX_FLAG_dot@
+DX_FLAG_html = @DX_FLAG_html@
+DX_FLAG_man = @DX_FLAG_man@
+DX_FLAG_pdf = @DX_FLAG_pdf@
+DX_FLAG_ps = @DX_FLAG_ps@
+DX_FLAG_rtf = @DX_FLAG_rtf@
+DX_FLAG_xml = @DX_FLAG_xml@
+DX_HHC = @DX_HHC@
+DX_LATEX = @DX_LATEX@
+DX_MAKEINDEX = @DX_MAKEINDEX@
+DX_PDFLATEX = @DX_PDFLATEX@
+DX_PERL = @DX_PERL@
+DX_PROJECT = @DX_PROJECT@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HAVE_DOT = @HAVE_DOT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPT_LDFLAGS = @OPT_LDFLAGS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_GDB = @PATH_TO_GDB@
+PERL = @PERL@
+RANLIB = @RANLIB@
+SECTION_LDFLAGS = @SECTION_LDFLAGS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UPC = @UPC@
+UPCDEPMODE = @UPCDEPMODE@
+UPCFLAGS = @UPCFLAGS@
+VERSION = @VERSION@
+XCFLAGS = @XCFLAGS@
+XLDFLAGS = @XLDFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_UPC = @ac_ct_UPC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bfdinc = @bfdinc@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+config_path = @config_path@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+enable_upc_runtime_debug = @enable_upc_runtime_debug@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+libtool_VERSION = @libtool_VERSION@
+link_upc_spec = @link_upc_spec@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+portals4inc = @portals4inc@
+portals4libs = @portals4libs@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+upc_crtbegin_spec = @upc_crtbegin_spec@
+upc_crtend_spec = @upc_crtend_spec@
+upc_crtstuff_cflags = @upc_crtstuff_cflags@
+upc_crtstuff_objs = @upc_crtstuff_objs@
+AUTOMAKE_OPTIONS = foreign dejagnu
+
+# May be used by various substitution variables.
+gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
+EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
+	   echo $(top_builddir)/../expect/expect; else echo expect; fi)
+
+_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
+	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
+
+RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign testsuite/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+check-DEJAGNU: site.exp
+	srcdir='$(srcdir)'; export srcdir; \
+	EXPECT=$(EXPECT); export EXPECT; \
+	runtest=$(RUNTEST); \
+	if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+	  exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
+	    if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
+	    then :; else exit_status=1; fi; \
+	  done; \
+	else echo "WARNING: could not find \`runtest'" 1>&2; :;\
+	fi; \
+	exit $$exit_status
+site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir "$(srcdir)"' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
+	  echo "## Begin content included from file $$f.  Do not modify. ##" \
+	   && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
+	   && echo "## End content included from file $$f. ##" \
+	   || exit 1; \
+	 done >> site.tmp
+	@echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
+	@if test -f site.exp; then \
+	   sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
+	 fi
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
+
+distclean-DEJAGNU:
+	-rm -f site.exp site.bak
+	-l='$(DEJATOOL)'; for tool in $$l; do \
+	  rm -f $$tool.sum $$tool.log; \
+	done
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-DEJAGNU distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
+	clean-libtool distclean distclean-DEJAGNU distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: libgupc/testsuite/config/default.exp
===================================================================
--- libgupc/testsuite/config/default.exp	(.../trunk)	(revision 0)
+++ libgupc/testsuite/config/default.exp	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,17 @@
+# Copyright (C) 1997-2015 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+load_lib "standard.exp"
Index: libgupc/testsuite/lib/libgupc-dg.exp
===================================================================
--- libgupc/testsuite/lib/libgupc-dg.exp	(.../trunk)	(revision 0)
+++ libgupc/testsuite/lib/libgupc-dg.exp	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,77 @@
+proc libgupc-dg-test { prog do_what extra_tool_flags } {
+    return [gcc-dg-test-1 libgupc_target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc libgupc-dg-prune { system text } {
+    return [gcc-dg-prune $system $text]
+}
+
+# Check for portals runtime
+set upc_portals [check_no_compiler_messages portals object {
+    #include "config.h"
+    #ifndef GUPCR_PORTALS_RUNTIME
+    #  error UPC runtime is not configured for Portals4
+    #endif
+  } ]
+
+# Check if YOD is supported for UPC program launching
+set upc_runtime_yod [check_no_compiler_messages yod object {
+    #include "config.h"
+    #ifndef GUPCR_JOB_LAUNCHER_YOD
+    #  error YOD is not supported
+    #endif
+    } ]
+
+# Find YOD if portals runtime is used
+if { $upc_portals } {
+    # YOD or SLURM?
+    if { $upc_runtime_yod } {
+        set env_var YOD
+        set run_var yod
+    } else {
+        set env_var "SRUN"
+        set run_var "srun"
+    }
+    # Environment variable set?
+    if { [info exists ::env($env_var)] } {
+        set upc_run_cmd $::env($env_var)
+    } else {
+        # Find run command on the exec path
+        set path [split $::env(PATH) ":"]
+        foreach d $path {
+	    set upc_run_cmd [file join $d "$run_var"]
+            verbose "UPC checking for $env_var: $run_var in dir: $d" 2
+            if [file executable $upc_run_cmd] {
+	        break
+	    }
+        }
+        if { [string compare $upc_run_cmd ""] == 0 } {
+	    error "UPC: Portals4 run command ($run_var) cannot be found."
+        }
+        verbose "UPC using run command: $upc_run_cmd" 2
+    }
+}
+
+# libgupc_load -- wrapper around default libupc_load to pass an extra
+# argument for dynamic threads UPC tests.
+# For the Portals4 based runtime, use a job scheduler to execute tests.
+
+if { [info procs libgupc_load] != [list] \
+     && [info procs prev_libgupc_load] == [list] } {
+    rename libgupc_load prev_libgupc_load
+
+    proc libgupc_load { program args } {
+        global upc_portals
+        global upc_run_arguments
+	global upc_run_cmd
+
+        if { $upc_portals } {
+	    set args [concat $upc_run_arguments $program $args]
+            set program $upc_run_cmd
+	} else {
+            set args [concat $upc_run_arguments $args]
+        }
+
+	return [prev_libgupc_load $program $args]
+    }
+}
Index: libgupc/testsuite/lib/libgupc.exp
===================================================================
--- libgupc/testsuite/lib/libgupc.exp	(.../trunk)	(revision 0)
+++ libgupc/testsuite/lib/libgupc.exp	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,257 @@
+# Damn dejagnu for not having proper library search paths for load_lib.
+# We have to explicitly load everything that gcc-dg.exp wants to load.
+
+proc load_gcc_lib { filename } {
+    global srcdir loaded_libs
+
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+    set loaded_libs($filename) ""
+}
+
+load_lib dg.exp
+
+# Required to use gcc-dg.exp - however, the latter should NOT be
+# loaded until ${tool}_target_compile is defined since it uses that
+# to determine default LTO options.
+
+load_gcc_lib multiline.exp
+load_gcc_lib prune.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+load_gcc_lib target-supports.exp
+load_gcc_lib target-utils.exp
+load_gcc_lib gcc-defs.exp
+load_gcc_lib timeout.exp
+load_gcc_lib file-format.exp
+load_gcc_lib target-supports-dg.exp
+load_gcc_lib scanasm.exp
+load_gcc_lib scandump.exp
+load_gcc_lib scanrtl.exp
+load_gcc_lib scantree.exp
+load_gcc_lib scanipa.exp
+load_gcc_lib timeout-dg.exp
+load_gcc_lib torture-options.exp
+load_gcc_lib fortran-modules.exp
+
+set dg-do-what-default run
+
+#
+# GCC_UNDER_TEST is the compiler under test.
+#
+
+set libgupc_compile_options ""
+
+#
+# libgupc_init
+#
+
+if [info exists TOOL_OPTIONS] {
+    set multilibs [get_multilibs $TOOL_OPTIONS]
+} else {
+    set multilibs [get_multilibs]
+}
+
+proc libgupc_init { args } {
+    global srcdir blddir objdir tool_root_dir
+    global libgupc_initialized
+    global tmpdir
+    global blddir
+    global gluefile wrap_flags
+    global ALWAYS_CFLAGS
+    global CFLAGS
+    global TOOL_EXECUTABLE TOOL_OPTIONS
+    global GCC_UNDER_TEST
+    global TESTING_IN_BUILD_TREE
+    global target_triplet
+    global always_ld_library_path
+
+    set blddir [lookfor_file [get_multilibs] libgupc]
+
+    # We set LC_ALL and LANG to C so that we get the same error
+    # messages as expected.
+    setenv LC_ALL C
+    setenv LANG C
+
+    # Many hosts now default to a non-ASCII C locale, however, so
+    # they can set a charset encoding here if they need.
+    if { [ishost "*-*-cygwin*"] } {
+      setenv LC_ALL C.ASCII
+      setenv LANG C.ASCII
+    }
+
+    if ![info exists GCC_UNDER_TEST] then {
+	if [info exists TOOL_EXECUTABLE] {
+	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
+	} else {
+	    set GCC_UNDER_TEST "[find_gcc]"
+	}
+    }
+
+    if ![info exists tmpdir] {
+	set tmpdir "/tmp"
+    }
+
+    if [info exists gluefile] {
+	unset gluefile
+    }
+
+    if {![info exists CFLAGS]} {
+	set CFLAGS ""
+    }
+
+    # Locate libgcc.a so we don't need to account for different values of
+    # SHLIB_EXT on different platforms
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+        set gccdir [file dirname $gccdir]
+    }
+
+    # Compute what needs to be put into LD_LIBRARY_PATH
+    set always_ld_library_path ".:${blddir}/.libs"
+
+    # Compute what needs to be added to the existing LD_LIBRARY_PATH.
+    if {$gccdir != ""} {
+	# Add AIX pthread directory first.
+	if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
+	    append always_ld_library_path ":${gccdir}/pthread"
+	}
+	append always_ld_library_path ":${gccdir}"
+	set compiler [lindex $GCC_UNDER_TEST 0]
+
+	if { [is_remote host] == 0 && [which $compiler] != 0 } {
+	  foreach i "[exec $compiler --print-multi-lib]" {
+	    set mldir ""
+	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+	    set mldir [string trimright $mldir "\;@"]
+	    if { "$mldir" == "." } {
+	      continue
+	    }
+	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+	      append always_ld_library_path ":${gccdir}/${mldir}"
+	    }
+	  }
+	}
+    }
+
+    set ALWAYS_CFLAGS ""
+    if { $blddir != "" } {
+        lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
+        # targets that use libgupc.a%s in their specs need a -B option
+        # for uninstalled testing.
+        lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
+        lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
+	# Add -I of source include directory for upc.h, gcc-upc.h, etc.
+        lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../include"
+        lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
+    }
+    lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
+
+    # We use atomic operations in the testcases to validate results.
+    if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
+	 && [check_effective_target_ia32] } {
+	lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
+    }
+
+    if [istarget *-*-darwin*] {
+	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
+    }
+
+    if [istarget sparc*-*-*] {
+	lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
+    }
+
+    if [info exists TOOL_OPTIONS] {
+	lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
+    }
+
+    # Make sure that lines are not wrapped.  That can confuse the
+    # error-message parsing machinery.
+    lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
+
+    # Disable caret
+    lappend ALWAYS_CFLAGS "additional_flags=-fno-diagnostics-show-caret"
+
+    # Disable color diagnostics
+    lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
+}
+
+#
+# libgupc_target_compile -- compile a source file
+#
+
+proc libgupc_target_compile { source dest type options } {
+    global blddir
+    global libgupc_compile_options
+    global gluefile wrap_flags
+    global ALWAYS_CFLAGS
+    global GCC_UNDER_TEST
+    global lang_test_file
+    global lang_library_path
+    global lang_link_flags
+    global lang_include_flags
+    global lang_source_re
+    global upc_run_arguments
+    global upc_portals
+
+    # Save compile options for later parsing
+    set compile_flags $options
+
+    if { [info exists lang_test_file] } {
+        if { $blddir != "" } {
+            # Some targets use libgfortran.a%s in their specs, so they need
+            # a -B option for uninstalled testing.
+            lappend options "additional_flags=-B${blddir}/${lang_library_path}"
+            lappend options "ldflags=-L${blddir}/${lang_library_path}"
+        }
+        lappend options "ldflags=${lang_link_flags}"
+	if { [info exists lang_include_flags] \
+	     && [regexp ${lang_source_re} ${source}] } {
+	    lappend options "additional_flags=${lang_include_flags}"
+	}
+    }
+
+    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
+	lappend options "libs=${gluefile}"
+	lappend options "ldflags=${wrap_flags}"
+    }
+
+    lappend options "additional_flags=[libio_include_flags]"
+    lappend options "timeout=[timeout_value]"
+    lappend options "compiler=$GCC_UNDER_TEST"
+
+    set options [concat $libgupc_compile_options $options]
+
+    if [info exists ALWAYS_CFLAGS] {
+	set options [concat "$ALWAYS_CFLAGS" $options]
+    }
+
+    set options [dg-additional-files-options $options $source]
+
+    # Set the default number of threads to 4.
+    set threads 4
+    # If the number of threads was given at compile time, use that.
+    regexp ".*-fupc-threads\[-=](\\d+)" \
+	       $compile_flags "" threads
+    set upc_run_arguments "-n $threads"
+
+    set result [target_compile $source $dest $type $options]
+
+    return $result
+}
+
+proc libgupc_option_help { } {
+    send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
+}
+
+proc libgupc_option_proc { option } {
+    if [regexp "^--additional_options," $option] {
+	global libgupc_compile_options
+	regsub "--additional_options," $option "" option
+	foreach x [split $option ","] {
+	    lappend libgupc_compile_options "additional_flags=$x"
+	}
+	return 1
+    } else {
+	return 0
+    }
+}
Index: libgupc/testsuite/libgupc.upc/upc.exp
===================================================================
--- libgupc/testsuite/libgupc.upc/upc.exp	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/upc.exp	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,37 @@
+if [info exists lang_library_path] then {
+    unset lang_library_path
+    unset lang_link_flags
+}
+if [info exists lang_test_file] then {
+    unset lang_test_file
+}
+if [info exists lang_include_flags] then {
+    unset lang_include_flags
+}
+
+load_lib libgupc-dg.exp
+load_gcc_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS "-O2 -fupc-threads=2"
+}
+
+# Initialize dg.
+dg-init
+
+# Turn on UPC.
+lappend ALWAYS_CFLAGS "additional_flags=-fupc"
+
+# Gather a list of all tests.
+set tests [lsort [find $srcdir/$subdir *.upc]]
+
+set ld_library_path $always_ld_library_path
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# Main loop.
+dg-runtest $tests "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
Index: libgupc/testsuite/libgupc.upc/intrepid/ChangeLog
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/ChangeLog	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/ChangeLog	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,146 @@
+2015-09-21  Gary Funck  <gary@intrepid.com>
+
+	* test05.upc: Remove dependency upon stable values for gaps
+	in a struct.
+
+2014-04-16  Gary Funck  <gary@intrepid.com>
+
+	* test26..upc: Add test case for comparisons involving
+	generic pointer-to-shared operands.
+
+2013-06-07  Nenad Vukicevic  <nenad@intrepid.com>
+
+	* test07.upc: Split test into two separate compilation units.
+	* test07_sep.upc: New.
+	* test08.upc: Split test into two separate compilation units.
+	* test08_sep.upc: New.
+
+2012-09-26  Gary Funck  <gary@intrepid.com>
+
+	* test31.upc: Make the timing check more tolerant.
+
+2012-09-26  Gary Funck  <gary@intrepid.com>
+
+	* test17.upc: Call upc_all_lock_free.
+	* test18.upc: Call upc_all_free, upc_all_lock_free,
+	  and call upc_alloc instead of deprecated upc_local_alloc.
+	* test19.upc: Call upc_all_free.
+	* test20.upc: Call upc_all_free.
+	* test21.upc: Call upc_all_free.
+	* test22.upc: Call upc_alloc instead of deprecated upc_local_alloc.
+	* test24.upc: Call upc_alloc instead of deprecated upc_local_alloc.
+	* test28.upc: Call upc_all_lock_free.
+	* test31.upc: New.  Test UPC wall-clock timer (upc_tick) library.
+
+2012-08-14  Gary Funck  <gary@intrepid.com>
+
+	* test29.upc: handle sprintf overflow on systems that
+	do no provide correct support for long double
+
+2012-08-09  Gary Funck  <gary@intrepid.com>
+
+	* test27.upc (fold_address_of_test): New.
+	Implement test for correct handling of &array[0].field
+	where 'array' is a UPC shared array.
+	Improve formatting and indentation.
+
+2012-07-25  Gary Funck  <gary@intrepid.com>
+
+	* test26.upc: Implement check for 6.4.2p6 conformance
+	and improve formatting and indentation.
+
+2012-01-04  Gary Funck  <gary@intrepid.com>
+
+	* test18.upc: Revert lost GCC/UPC -> GUPC change.
+	* test28.upc: Ditto.
+	* test30.upc: Ditto.
+
+2012-01-04  Gary Funck  <gary@intrepid.com>
+
+	* test00.upc: Fix spelling errors and split long lines.
+	* test03.upc: Ditto.
+	* test04.upc: Ditto.
+	* test07.upc: Ditto.
+	* test08.upc: Ditto.
+	* test12.upc: Ditto.
+	* test14.upc: Ditto.
+	* test15.upc: Ditto.
+	* test16.upc: Ditto.
+	* test17.upc: Ditto.
+	* test18.upc: Ditto.
+	* test19.upc: Ditto.
+	* test20.upc: Ditto.
+	* test21.upc: Ditto.
+	* test22.upc: Ditto.
+	* test23.upc: Ditto.
+	* test24.upc: Ditto.
+	* test25.upc: Ditto.
+	* test26.upc: Ditto.
+	* test27.upc: Ditto.
+	* test28.upc: Ditto.
+	* test30.upc: Ditto.
+
+2011-10-25  Gary Funck  <gary@intrepid.com>
+
+	Re-fix typo in previous commit.
+
+2011-10-24  Gary Funck  <gary@intrepid.com>
+
+	* test21.upc: Fix typo in "passed" message. Terminate with '.'.
+	* test24.upc: Ditto.
+	* test25.upc: Ditto.
+	* test30.upc: Ditto.
+
+2011-10-26  Gary Funck  <gary@intrepid.com>
+
+	Rename "GCC/UPC" to "GNU UPC", "UPC" to "GUPC", and
+	"libupc" to "libgupc".
+	* test18.upc: Change "GCC/UPC" to "GNU UPC".
+	* test28.upc: Ditto.
+	* test30.upc: Ditto.
+
+2011-09-07  Gary Funck  <gary@intrepid.com>
+
+	* test30.upc: Fix spelling error in diagnostic message.
+
+2011-09-07  Gary Funck  <gary@intrepid.com>
+
+	* test30.upc: New.  Missed in previous commit.
+	Print "pass" even when compiled with packed
+	UPC pointer-to-shared configuration.
+
+2011-09-07  Gary Funck  <gary@intrepid.com>
+
+	* test30.upc: New. Test UPC pointer-to-shared alignment
+	for struct PTS.
+
+2011-02-08  Gary Funck  <gary@intrepid.com>
+
+	* test00.upc, test01.upc, test02.upc, test03.upc, test04.upc,
+	  test05.upc, test06.upc, test07.upc, test08.upc, test09.upc,
+	  test10.upc, test11.upc, test12.upc, test13.upc, test14.upc,
+	  test15.upc, test16.upc, test17.upc, test18.upc, test19.upc,
+	  test20.upc, test21.upc, test22.upc, test23.upc, test24.upc,
+	  test25.upc, test26.upc, test27.upc, test28.upc, test29.upc:
+	Update copyright notices.
+
+2010-11-28  Gary Funck  <gary@intrepid.com>
+
+	Merge GCC/UPC 4.5.1.2 changes into gupc branch.
+	* test18.upc: Add new test for ICE when compiling
+	a declaration of the form:
+	shared [*] int A[THREADS][16];
+	when compiled in a dynamic THREADS context.
+	Conditionally defined __attribute__()
+	to match the non- GCC-specific version of this test.
+	* test29.upc: New test.
+	Add a test for operations on 'shared long double types'.
+
+2010-07-03  Gary Funck  <gary@intrepid.com>
+
+	Merge trunk version 161517 into gupc branch.
+	* test18.upc:
+	Add 'unused' attributes to avoid "set, but
+	not referenced" warnings.
+	* test19.upc:
+	Likewise.
Index: libgupc/testsuite/libgupc.upc/intrepid/test00.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test00.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test00.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,107 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+shared char x1;
+shared short x2;
+shared int x3;
+shared long long x4;
+shared float x5;
+shared double x6;
+
+#define CHAR_VAL  0x7f
+#define SHORT_VAL 0x1234
+#define INT_VAL   0x12345678
+#define LL_VAL    0x1234567887654321LL
+
+#define SF_VAL    1193046.0
+#define DF_VAL    20015998343868.0
+
+void
+test00 ()
+{
+  if (MYTHREAD == 0)
+    {
+      x1 = CHAR_VAL;
+      x2 = SHORT_VAL;
+      x3 = INT_VAL;
+      x4 = LL_VAL;
+      x5 = SF_VAL;
+      x6 = DF_VAL;
+    }
+  upc_barrier;
+  if (x1 != CHAR_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %d = %d\n",
+               MYTHREAD, "char", x1, CHAR_VAL);
+      abort ();
+    }
+  if (x2 != SHORT_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %d = %d\n",
+               MYTHREAD, "short", x2, SHORT_VAL);
+      abort ();
+    }
+  if (x3 != INT_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %d = %d\n",
+               MYTHREAD, "int", x3, INT_VAL);
+      abort ();
+    }
+  if (x4 != LL_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %lld = %lld\n",
+               MYTHREAD, "long long", x4, LL_VAL);
+      abort ();
+    }
+  if (x5 != SF_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %f = %f\n",
+               MYTHREAD, "float", x5, SF_VAL);
+      abort ();
+    }
+  if (x6 != DF_VAL)
+    {
+      fprintf (stderr, "%d: Error %s : %f = %f\n",
+               MYTHREAD, "double", x6, DF_VAL);
+      abort ();
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      printf ("test00: access shared scalars - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test00 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test01.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test01.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test01.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,65 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+shared int array[FACTOR * THREADS];
+
+void
+test01 ()
+{
+  int i;
+  for (i = MYTHREAD; i < FACTOR * THREADS; i += THREADS)
+    {
+      array[i] = i + 1;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < FACTOR * THREADS; ++i)
+	{
+	  int got = array[i];
+	  int expected = i + 1;
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "test01: Error at element %d. Expected %d, got %d\n",
+		       i, expected, got);
+	      abort ();
+	    }
+	}
+      printf ("test01: simple array test - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test01 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test02.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test02.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test02.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,70 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define DIM1 1024
+
+shared int array[DIM1][THREADS];
+
+void
+test02 ()
+{
+  int i, j;
+  for (i = 0; i < DIM1; ++i)
+    {
+      array[i][MYTHREAD] = (i + 1) * (MYTHREAD + 1);
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < DIM1; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      int got = array[i][j];
+	      int expected = (i + 1) * (j + 1);
+	      if (got != expected)
+		{
+		  fprintf (stderr, "test02: Error at element [%d,%d]. Expected %d, got %d\n",
+			   i, j, expected, got);
+		  abort ();
+		}
+	    }
+	}
+      printf ("test02: simple 2-dimensional array test - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test02 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test03.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test03.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test03.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,85 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+struct data_struct
+{
+  char x1;
+  short x2;
+  int x3;
+  long long x4;
+};
+
+shared struct data_struct s;
+
+void
+test03 ()
+{
+  if (MYTHREAD == 0)
+    {
+      s.x1 = 127;
+      s.x2 = -2;
+      s.x3 = -3;
+      s.x4 = -4;
+    }
+  upc_barrier;
+  if (s.x1 != 127)
+    {
+      fprintf (stderr, "%d: Error %s : %d = 255\n", MYTHREAD, "char", s.x1);
+      abort ();
+    }
+  if (s.x2 != -2)
+    {
+      fprintf (stderr, "%d: Error %s : %d = -2\n", MYTHREAD, "short", s.x2);
+      abort ();
+    }
+  if (s.x3 != -3)
+    {
+      fprintf (stderr, "%d: Error %s : %d = -3\n", MYTHREAD, "int", s.x3);
+      abort ();
+    }
+  if (s.x4 != -4)
+    {
+      fprintf (stderr, "%d: Error %s : %lld = -4\n",
+               MYTHREAD, "long long", s.x4);
+      abort ();
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      printf ("test03 (access shared struct) - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test03 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test04.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test04.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test04.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,106 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+shared char x1;
+shared short x2;
+shared int x3;
+shared long long x4;
+
+
+void
+set_proc (shared char *p1, char v1, shared short *p2,
+	  short v2, shared int *p3, int v3, shared long long *p4,
+	  long long v4)
+{
+  *p1 = v1;
+  *p2 = v2;
+  *p3 = v3;
+  *p4 = v4;
+}
+
+void
+get_proc (shared char *p1, char *v1, shared short *p2,
+	  short *v2, shared int *p3, int *v3, shared long long *p4,
+	  long long *v4)
+{
+  *v1 = *p1;
+  *v2 = *p2;
+  *v3 = *p3;
+  *v4 = *p4;
+}
+
+void
+test04 ()
+{
+  char xv1;
+  short xv2;
+  int xv3;
+  long long xv4;
+  if (MYTHREAD == 0)
+    {
+      set_proc (&x1, 127, &x2, -2, &x3, -3, &x4, -4);
+    }
+  upc_barrier;
+  get_proc (&x1, &xv1, &x2, &xv2, &x3, &xv3, &x4, &xv4);
+  if (xv1 != 127)
+    {
+      fprintf (stderr, "%d: Error %s : %d = 127\n", MYTHREAD, "char", xv1);
+      abort ();
+    }
+  if (xv2 != -2)
+    {
+      fprintf (stderr, "%d: Error %s : %d = -2\n", MYTHREAD, "short", xv2);
+      abort ();
+    }
+  if (xv3 != -3)
+    {
+      fprintf (stderr, "%d: Error %s : %d = -3\n", MYTHREAD, "int", xv3);
+      abort ();
+    }
+  if (xv4 != -4)
+    {
+      fprintf (stderr, "%d: Error %s : %lld = -4\n", MYTHREAD, "long long",
+	       xv4);
+      abort ();
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      printf ("test04 (access shared values via"
+              " (shared *) parameters) - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test04 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test05.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test05.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test05.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,102 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct data_struct
+  {
+    char x1;
+    short x2;
+    int x3;
+    long long x4;
+    int x5[5];
+  };
+
+#define FACTOR 10
+shared struct data_struct array[FACTOR*THREADS];
+
+void
+test05()
+{
+  int i, j;
+  for (i = MYTHREAD; i < FACTOR*THREADS; i += THREADS)
+    {
+      struct data_struct * const s = (struct data_struct *)&array[i];
+      s->x1 = i*4 + 1;
+      s->x2 = i*4 + 2;
+      s->x3 = i*4 + 3;
+      s->x4 = i*4 + 4;
+      for (j = 0; j < 5; ++j)
+	s->x5[j] = i*4 + j + 5;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < FACTOR*THREADS; ++i)
+	{
+	  struct data_struct got = array[i];
+	  struct data_struct expected;
+	  expected.x1 = i*4 + 1;
+	  expected.x2 = i*4 + 2;
+	  expected.x3 = i*4 + 3;
+	  expected.x4 = i*4 + 4;
+	  for (j = 0; j < 5; ++j)
+	    expected.x5[j] = i*4 + j + 5;
+	  if ((got.x1 != expected.x1)
+	      || (got.x2 != expected.x2)
+	      || (got.x3 != expected.x3)
+	      || (got.x4 != expected.x4)
+	      || (got.x5[0] != expected.x5[0])
+	      || (got.x5[1] != expected.x5[1])
+	      || (got.x5[2] != expected.x5[2])
+	      || (got.x5[3] != expected.x5[3])
+	      || (got.x5[4] != expected.x5[4]))
+	    {
+	      fprintf(stderr, "test05: error at element %d."
+		" Expected (%d,%d,%d,%lld,%d,%d,%d,%d,%d),"
+		" got (%d,%d,%d,%lld,%d,%d,%d,%d,%d)\n",
+		i, expected.x1, expected.x2, expected.x3, expected.x4,
+		expected.x5[0], expected.x5[1], expected.x5[2],
+		expected.x5[3], expected.x5[4],
+		got.x1, got.x2, got.x3, got.x4,
+		got.x5[0], got.x5[1], got.x5[2], got.x5[3], got.x5[4]);
+	      abort ();
+	    }
+	}
+      printf ("test05: access structured shared array element\n"
+	      "		using a local pointer - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test05 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test06.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test06.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test06.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,68 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+shared int array[FACTOR*THREADS];
+
+void
+test06()
+{
+  int i;
+  for (i = MYTHREAD; i < FACTOR*THREADS; i += THREADS)
+    {
+      /* declare, and use a local pointer */
+      int *s = (int *)&array[i];
+      *s = i+1;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < FACTOR*THREADS; ++i)
+	{
+	  shared int *got;
+	  int expected = i+1;
+	  got = (shared int *)&array[i];
+	  if (*got != expected)
+	    {
+	      fprintf(stderr, "test06: error at element %d. Expected %d, got %d\n",
+		i, expected, *got);
+	      abort ();
+	    }
+	}
+      printf ("test06: test shared->local, and shared pointers - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test06 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test07.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test07.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test07.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,44 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* { dg-additional-sources "test07_sep.upc" } */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+
+shared int array[FACTOR*THREADS];
+
+extern void test07 (); /* separate */
+
+int
+main()
+{
+  test07 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test07_sep.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test07_sep.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test07_sep.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,60 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* { dg-do compile } */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+
+void
+test07 ()
+{
+  extern shared int array[FACTOR * THREADS];
+  int i;
+  for (i = MYTHREAD; i < FACTOR * THREADS; i += THREADS)
+    {
+      array[i] = i + 1;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < FACTOR * THREADS; ++i)
+	{
+	  int got = array[i];
+	  int expected = i + 1;
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "test07: error at element %d. Expected %d, got %d\n",
+		       i, expected, got);
+	      abort ();
+	    }
+	}
+      printf ("test07: simple external shared array test - passed.\n");
+    }
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test08.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test08.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test08.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,44 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* { dg-additional-sources "test08_sep.upc" } */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DIM1 1024
+
+shared int array[DIM1][THREADS];
+
+extern void test08 (); /* separate */
+
+int
+main()
+{
+  test08 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test08_sep.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test08_sep.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test08_sep.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,63 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* { dg-do compile } */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DIM1 1024
+
+void
+test08 ()
+{
+  extern shared int array[DIM1][THREADS];
+  int i, j;
+  for (i = 0; i < DIM1; ++i)
+    {
+      array[i][MYTHREAD] = (i + 1) * (MYTHREAD + 1);
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < DIM1; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      int got = array[i][j];
+	      int expected = (i + 1) * (j + 1);
+	      if (got != expected)
+		{
+		  fprintf (stderr, "test08: error at element [%d,%d]. Expected %d, got %d\n",
+			   i, j, expected, got);
+		  abort ();
+		}
+	    }
+	}
+      printf ("test08: simple external 2-dimensional array test - passed.\n");
+    }
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test09.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test09.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test09.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,74 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define BLKSIZE 25 
+#define BLKS_PER_THREAD 4
+#define FACTOR (BLKSIZE*BLKS_PER_THREAD)
+#define NELEM (FACTOR*THREADS)
+
+shared [BLKSIZE] int array[NELEM];
+
+void
+test09()
+{
+  int i, j;
+  for (i = 0; i < BLKS_PER_THREAD; ++i)
+    {
+      int blk_index = (MYTHREAD + i * THREADS) * BLKSIZE;
+      int *block = (int *)&array[blk_index];
+      for (j = 0; j < BLKSIZE; ++j)
+	{
+	  block[j] = blk_index + j + 1;
+	}
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < NELEM; ++i)
+	{
+	  int got = array[i];
+	  int expected = i+1;
+	  if (got != expected)
+	    {
+	      fprintf(stderr, "test09: error at element %d. Expected %d, got %d\n",
+		i, expected, got);
+	      abort ();
+	    }
+	}
+      printf ("test09: simple blocked array test - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test09 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test10.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test10.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test10.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,80 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define DIM1 1024
+
+shared int array[DIM1][THREADS];
+
+void
+test10()
+{
+  int i, j;
+  upc_forall (i = 0; i < DIM1; ++i; continue)
+    {
+      upc_forall (j = 0; j < THREADS; ++j; &array[i][j])
+	{
+	  if (upc_threadof(&array[i][j]) != (size_t) MYTHREAD)
+	    {
+	      fprintf (stderr, "test10: error at element [%d,%d]."
+		" Does not have affinity with thread %d, inside"
+		" nested upc_forall.\n", i, j, MYTHREAD);
+	      abort ();
+	    }
+          array[i][j] = (i+1)*(MYTHREAD + 1);
+	}
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < DIM1; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      int got = array[i][j];
+	      int expected = (i + 1) * (j + 1);
+	      if (got != expected)
+		{
+		  fprintf(stderr, "test10: error at element [%d,%d]. Expected %d, got %d\n",
+		    i, j, expected, got);
+		  abort ();
+		}
+	    }
+	}
+      printf ("test10: nested upc_forall test - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test10 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test11.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test11.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test11.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,72 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+shared int array[FACTOR][THREADS];
+
+void
+test11()
+{
+  int i, j;
+  for (i = 0; i < FACTOR; i += 1)
+    {
+      /* declare, and use a local pointer */
+      int *s = (int *)&array[i][MYTHREAD];
+      *s = (i+1) * (MYTHREAD + 1);
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < FACTOR; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      shared int *got;
+	      int expected = (i+1) * (j+1);
+	      got = (shared int *)&array[i][j];
+	      if (*got != expected)
+		{
+		  fprintf(stderr, "test11: error at element %d. Expected %d, got %d\n",
+		    i, expected, *got);
+		  abort ();
+		}
+	    }
+	}
+      printf ("test11: test shared->local, and shared pointers"
+	      " using two-dimensional array - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test11 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test12.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test12.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test12.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,95 @@
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* This test replicates a problem where incorrect code was generated
+   whenever an intervening declaration of a type that has the same type
+   as the basic element type of a shared array whose dimension included
+   a reference to THREADS.  In that situation, the compiler "forgot"
+   to scale all references to the array, by THREADS (when compiled in
+   the dynamic compilation environment. */
+
+#define FACTOR 100
+shared int a[FACTOR][THREADS];
+/* following variable is not used, but is required to demonstrate problem */
+#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(X) 
+#endif
+shared int unused_var __attribute__ ((unused));
+shared int *Ptr;
+
+void
+test12 ()
+{
+  int i, j;
+  int got, expected;
+  for (i = 0; i < FACTOR; ++i)
+    {
+      Ptr = &a[i][MYTHREAD];
+      got = upc_threadof(Ptr);
+      expected = MYTHREAD;
+      if (got != MYTHREAD)
+	{
+	   fprintf (stderr, "Error at element [%d,%d]."
+	     " Address of array element has affinity %d,"
+	     " but should have affinity to this thread (%d).\n",
+	     i, MYTHREAD, got, expected);
+	   abort ();
+	}
+      *Ptr = i * THREADS + MYTHREAD;
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      for (i = 0; i < FACTOR; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      expected = i * THREADS + j;
+	      got = a[i][j];
+	      if (got != expected)
+		{
+		  fprintf (stderr, "Error at element [%d,%d]."
+		    " Got `%d', expected `%d'.\n",
+		    i, j, got, expected);
+		  abort ();
+		}
+	    }
+	}
+      printf ("test12: test multi-dimension array accesses\n"
+	      " in a dynamic compilation environment - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test12 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test13.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test13.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test13.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* This test calculates the difference between two shared pointers.
+   Further, it declares shared pointers in a stack local context. */
+
+shared int vec[THREADS];
+
+size_t
+ptr_diff(shared int *p1, shared int *p2)
+{
+  return p1 - p2;
+}
+
+void
+test13()
+{
+  size_t s1, s2;
+  shared int *p_t, *p_0;
+  p_t = &vec[THREADS - 1];
+  p_0 = &vec[0];
+  s1 = ptr_diff(p_t, p_0);
+  s2 = p_t - p_0;
+  if (s1 != (size_t)(THREADS - 1))
+    {
+      fprintf (stderr, "Error in pointer difference,"
+                       " got: %lld, expected: %lld.\n",
+		       (long long)s1, (long long)(THREADS - 1));
+      abort ();
+    }
+  if (s1 != s2)
+    {
+      fprintf (stderr, "Error in pointer difference,"
+                       " s1: %lld not equal to s2: %lld.\n",
+		       (long long)s1, (long long)s2);
+      abort ();
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      printf ("test13: test pointer difference and local declaration"
+	      " of shared pointers - passed.\n");
+    }
+}
+
+int
+main ()
+{
+  test13 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test14.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test14.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test14.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,78 @@
+/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+test14 ()
+{
+  int shared * res; 
+  int *p;
+  res = 0; 
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      if (res)
+        {
+	  fprintf (stderr, "Error: null PTS test 'if (res)' failed.\n");
+	  abort ();
+        }
+      if (res != 0)
+        {
+	  fprintf (stderr, "Error: null PTS test 'if (res !=0)' failed.\n");
+	  abort ();
+	}
+      p = (int *)res;
+      if (p)
+        {
+	  fprintf (stderr, "Error: null PTS to local test 'if (p)' failed.\n");
+	  abort ();
+	}
+      if ((int *) res != 0)
+        {
+	  fprintf (stderr, "Error: null PTS to local "
+	           "test 'if ((int *) res != 0)' failed.\n");
+	  abort ();
+	}
+      if (0 != (int *) res)
+        {
+	  fprintf (stderr, "Error: null PTS to local "
+	           "test 'if (0 != (int *) res)' failed.\n");
+	  abort ();
+	}
+      printf ("test14: test assignment, comparison, and "
+              "conversion of a null shared pointer - passed.\n");
+    }
+}
+
+int main ()
+{
+   test14 ();
+   return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test15.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test15.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test15.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+shared int array[FACTOR*THREADS];
+
+void
+test15()
+{
+  int i;
+  shared int *p;
+  for (i = MYTHREAD; i < FACTOR*THREADS; i += THREADS)
+    {
+      array[i] = i+1;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      p = &array[0];
+      for (i = 0; i < FACTOR*THREADS; ++i)
+	{
+	  int expected = i+1;
+	  int got = *p++;
+	  if (got != expected)
+	    {
+	      fprintf(stderr, "test15: error at element %d. Expected %d, got %d\n",
+		i, expected, got);
+	      abort ();
+	    }
+	}
+      /* C standard allows pointers to last element plus one */
+      p = &array[FACTOR*THREADS];
+      for (i = FACTOR*THREADS-1; i >= 0; --i)
+	{
+	  int expected = i+1;
+	  int got = *--p;
+	  if (got != expected)
+	    {
+	      fprintf(stderr, "test15: error at element %d. Expected %d, got %d\n",
+		i, expected, got);
+	      abort ();
+	    }
+	}
+      printf ("test15: test increment/decrement operations "
+              "on shared pointers - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test15 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test16.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test16.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test16.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <upc.h>
+
+#define BLKSIZE 10
+int shared [BLKSIZE] a[100*THREADS];
+
+struct row {
+   int x, y, z;
+   };
+
+/* Triples of random integers in the range 1..99 */
+struct row data[20] = {
+    {23,29,84}, {15,58,19}, {81,17,48}, {15,36,49},
+    {10,63,1}, {72,10,48}, {25,67,89}, {75,72,90},
+    {92,37,89}, {77,32,19}, {99,16,70}, {50,93,71},
+    {10,20,55}, {70,7,51}, {19,27,63}, {44,3,46},
+    {91,26,89}, {22,63,57}, {33,10,50}, {56,85,4}
+   };
+
+int main ()
+{
+   int i;
+   int shared [BLKSIZE] *p0, *p1;
+   int diff, expected;
+   for (i = 0; i < 19; ++i)
+     {
+       int t0 = MYTHREAD;
+       int t1 = (MYTHREAD + data[i].x) % THREADS;
+       int j = data[i].y;
+       int k = data[i].z;
+       int ediff = (k - j);
+       int pdiff = k % BLKSIZE - j % BLKSIZE;
+       int tdiff = (t1 - t0);
+       p0 = &a[((j / BLKSIZE) * THREADS + t0) * BLKSIZE + (j % BLKSIZE)];
+       p1 = &a[((k / BLKSIZE) * THREADS + t1) * BLKSIZE + (k % BLKSIZE)];
+       diff = p1 - p0;
+       expected = (ediff - pdiff) * THREADS + tdiff * BLKSIZE + pdiff;
+       if (diff != expected)
+         {
+	   fprintf (stderr, "Error: pointer difference: %d not equal "
+	            "to expected: %d\n", diff, expected);
+	   abort ();
+	 }
+      }
+   upc_barrier;
+   if (!MYTHREAD)
+     {
+      printf ("test16: test pointer difference between pointers "
+              "to shared array with layout specifier - passed.\n");
+     }
+   return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test17.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test17.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test17.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,99 @@
+/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FACTOR 100
+#define BLKSIZE 5
+shared [BLKSIZE] int array[FACTOR*THREADS];
+
+/* ptr is a shared pointer that lives in shared memory */
+shared [BLKSIZE] int * shared ptr;
+shared int counter;
+
+/* serialization lock */
+upc_lock_t *lock;
+
+void
+test17()
+{
+  int i;
+  lock = upc_all_lock_alloc();
+  if (!MYTHREAD)
+    {
+      counter = 0;
+      ptr = &array[0];
+    }
+  upc_barrier;
+  for (i = 0; i < FACTOR; ++i)
+    {
+      upc_lock (lock);
+      counter = counter + 1;
+      *ptr = counter;
+      ptr = ptr + 1;
+      upc_unlock (lock);
+    }
+  upc_all_lock_free (lock);
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      int expected;
+      int got;
+      shared [BLKSIZE] int *p, *last;
+      for (p = &array[0], last = &array[FACTOR*THREADS-1], i = 0;
+	   p <= last; ++p)
+	{
+	  expected = ++i;
+	  got = *p;
+	  if (got != expected)
+	    {
+	      fprintf(stderr, "test17: error at element %d. Expected %d, got %d.\n",
+		i, expected, got);
+	      abort ();
+	    }
+	}
+      got = i;
+      expected = FACTOR*THREADS;
+      if (got != expected)
+        {
+	  fprintf(stderr, "test17: error: loop iteration mismatch."
+	                  " Expected %d, got %d.\n", expected, got);
+	  abort ();
+	}
+      printf ("test17: test indirection via a shared pointer to shared, "
+              "and pointer comparison, for pointers with "
+	      "blocking factors - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test17 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test18.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test18.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test18.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,1090 @@
+/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc_strict.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(X) 
+#endif
+
+shared [5] int a_blk5[10*THREADS];
+shared [5] int *ptr_to_blk5;
+shared [3] int *ptr_to_blk3;
+shared [5] int * shared shared_ptr_to_shared;
+shared int shared_int;
+int local_int = 99;
+shared int * ptr_to_shared_int;
+upc_lock_t *lock;
+typedef shared [3] int a_3[3];
+a_3 a_3_by_3[3*THREADS];
+shared [] int a_indef[10];
+shared [*] int a_star_10[10*THREADS];
+/* below, unused, but caused compilation error in the past. */
+shared [] int* shared shared_a_indef_ptr[THREADS] __attribute__ ((unused));
+int * shared shared_ptr_to_local_int;
+/* bug 39: can't statically initialize pointer-to-shared with NULL */
+shared int * shared_ptr_null_init = 0;
+/* bug 62: pointer to shared incomplete type with layout specifier
+   not deferred to type completion */
+shared [10] struct inc_struct *ptr_to_incomplete;
+struct inc_struct { int x; int y; };
+/* bug 95: cast of pointer to shared const misclassified as an error */
+struct struct95
+  {
+    int field[10];
+  };
+shared struct struct95 shared_struct;
+/* bug 96: access to 2-dim shared volatile element crashes compiler. */
+shared volatile int shared_vol2[10][THREADS];
+/* bug 100: local pointer set to null pointer to shared. */
+double localData;
+double *localPtr;
+ 
+/* bug 103: ICE: codegen (AMD64) - fail while evaluating shared array element
+   actual parameters */
+shared double save_err[100][4][THREADS];
+
+/* gimple bug. */
+shared int gimple_arr[THREADS];
+
+/* BUPC bug53 - de-reference via shared pointer to local.*/
+int * shared bupc_bug53_p;
+
+/* BUPC bug206 - de-reference via local pointer
+   to pointer to unblocked shared.  */
+typedef shared [] int *sintptr;
+shared [] int bupc_206_A[10];
+sintptr bupc_206_S;
+
+#undef abs
+#define abs(x) ((x) < 0 ? -(x) : (x))
+
+int
+process_errors (double e1, double e2, double e3, double e4)
+{
+  double s = abs(e1) + abs(e2) + abs(e3) + abs(e4);
+  return (s < 1.0e-5);
+}
+
+/* bug 104: Erroneous code generated */
+shared int bug104_TT[16][THREADS];
+
+void
+bug104_proc_1 (int i, int j)
+{
+  if (i == j)
+     return;
+  fprintf (stderr, "Error bug 104: failed - i != j (%d != %d)\n", i, j);
+  abort ();
+}
+
+void
+bug104_proc (int i, int j)
+{
+   if (j != MYTHREAD)
+     return;
+   /* The gets of bug104_TT[i][j] below were interfering with the
+      save area on the stack where i and j are stored.
+      This caused the second call to fail. */
+   bug104_proc_1 (bug104_TT[i][j], i); 
+   bug104_proc_1 (bug104_TT[i][j]+2, i+2); 
+}
+
+/* Bug 106: GUPC fails with internal error on a few
+   UPCR regression tests on OPTERON (x86_64) systems */
+
+typedef struct bug106_U_shared bug106_u_t;
+struct bug106_U_shared 
+{ 
+  double local[9][8][7][6][5];
+}; 
+shared [] bug106_u_t *bug106_u;
+ 
+shared [] double *
+bug106_func(int i, int j)
+{
+  shared [] double *result;
+  result = &bug106_u[0].local[1][i][j][2][0];
+  return result;
+}
+
+/* bug 195: ICE: fail to parse shared array declaration after a similar
+   declaration has already been seen */
+extern shared [2941*2] double sh_buf[THREADS][2941*2];
+shared [2941*2] double sh_buf[THREADS][2941*2];
+
+/* bug 213: pragma upc appearing just after opening bracket not supported.
+   This was causing a compilation warning, because it was an unsupported
+   pragma.  The code below doesn't do anything meaningful.  It just nests
+   some brackets to test that aspect of pragma upc handling.  */
+void
+bug213_func (shared double *x, shared double *y, shared double *z[])
+{
+  int i;
+  for (i = 0; i < 100; ++i)
+    {
+      int j;
+      for (j = 0; j < 100; ++j)
+        {
+          #pragma upc strict
+	  if (x[i] < x[j])
+	    {
+	      z[i][j] = x[i] * y[j];
+	    }
+	  else
+	    {
+	      z[i][j] = -x[i] * y[j];
+	    }
+	}
+    }
+}
+
+struct bupc_156_struct {
+  char No;
+  int  a[20];
+};
+
+shared [10] struct bupc_156_struct bupc_156;
+void
+bupc156_test()
+{
+  size_t bs_No __attribute__ ((unused));
+  size_t bs_a __attribute__ ((unused));
+  bs_No = upc_blocksizeof(*&(bupc_156.No));
+  bs_a = upc_blocksizeof(*&(bupc_156.a));
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      shared [] char * x = &(bupc_156.No);
+      int i;
+      for (i = 0; i < 20; ++i)
+        bupc_156.a[i] = (i + 1);
+      *x = 'X';
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      int *a = (int *)&bupc_156.a[0];
+      int i;
+      if (bupc_156.No != 'X')
+        {
+	  fprintf (stderr, "Error bupc156 test failed: bupc_156.No mismatch"
+	                   " - expected 'X', got '%c'\n", bupc_156.No);
+          abort ();
+	}
+      for (i = 0; i < 20; ++i)
+        {
+	  int expected = i + 1;
+	  int got = a[i];
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "Error bupc156 test failed: "
+	               "expected %d got %d at i = %d\n",
+	               expected, got, i);
+	      abort ();
+	    }
+	}
+    }
+  upc_barrier;
+}
+
+#define NB228 100
+struct bug228_struct {
+  double a[NB228];
+};
+
+shared struct bug228_struct bug228_array[THREADS];
+
+void
+bug228_test (void)
+{
+  int i, t;
+  upc_barrier;
+  for (i = 0; i <  NB228; ++i)
+    bug228_array[MYTHREAD].a[i] = (double)((i + 1)*(MYTHREAD+1));
+  upc_barrier;
+  if (MYTHREAD > 0)
+    {
+      bug228_array[MYTHREAD] = bug228_array[0];
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (t = 0; t < THREADS; ++t)
+        for (i = 0; i < NB228; ++i)
+	  {
+	    double expected = (double)(i + 1);
+	    double got = bug228_array[t].a[i];
+	    if (got != expected)
+	      {
+		fprintf (stderr, "Error bug228 test failed: expected %.3g got %.3g"
+		                 " at t = %d, i = %d\n",
+			 expected, got, t, i);
+		abort ();
+	      }
+	  }
+    }
+  upc_barrier;
+}
+
+/* 'strict' is needed here, because on a 64 bit machine,
+   two threads might try to write each half of a 64 bit
+   word and a race condition results.  */
+strict shared int bug230_ia[2][10*THREADS];
+
+void
+bug230_proc(strict shared int ia[2][10*THREADS])
+{
+  int i, j;
+  for (i = 0; i < 2; ++i)
+    for (j = 0; j < 10; ++j)
+      ia[i][j*THREADS+MYTHREAD] = i*10*THREADS + (j*THREADS + MYTHREAD);
+}
+
+
+/* Note: Bug 229 is a compile-time bug, that this
+   test reproduces when compiled.  At runtime,
+   this test exercises bug 230 (when compiled with
+   static threads and THREADS=2).  */
+void
+bug230_test()
+{
+  int i, j, t;
+  upc_barrier;
+  bug230_proc (bug230_ia);
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (t = 0; t < THREADS; ++t)
+        for (i = 0; i < 2; ++i)
+          for (j = 0; j < 10; ++j)
+	    {
+	      int expected = i*10*THREADS + (j*THREADS + t);
+	      int got = bug230_ia[i][j*THREADS+t];
+	      if (got != expected)
+	        {
+	          fprintf (stderr, "Error bug #230 test failed: expected %d got %d"
+		                   " at t = %d, i = %d, j = %d\n",
+	                           expected, got, t, i, j);
+		  abort ();
+		}
+	    }
+    }
+  upc_barrier;
+}
+
+/* Bug 233: upc_alloc.upc fails to compile, with complaint
+   about attempt to copy shared pointer to local. */
+
+shared int bug233_v1;
+shared int * shared bug233_p1;
+shared int * shared bug233_p2;
+
+void
+bug233_test ()
+{
+  upc_barrier;
+    if (!MYTHREAD)
+      {
+	bug233_v1 = 101;
+        bug233_p1 = &bug233_v1;
+        /* The statement above should compile without complaint. */
+        bug233_p2 = bug233_p1;
+      }
+  upc_barrier;
+  if (bug233_p1 == NULL)
+    {
+      fprintf (stderr, "Error p1 is NULL - bug233 test failed.\n");
+      abort ();
+    }
+  if (bug233_p2 != bug233_p1)
+    {
+      fprintf (stderr, "Error p2 != p1 - bug233 test failed.\n");
+      abort ();
+    }
+  if (bug233_p2 != &bug233_v1)
+    {
+      fprintf (stderr, "Error p2 != &v1 - bug233 test failed.\n");
+      abort ();
+    }
+  if (*bug233_p2 != 101)
+    {
+      fprintf (stderr, "Error *p2 = %d, expected: 101 - bug233 test failed.\n",
+                       *bug233_p2);
+      abort ();
+    }
+  upc_barrier;
+}
+
+/* Bug 235: incorrect address calculation involving blocked PTS
+ * and a negative index.  This failure was originally discovered
+ * when running the "compound_test" test in the new (RC2) GWU GUTS
+ * test, though it has nothing to do with that test.   This test
+ * fails only if THREADS > 2.  Upon further analysis, the incorrect
+ * calculation implies to all negative index values. The reasons
+ * for this boil down to the need to insure that a signed
+ * floor_div() and floor_mod() calculation is used when performing
+ * the address calculation. */
+void
+bug235_test()
+{
+  shared [5] int *p1;
+  int i;
+  p1 = (shared[5] int *) upc_all_alloc(3*THREADS, 5*sizeof(int));
+  if (!p1)
+    {
+      fprintf(stderr, "Error Bug #235 allocation failed.\n");
+      abort();
+    }
+  for (i = 1; i <= 3*THREADS*5; ++i)
+    {
+      int got = upc_threadof(p1+i-1);
+      int expected = ((i-1)/5)%THREADS;
+      if (got != expected)
+        {
+          fprintf(stderr, "Error Bug #235: affinity check for p1+i-1 failed.\n"
+            " i = %d MYTHREAD = %d affinity = %d expected = %d\n",
+            i, MYTHREAD, got, expected);
+          abort ();
+        }
+    }
+  upc_all_free (p1);
+}
+
+/* bug 236: bugzilla/bug1126.upc fails to compile -
+   reports __copyblk3 has incompatible type for argument 2
+   Problem occurs when a PTS is in shared space.  The result
+   of incrementing/decrementing the pointer is erroneously
+   qualified as "shared".   A similar situation arises
+   for regular pointer arithmetic (bug 226) which is also
+   tested below. */
+shared [5] int bug236_A[5*THREADS];
+shared [5] int * shared bug236_ptr;
+void bug236_test ()
+{
+  int i;
+  if (!MYTHREAD)
+      bug236_ptr = bug236_A;
+  upc_barrier;
+  for (i = 0; i < 5*THREADS; ++i)
+    {
+      upc_barrier;
+      if (MYTHREAD == ((i/5)%THREADS))
+        {
+	  int expected, got;
+	  expected = (i/5)%THREADS;
+	  got = upc_threadof (bug236_ptr);
+	  bug236_ptr = bug236_ptr + 1;
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "Error threadof(%i) = %d, "
+	               "expected: %d - bug226 test failed.\n",
+		       i, got, expected);
+	      abort ();
+	    }
+        }
+      upc_barrier;
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+      bug236_ptr = bug236_A;
+  upc_barrier;
+  for (i = 0; i < 5*THREADS; ++i)
+    {
+      upc_barrier;
+      if (MYTHREAD == ((i/5)%THREADS))
+        {
+	  int expected, got;
+	  expected = (i/5)%THREADS;
+	  got = upc_threadof (bug236_ptr++);
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "Error threadof(%i) = %d, "
+	               "expected: %d - bug236 test failed.\n",
+		       i, got, expected);
+	      abort ();
+	    }
+        }
+      upc_barrier;
+    }
+  upc_barrier;
+}
+
+int
+get_prev()
+{
+  /* The following generated an internal compiler error
+     in gimplify_expr() when compiled at -O0 using the
+     packed PTS representation.  */
+  int val = gimple_arr[MYTHREAD?(MYTHREAD-1):THREADS-1];
+  return val;
+}
+
+void
+gimple_bug_test()
+{
+  int expected, got;
+  if (!MYTHREAD)
+    {
+      int i;
+      for (i = 0; i < THREADS; ++i) gimple_arr[i] = (i+1);
+    }
+  upc_barrier;
+  expected = MYTHREAD ? MYTHREAD : THREADS;
+  got = get_prev();
+  if (got != expected)
+    {
+      fprintf (stderr, "thread %i: Error: "
+               "expected: %d  got %d - gimple bug test failed.\n",
+	       MYTHREAD, got, expected);
+      abort ();
+    }
+  upc_barrier;
+}
+
+void
+bupc_bug53_test ()
+{
+  if (MYTHREAD == 0)
+    {
+      int i;
+      bupc_bug53_p = (int *) malloc (10 * sizeof (int));
+      for (i = 0; i < 10; i++)
+	bupc_bug53_p[i] = i;
+      for (i = 0; i < 10; i++)
+	{
+	  int expected = i;
+	  int got = bupc_bug53_p[i];
+	  if (got != expected)
+	    {
+	      fprintf (stderr, "Error: expected: %d, got: %d "
+	               "- BUPC bug53 test failed\n",
+	               expected, got);
+	      abort ();
+	    }
+	}
+      free (bupc_bug53_p);
+    }
+}
+
+void
+bupc_bug206_test()
+{
+  sintptr *local = &bupc_206_S;
+  bupc_206_S = bupc_206_A;
+  local[0] = NULL;  /* local[0] is an alias for 'S' */
+  if (bupc_206_S != NULL)
+    {
+      fprintf (stderr, "%d: Error: S != NULL"
+                       " - BUPC bug206 test failed.\n", MYTHREAD);
+      abort();
+    }
+}
+
+void
+bug323_test ()
+{
+  static size_t shared full_filevec_datasz = 10;
+  static size_t shared full_full_smemvec_cnt1 __attribute__ ((unused)) = 0;
+  static size_t shared full_full_smemvec_cnt  __attribute__ ((unused)) = 0;
+  static unsigned int neededsz_bytes = 0;
+  while (0) {
+     /* Bug 323: ICE: in statement below.
+        "The cause of failure is subtle. Internally, the compiler tries to
+	cache constants in the form (<type> <value>). In the failing test, there
+	are two places that it creates a ((shared unsigned int) 0) constant.
+	But the internal cache discards "shared", yet the code tries to compare
+	the constant's type that it pulls from the cache with the (shared
+	unsigned int) type. They don't match, and the assertion fails."  */
+     if (full_filevec_datasz > 0 &&
+        full_filevec_datasz >= neededsz_bytes) break;
+  }
+}
+
+
+typedef struct
+{
+  shared [] unsigned char *r;
+} RowOfBytes;
+
+#define BLK_349 100
+shared [BLK_349] unsigned char data_349[BLK_349 * THREADS];
+shared RowOfBytes A_349[THREADS];
+
+void bug349_proc (shared RowOfBytes *arr, int i)
+{
+  int j;
+  for (j = 0; j < BLK_349; ++j)
+    {
+      /* Bug 349: ICE: GUPC 4.3 - assertion check on
+         attempt to create a shared temp, when compiling
+         sobel (optimized).  */
+      arr[i].r[j] = (unsigned char) (j + 1);
+    }
+}
+
+void
+bug349_test ()
+{
+  A_349[MYTHREAD].r = (shared [] unsigned char *)
+                      &data_349[BLK_349 * MYTHREAD];
+  upc_barrier;
+  bug349_proc (A_349, MYTHREAD);
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      int i, j;
+      for (i = 0; i < THREADS; ++i)
+	{
+	  for (j = 0; j < BLK_349; ++j)
+	    {
+	      unsigned char expected = (unsigned char) (j + 1);
+	      unsigned char got = A_349[i].r[j];
+	      if (got != expected)
+	        {
+		  fprintf (stderr, "Error: expected: %d, got: %d - bug 349 test failed\n",
+			   (int) expected, (int) got);
+		  abort ();
+	        }
+	    }
+	}
+    }
+}
+
+#define SZ_351 1000
+shared int A_351[SZ_351*THREADS];
+
+void
+bug351_test ()
+{
+  /* bug 351: THREADS factor ignored in sizeof() calculation when compiled in
+   * dynamic environment.  */
+  if (!MYTHREAD)
+    {
+      unsigned long expected = ((unsigned long) SZ_351
+                                * (unsigned long) THREADS
+                                * (unsigned long) sizeof(A_351[0]));
+      unsigned long got = (unsigned long) sizeof (A_351);
+      if (got != expected)
+        {
+	  fprintf (stderr, "Error: expected: %lu, got: %lu - bug 351 test failed\n",
+		   expected, got);
+	  abort ();
+        }
+    }
+}
+
+/*   Bug 362: ICE for pointer comparison when compiler
+     configured with --enable-checking-types.
+
+     error: type mismatch in comparison expression
+     internal compiler error: verify_gimple failed */
+
+shared [10] int A_362[20*THREADS];
+
+void
+bug362_test ()
+{
+  /* Code partially taken from BUPC Bugzilla bug2280.upc */
+  const int expected = 1;
+  int got;
+  shared [10] int *p = &A_362[8];
+  shared [10] int *q = &A_362[11];
+  /* ICE on pointer comparison below.  Note: the comparison
+     and assignment to 'got' should remain as written.  */
+  if (p > q)
+    got = 1;
+  else
+    got = 0;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug362: shared pointer comparison failed"
+                       " got %d expected %d\n", got, expected);
+      abort ();
+    }
+}
+
+
+/* bug 402: ICE: '[*]' layout factor on multi-dimensional shared array with
+   dynamic threads.  */
+shared [*] int A_402[THREADS][16];
+
+void
+bug402_test ()
+{
+  int i, j;
+  for (j = 0; j < 16; ++j)
+    A_402[MYTHREAD][j] = MYTHREAD*16 + j + 1;
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      if (upc_blocksizeof(A_402) != 16)
+	{
+	  fprintf (stderr, "Error: blocksizeof(A_402) != 16  "
+	           "- bug 402 test failed\n");
+	  abort ();
+	}
+      for (i = 0; i < THREADS; ++i)
+        for (j = 0; j < 16; ++j)
+	  {
+	    int expected = i*16 + j + 1;
+	    int got = A_402[i][j];
+	    if (got != expected)
+	      {
+		fprintf (stderr, "Error: expected: %d, got: %d - bug 402 test failed\n",
+			 expected, got);
+		abort ();
+	      }
+	  }
+    }
+}
+
+void
+test18()
+{
+  int i, j;
+  int got;
+  int expected;
+  /* bug 56: can't initialize a shared pointer to NULL at auto scope */
+  shared int *sptr_auto = 0;
+  /* bug 63: compiler refuses to initialize a pointer-to-shared,
+     unless the initialization expression is 'simple' */
+  shared [3] int * p_3_init = &(a_3_by_3[2][2]);
+  /* bug 67: ICE on array initializer that references the address
+     of shared variable */
+  shared [5] int *p5_array[] = {&a_blk5[0], &a_blk5[9],
+                                &a_blk5[4*MYTHREAD], 0};
+  /* bug 24: upc_elemsizeof unimplemented */
+  got = upc_elemsizeof a_3_by_3;
+  expected = sizeof (int);
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug24: upc_elemsizeof failed: "
+               "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 25: upc_blocksizeof fails on arrays with THREADS multiple */
+  got = upc_blocksizeof a_3_by_3;
+  expected = 3;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug25: upc_blocksizeof fails "
+               "on arrays with THREADS multiple: got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 26: upc_blocksizeof does not return 0 for arrays
+     with indefinite block size */
+  got = upc_blocksizeof a_indef;
+  expected = 0;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug26: upc_blocksizeof does not "
+               "return 0 for arrays with indefinite block size: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 31: layout '[*]' not implemented */
+  got = upc_blocksizeof a_star_10;
+  expected = 10;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 31: layout '[*]' not implemented: "
+               "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 39: can't statically initialize pointer-to-shared with NULL */
+  got = !shared_ptr_null_init;
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 39: can't statically initialize "
+               "pointer-to-shared with NULL: got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 46: upc_alloc unimplemented */
+  ptr_to_shared_int = upc_alloc (sizeof (int));
+  got = !!ptr_to_shared_int;
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 46: upc_alloc unimplemented: "
+               "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 46: upc_affinitysize unimplemented */
+  got = upc_affinitysize (3 * 5 * sizeof(int) * THREADS,
+                          5 * sizeof(int), MYTHREAD);  
+  expected = 3 * 5 * sizeof (int);
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 46: upc_affinitysize unimplemented: "
+               "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 48: upc_lock_free unimplemented */
+  /* We can't test upc_lock_free(), so we'll just call it. */
+  lock = upc_global_lock_alloc ();
+  upc_lock_free (lock);
+#ifndef sgi /* KNOWN BUG #89 */
+  /* bug 52: upc_resetphase unimplemented */
+  ptr_to_blk5 = upc_resetphase (&a_blk5[1]);
+  got = upc_phaseof (ptr_to_blk5);
+  expected = 0;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 52: upc_resetphase unimplemented: "
+               "got %d expected %d\n", got, expected);
+      abort ();
+    }
+#endif /* !sgi */
+  /* bug 53: cast of pointer-to-shared with differing block size
+     does not reset phase */
+  ptr_to_blk5 = &a_blk5[3];
+  ptr_to_blk3 = (shared [3] int *)ptr_to_blk5;
+  got = upc_phaseof (ptr_to_blk3);
+  expected = 0;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 53: cast of pointer-to-shared "
+               "with differing block size does not reset phase: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 54: upc_fence is unimplemented */
+  upc_fence;
+  /* bug 55: upc_poll is unimplemented */
+  upc_poll();
+  /* bug 56: can't initialize a shared pointer to NULL at auto scope */
+  got = (sptr_auto == (shared void *)0);
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 56: can't initialize a "
+               "shared pointer to NULL at auto scope: got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 59: UPC_MAX_BLOCK_SIZE is not an integer constant */
+#if UPC_MAX_BLOCK_SIZE > 0
+  got = 1;
+#else
+  got = 0;
+#endif
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 59: UPC_MAX_BLOCK_SIZE is not "
+               "an integer constant: got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 62: pointer to shared incomplete type with
+     layout specifier not deferred to type completion */
+  got = upc_blocksizeof *ptr_to_incomplete;
+  expected = 10;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 62: pointer to shared incomplete type "
+               "with layout specifier not deferred to type completion: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 63: compiler refuses to initialize a pointer-to-shared,
+     unless the initialization expression is 'simple' */
+  got = (p_3_init == &a_3_by_3[2][2]);
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 63: compiler refuses to initialize "
+               "a pointer-to-shared, unless the initialization "
+	       "expression is 'simple': got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 67: ICE on array initializer that references the address
+     of shared variable */
+  got = (p5_array[2] == &a_blk5[4*MYTHREAD]);
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 67: ICE on array initializer "
+               "that references the address of shared variable: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 68: comparison between generic pointer to shared,
+     and pointer to shared fails */
+  ptr_to_blk5 = &a_blk5[4];
+  got = ((shared void *)&a_blk5[4] == ptr_to_blk5);
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 68: comparison between "
+               "generic pointer to shared, and pointer to shared fails: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 70: indirection through shared local pointer fails */
+  lock = upc_all_lock_alloc ();
+  upc_barrier;
+  upc_lock (lock);
+  shared_ptr_to_local_int = &local_int;
+  got = *shared_ptr_to_local_int;
+  upc_unlock (lock);
+  upc_all_lock_free (lock);
+  upc_barrier;
+  expected = 99;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 70: indirection through "
+               "shared local pointer fails: got %d expected %d\n",
+               got, expected);
+      abort ();
+    }
+  /* bug 71: upc_forall with integer affinity fails */
+  upc_forall (i = 0; i < THREADS; ++i; i)
+  {
+    got = i;
+    expected = MYTHREAD;
+    if (got != expected)
+      {
+        fprintf (stderr, "Error bug 71: upc_forall with "
+	         "integer affinity fails: got %d expected %d\n",
+                 got, expected);
+        abort ();
+      }
+  }
+  /* bug 75: indirection through pointer-to-shared which is
+     itself shared fails */
+  if (!MYTHREAD)
+    {
+      a_blk5[1] = 99;
+      shared_ptr_to_shared = &a_blk5[1];
+    }
+  upc_barrier;
+  got = *shared_ptr_to_shared;
+  expected = 99;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 75: indirection through "
+               "pointer-to-shared which is itself shared fails: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 77: anonymous barriers generate barrier id mismatch */
+  if (MYTHREAD % 2)
+    {
+      upc_barrier 1;
+      got = (MYTHREAD % 2) == 1;
+    }
+  else
+    {
+      upc_barrier;
+      got = (MYTHREAD % 2) == 0;
+    }
+  expected = 1;
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 77: anonymous barriers "
+               "generate barrier id mismatch: "
+	       "got %d expected %d\n", got, expected);
+      abort ();
+    }
+  /* bug 95: cast of pointer to shared const misclassified as an error */
+  upc_barrier;
+  for (i = 0; i < 10; ++i)
+    {
+      shared_struct.field[i] = 99;
+    }
+  expected = 99;
+  /* should not complain attempt to cast shared pointer to local pointer */
+  got = *((shared int *)shared_struct.field);
+  if (got != expected)
+    {
+      fprintf (stderr, "Error bug 95: cast of pointer to shared const"
+               "misclassified as an error: got %d expected %d\n",
+	       got, expected);
+      abort ();
+    }
+  /* bug 96: ICE: combination of shared and volatile crashes the compiler */
+  upc_barrier;
+  for (i = 0; i < 10; ++i)
+    {
+      shared_vol2[i][MYTHREAD] = i*THREADS + MYTHREAD;
+    }
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      for (i = 0; i < 10; ++i)
+	{
+	  for (j = 0; j < THREADS; ++j)
+	    {
+	      expected = i*THREADS + j;
+	      got = shared_vol2[i][j];
+	      if (got != expected)
+		{
+		  fprintf (stderr, "Error bug 96: ICE: combination of "
+		           "shared and volatile crashes the "
+			   "compiler failed: got %d expected %d\n",
+			   got, expected);
+		  abort ();
+		}
+	    }
+	}
+    }
+  /* bug 100: invalid compilation error when casting null
+     pointer to shared to local pointer */
+  upc_barrier;
+  localPtr = &localData;
+  localPtr = (double *)(shared [] double *) NULL;
+  if (localPtr != NULL)
+    {
+      fprintf (stderr, "Error bug 100: failed #1 "
+               "- null local pointer expected.\n");
+    }
+  localPtr = &localData;
+  localPtr = (double *)(shared void *) NULL;
+  if (localPtr != NULL)
+    {
+      fprintf (stderr, "Error bug 100: failed #2 "
+               "- null local pointer expected.\n");
+    }
+  localPtr = &localData;
+  localPtr = (double *)((shared void *) 0);
+  if (localPtr != NULL)
+    {
+      fprintf (stderr, "Error bug 100: failed #3 "
+               "- null local pointer expected.\n");
+    }
+  upc_barrier;
+  /* Bug 103: ICE: codegen (AMD64) - fail in emit_move_insn
+     when evaluating shared array element actual parameters */
+  for (i=0; i<100; i++)
+    for (j=0; j<4; j++)
+       save_err[i][j][MYTHREAD] = 1.0e-6;
+  upc_barrier;
+  for (i=0; i<100; i++)
+   {
+      int ok;
+      ok = process_errors (save_err[i][0][MYTHREAD], save_err[i][1][MYTHREAD],
+                           save_err[i][2][MYTHREAD], save_err[i][3][MYTHREAD]);
+      if (!ok)
+        {
+          fprintf (stderr, "Error bug 103: failed "
+	           "- save_err[%d][0..3][%d] exceeds"
+                   " error tolerance (%0.3lg,%0.3lg,%0.3lg,%0.3lg)\n",
+                   i, MYTHREAD,
+                   save_err[i][0][MYTHREAD], save_err[i][1][MYTHREAD],
+                   save_err[i][2][MYTHREAD], save_err[i][3][MYTHREAD]);
+          abort ();
+        }
+    }
+  upc_barrier;
+  /* Bug 104: Erroneous code generated */
+  for (i=0; i<16; i++)
+    {
+      bug104_TT[i][MYTHREAD] = i;
+    }
+  upc_barrier;
+  bug104_proc (4, MYTHREAD); 
+  upc_barrier;
+  /* Bug 106: GUPC fails with internal error on
+     a few UPCR regression tests on OPTERON (x86_64) systems */
+  {
+    int i1, i2, i3, i4, i5, i6;
+    shared [] double *p;
+    double got, expected;
+    bug106_u = upc_alloc (10 * sizeof(bug106_u_t));
+    j = 0;
+    for (i1 = 0; i1 < 10; ++i1)
+      for (i2 = 0; i2 < 9; ++i2)
+        for (i3 = 0; i3 < 8; ++i3)
+          for (i4 = 0; i4 < 7; ++i4)
+            for (i5 = 0; i5 < 6; ++i5)
+              for (i6 = 0; i6 < 5; ++i6)
+                bug106_u[i1].local[i2][i3][i4][i5][i6] = (double)(++j);
+    upc_barrier;
+    p = bug106_func (2, 1);
+    got = *p;
+    expected = 2141;
+    if (got != expected)
+      {
+        fprintf (stderr, "Error bug 106: failed - got: %0.5g expected %0.5g\n",
+	                  got, expected);
+	abort ();
+      }
+  }
+  upc_barrier;
+  bupc156_test ();
+  upc_barrier;
+  bug228_test ();
+  upc_barrier;
+  bug230_test ();
+  upc_barrier;
+  bug233_test ();
+  upc_barrier;
+  bug235_test ();
+  upc_barrier;
+  bug236_test ();
+  upc_barrier;
+  gimple_bug_test ();
+  upc_barrier;
+  bupc_bug53_test ();
+  upc_barrier;
+  bupc_bug206_test ();
+  upc_barrier;
+  bug323_test ();
+  upc_barrier;
+  bug349_test ();
+  upc_barrier;
+  bug351_test ();
+  upc_barrier;
+  bug402_test ();
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      printf ("test18: miscellaneous regression tests - passed.\n");
+    }
+}
+
+int two() { return 2; }
+volatile int v2;
+
+int
+main()
+{
+  test18 ();
+  /* bug 65: default 'return 0;' not being implemented for main program */
+  /* force the value 2 into the return register before falling off 'main'
+     to ensure that the return from main isn't zero, unless the compiler
+     adds the required default 'return 0;'. */
+  v2 = two ();
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test19.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test19.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test19.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,286 @@
+/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#undef min
+#undef max
+#undef abs
+#undef ceil
+#undef round_up
+
+#define min(x,y) (((x) < (y)) ? (x): (y))
+#define max(x,y) (((x) > (y)) ? (x): (y))
+#define abs(x) (((x) > 0) ? (x): -(x))
+#define ceil(x, r) (((x) + (r) - 1)/(r))
+#define round_up(x, r) (ceil(x,r)*(r))
+
+#define ALLOC_OVERHEAD 64
+#define ALLOC_CHUNK_SIZE 64
+#define MIN_ALLOC (ALLOC_OVERHEAD + ALLOC_CHUNK_SIZE)
+/* We calculate the largest (default) allocation,
+   adjusting for overhead and for the allocation of a lock. */
+#define MAX_ALLOC_SIZE (10*1024*1024-ALLOC_OVERHEAD-MIN_ALLOC)
+#define AVE_ALLOC_SIZE 10000
+/* Given that the sizes are generated randomly, it is unlikely that
+   we'll need a table as large as twice the expected average number
+   of allocations. Further since we're distributing the allocations
+   across threads, the actual maximum is likely much lower than this. */
+#define AVE_ALLOCS ceil(MAX_ALLOC_SIZE, AVE_ALLOC_SIZE)
+#define MAX_ALLOCS 2*AVE_ALLOCS
+/* Given that allocations occur in a 2:1 ratio in the first
+   phase and that deallocations occur in a 2:1 ratio in the
+   second phase, we would expect on average 3 times the expected
+   number of allocations for the number of
+   iterations inclusive of allocations and deallocations
+   in each phase. */
+#define MAX_ITERS 3*AVE_ALLOCS
+shared void *ptrs[MAX_ALLOCS];
+size_t sizes[MAX_ALLOCS];
+/* 'N' records the number of entries in (ptrs, sizes) */
+int N;
+/* 'N_max' is used in the deallocation phase to record
+   the high water value of 'N' */
+int N_max;
+
+upc_lock_t *lock;
+shared void * strict shared global_ptr;
+
+/* Burn a few random cycles */
+void keep_busy ()
+{
+  volatile long busy_count;
+  busy_count = (long)(random() % 20000);
+  while (--busy_count > 0) /* loop */ ;
+}
+
+void
+test19()
+{
+  shared void *p;
+  int i;
+  size_t sz;
+  size_t alloc_quota;
+  /* set random seed so each thread generates a different sequence */
+  srandom (MYTHREAD + 1);
+  lock = upc_all_lock_alloc();
+  if (!lock)
+    {
+      fprintf (stderr, "Error: upc_all_lock_alloc() failed.\n");
+      abort ();
+    }
+  upc_barrier;
+  if (!MYTHREAD) global_ptr = 0;
+  upc_barrier;
+  /* allocate a big block and/or free it 10 times on each thread */
+  for (i = 0; i < 10; ++i)
+    {
+      /* delay a little to randomize sequencing on the lock */
+      keep_busy ();
+      upc_lock (lock);
+      if (global_ptr)
+        {
+	  upc_free (global_ptr);
+	  global_ptr = 0;
+        }
+      else
+        {
+	  global_ptr = upc_global_alloc (THREADS, MAX_ALLOC_SIZE);
+	  if (!global_ptr)
+	    {
+	      fprintf (stderr, "%d: Error: failed to "
+	               "allocate large block\n", MYTHREAD);
+	      abort ();
+	         
+	    }
+	}
+      upc_unlock (lock);
+    }
+  upc_barrier;
+  /* clean up */
+  upc_all_free (global_ptr);
+  upc_barrier;
+  /* The following test proceeds in two phases. The first is an
+     allocation phase, where about 2/3's of the time the threads
+     will allocate and 1/3 of the time, they'll deallocate.
+
+     Then, once everything is allocated, go into a deallocation
+     phase where about 2/3's of the time de-allocations are performed
+     and 1/3 of the time they'll be allocated.
+     
+     Once everything has been deallocated, we verify that we
+     can once again allocate the largest possible memory
+     segment.  */
+  /* Each thread will try to allocate its 'quota' of memory
+     space. Note that since most dynamic memory managers
+     generate internal fragmentation, it is unlikely that
+     each thread will allocate its quota. This is
+     unimportant, because what we're after is the test at
+     the end to see that all the memory was returned. */
+  alloc_quota = MAX_ALLOC_SIZE / THREADS;
+  if (MYTHREAD == (THREADS - 1))
+    alloc_quota += MAX_ALLOC_SIZE % THREADS;
+#ifdef VERBOSE
+  setbuf(stdout, 0);
+  upc_lock (lock);
+  printf ("%d: allocation quota = %d\n", MYTHREAD, (int)alloc_quota);
+  upc_unlock (lock);
+#endif /* VERBOSE */
+  N = 0;
+  int iter = 0;
+  while (alloc_quota > 0)
+    {
+      int do_alloc = (random() % 3) < 2;
+      if (do_alloc || N == 0 || iter++ > MAX_ITERS)
+        {
+	  size_t alloc_size;
+	  sz = random() % (2 * AVE_ALLOC_SIZE) + 1;
+	  alloc_size = ALLOC_OVERHEAD + round_up (sz, ALLOC_CHUNK_SIZE);
+	  if ((alloc_size >= alloc_quota)
+	      || (alloc_quota < MIN_ALLOC))
+	    sz = alloc_quota - ALLOC_OVERHEAD;
+	  alloc_size = ALLOC_OVERHEAD + round_up (sz, ALLOC_CHUNK_SIZE);
+	  if (alloc_size > alloc_quota)
+	    {
+	      alloc_quota = 0;
+	      continue;
+	    }
+	  alloc_quota -= alloc_size;
+#ifdef VERBOSE
+          upc_lock (lock);
+	  printf ("%d: allocate %ld, %d\n", MYTHREAD, (long int)sz, (int)alloc_quota);
+          upc_unlock (lock);
+#endif /* VERBOSE */
+	  p = upc_global_alloc (THREADS, sz);
+	  if (p)
+	    {
+	      ptrs[N]    = p;
+	      sizes[N++] = sz;
+	    }
+	  else
+	    break;
+          if (N == MAX_ALLOCS) break; /* DOB: prevent buffer overrun */
+	}
+      else
+        {
+	  int k;
+	  /* deallocate a random entry */
+	  k = random() % N;
+	  p = ptrs[k];
+	  sz = sizes[k];
+	  for (i = k; i < (N - 1); ++i)
+	    {
+	      ptrs[i]  = ptrs[i+1];
+	      sizes[i] = sizes[i+1];
+            }
+	  N = N - 1;
+#ifdef VERBOSE
+          upc_lock (lock);
+	  printf ("%d: free %d, %d\n", MYTHREAD, (int)sz, (int)alloc_quota);
+          upc_unlock (lock);
+#endif /* VERBOSE */
+	  upc_free (p);
+	  alloc_quota +=  ALLOC_OVERHEAD
+	                  + round_up (sz, ALLOC_CHUNK_SIZE);
+	}
+    }
+  upc_barrier;
+#ifdef VERBOSE
+  upc_lock (lock);
+  printf ("%d: finished allocation phase, %ld bytes left\n",
+	  MYTHREAD, (long int)alloc_quota);
+  upc_unlock (lock);
+#endif /* VERBOSE */
+  /* deallocation phase */
+  N_max = N;
+  iter = 0;
+  while (N > 0)
+    {
+      int do_alloc = (random() % 3) < 1;
+      iter++;
+      if (do_alloc && (N < N_max) && iter < MAX_ITERS)
+        {
+	  sz = sizes[N];
+#ifdef VERBOSE
+          upc_lock (lock);
+	  printf ("%d: allocate %ld\n", MYTHREAD, (long int)sz);
+          upc_unlock (lock);
+#endif /* VERBOSE */
+	  p = upc_global_alloc (THREADS, sz);
+	  if (p)
+	    ptrs[N++]    = p;
+	  else
+	    continue;
+	}
+      else
+        {
+	  int k;
+	  /* deallocate a random entry */
+	  k = random() % N;
+	  p = ptrs[k];
+	  sz = sizes[k];
+	  for (i = k; i < (N_max - 1); ++i)
+	    {
+	      ptrs[i]  = ptrs[i+1];
+	      sizes[i] = sizes[i+1];
+            }
+	  sizes[N_max-1] = sz;
+	  N = N - 1;
+#ifdef VERBOSE
+          upc_lock (lock);
+	  printf ("%d: free %d\n", MYTHREAD, (int)sz);
+          upc_unlock (lock);
+#endif /* VERBOSE */
+	  upc_free (p);
+	}
+    }
+  upc_barrier;
+  /* At this point, everything should've been deallocated, and
+     we can safely allocate the big block again. */
+  if (MYTHREAD == 0)
+    {
+      global_ptr = upc_global_alloc (THREADS, MAX_ALLOC_SIZE);
+      if (!global_ptr)
+	{
+	  fprintf (stderr, "Error: Failed to allocate large block in final stage.\n");
+	  abort ();
+	     
+	}
+      upc_free (global_ptr);
+      printf ("test19: intensive global memory allocator test - passed.\n");
+    }
+}
+
+int
+main()
+{
+  test19 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test20.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test20.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test20.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,97 @@
+/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct {
+  double real;
+  double imag;
+} dcomplex;
+
+#define NTDIVNP 65536
+
+typedef struct dcomplex_cell_s dcomplex_cell_t;
+struct dcomplex_cell_s {
+  dcomplex cell[NTDIVNP];
+};
+
+shared dcomplex_cell_t *sh0;
+shared dcomplex_cell_t *sh1;
+
+void
+test20 ()
+{
+  int i;
+  sh0 = (shared dcomplex_cell_t *)
+        upc_all_alloc (THREADS, sizeof (dcomplex_cell_t));
+  sh1 = (shared dcomplex_cell_t *)
+        upc_all_alloc (THREADS, sizeof (dcomplex_cell_t));
+  for (i = 0; i < NTDIVNP; ++i)
+    {
+      sh0[MYTHREAD].cell[i].real = (double)(MYTHREAD * NTDIVNP + i); 
+      sh0[MYTHREAD].cell[i].imag = -sh0[MYTHREAD].cell[i].real;
+    }
+  upc_barrier;
+  /* block copy from shared memory to local slice, same thread. */
+  upc_memget ((dcomplex *)&sh1[MYTHREAD].cell[0],
+             &sh0[MYTHREAD].cell[0], sizeof(dcomplex) * NTDIVNP);
+  upc_barrier;
+  for (i = 0; i < NTDIVNP; ++i)
+    {
+      double expected_real = (double)(MYTHREAD * NTDIVNP + i);
+      double expected_imag = -expected_real;
+      double got_real = sh1[MYTHREAD].cell[i].real;
+      double got_imag = sh1[MYTHREAD].cell[i].imag;
+      if (got_real != expected_real)
+        {
+	  fprintf (stderr, "%d: Error mismatch at %i"
+	           "- real, expected: %7.0lf got: %7.0lf\n",
+	           MYTHREAD, i, expected_real, got_real);
+          abort ();
+	}
+      if (got_imag != expected_imag)
+        {
+	  fprintf (stderr, "%d: Error mismatch at %i"
+	           "- imag, expected: %7.0lf got: %7.0lf\n",
+	           MYTHREAD, i, expected_imag, got_imag);
+          abort ();
+	}
+    }
+  upc_all_free (sh0);
+  upc_all_free (sh1);
+  upc_barrier;
+  if (MYTHREAD == 0)
+    printf ("test20: block copy via upc_memget test passed.\n");
+  upc_barrier;
+}
+
+int main ()
+{
+  test20 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test21.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test21.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test21.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,83 @@
+/* Copyright (C) 2006-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* The size needs to be large enough to cross several pages
+   of the underlying runtime implemented virtual memory.  */
+#define BUF_SIZE 31419265
+
+void
+test21 ()
+{
+  shared char *ptr;
+  shared [] char *str;
+  char *s;
+  int k;
+  ptr = upc_all_alloc (THREADS, BUF_SIZE);
+  if (!ptr)
+    {
+      fprintf (stderr, "%d: Error: upc_all_alloc() failed\n",
+	       MYTHREAD);
+      abort ();
+    }
+  upc_barrier;
+  /* Verify that the local addresses are sequential and that
+     they map back to the remote addresses */
+  s = (char *)&ptr[MYTHREAD]; /* local <- shared */
+  str = (shared [] char *)&ptr[MYTHREAD];
+  for (k = 0; k < BUF_SIZE; ++k)
+    {
+      void *local_addr = (void *)&s[k];
+      void *remote_to_local_addr = (void *)&str[k];
+      if (local_addr != remote_to_local_addr)
+	{
+	  fprintf (stderr, "%d: Error: address compare "
+	           "for size %ld failed at index %d\n"
+	           "     Local address %016lx != %016lx "
+		   "vaddr = %016lx\n",
+	           MYTHREAD, (long int)BUF_SIZE, k,
+	           (long unsigned)local_addr,
+	           (long unsigned)remote_to_local_addr,
+	           (long unsigned)upc_addrfield(
+	             &(((shared [] char *)&ptr[MYTHREAD])[k])));
+	  abort ();
+	}
+    }
+  upc_all_free (ptr);
+  upc_barrier;
+}
+
+int
+main ()
+{
+  test21 ();
+  if (MYTHREAD == 0)
+    printf ("test21: global/local address check - passed.\n");
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test22.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test22.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test22.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,70 @@
+/* Copyright (C) 2006-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ALLOC_SIZE 0x100000	/* 1mb at the time */
+#define NALLOC 5
+
+void
+test22 ()
+{
+  shared char *x[NALLOC];
+  shared char *y;
+  int cnt = 0;
+  int i;
+
+  y = upc_global_alloc (1, 0x100);
+  for (i=0; i < NALLOC; i++)
+    {
+      x[i] = upc_alloc (ALLOC_SIZE);
+      if (x[i]) cnt++;
+    }
+  if (cnt != 5) 
+    {
+      fprintf (stderr, "test22: Error: Thread %d allocated "
+               "only %d local buffers.\n", MYTHREAD, cnt);
+      abort ();
+    }
+  for (i=0; i < NALLOC; i++)
+    {
+      upc_free(x[i]);
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+    printf ("test22: heap local allocation - passed.\n");
+  upc_barrier;
+  upc_free(y);
+}
+
+int
+main ()
+{
+  test22 ();
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test23.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test23.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test23.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,84 @@
+/* Copyright (C) 2006-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+
+struct node_s
+  {
+    shared struct node_s *next;
+    int data;
+  };
+typedef struct node_s node_t;
+typedef shared node_t *node_p;
+
+shared void *
+add_ptr(node_p ptr, size_t offset)
+{
+  return (shared void *)((shared [] char *)ptr + offset);
+}
+
+shared node_t S;
+
+void
+test23()
+{
+  node_p node = &S;
+  shared void *ptr;
+  size_t diff;
+  ptr = add_ptr (node, 64);
+  if (upc_phaseof (ptr) != 0)
+    {
+      fprintf (stderr, "Error: phase of (ptr) != 0 equals: %d\n",
+                       (int)upc_phaseof(ptr));
+      abort ();
+    }
+  if (upc_threadof (ptr) != 0)
+    {
+      fprintf (stderr, "Error: thread of (ptr) != 0 equals: %d\n",
+                       (int)upc_threadof(ptr));
+      abort ();
+    }
+  diff = (shared [] char *)ptr - (shared [] char *)node;
+  if (diff != 64)
+    {
+      fprintf (stderr, "Error: address of (ptr)"
+               "- address of (node) != 64 equals: %ld\n",
+	       (long)diff);
+      abort ();
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+    printf ("test23: add integer to (shared void *)  - passed.\n");
+}
+
+int
+main ()
+{
+  test23 ();
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test24.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test24.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test24.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,296 @@
+/* Copyright (C) 2006-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#undef min
+#define min(x,y) (((x) < (y)) ? (x) : (y))
+#undef max
+#define max(x,y) (((x) > (y)) ? (x) : (y))
+#undef abs
+#define abs(x) (((x) > 0) ? (x) : -(x))
+#undef ceil
+#define ceil(x, r) (((x) + (r) - 1)/(r))
+#undef round_up
+#define round_up(x, r) (ceil(x,r)*(r))
+
+/* The following sequence of numbers, when interpreted as
+   a plus number meaning allocation and a minus meaning
+   de-allocation will eventually allocate roughly 54 megabytes,
+   where approximately 1/3 of the sequence will free memory
+   and 2/3's will allocate memory. */
+const int alloc_seq[] = {
+    39603, 76, 3571, 103682, 123, 199, 4870847, -39603, 29, -4870847,
+    -3571, 7, -103682, -7, 15127, 1149851, 11, 1364, 3010349, -199,
+    4870847, 20633239, 9349, -3010349, 3, 24476, 199, 4, -76, -15127,
+    -199, 76, -9349, -20633239, 3010349, 47, 64079, 843, 15127, 7,
+    -47, -3010349, 47, -47, 199, 103682, 9349, 710647, 3010349, 521,
+    39603, -15127, -843, 2207, 271443, 20633239, 18, -4, 3571, 15127,
+    -3571, -64079, 167761, 64079, 12752043, 1860498, -271443, 843,
+    7881196, 3571, 4, -24476, 24476, 5778, 271443, 47, 439204, 322};
+#define n_alloc_seq (sizeof (alloc_seq)/sizeof(int))
+
+typedef struct alloc_node_s {
+  struct alloc_node_s *next;
+  struct alloc_node_s *prev;
+  shared void *ptr;
+  size_t size;
+} alloc_t;
+typedef alloc_t *alloc_p;
+
+alloc_t alloc_list;
+
+shared [] char * shared local_alloc[THREADS];
+
+/* Return a character code that hashes thread number 't'
+   and size 'size'.  */
+int
+char_code (int t, size_t size)
+{
+  int c = 'A' + (size * 8 + t % 8) % 26;
+  return c;
+}
+
+/* Add entry for (p, size) into the allocated list.  */
+void
+add_to_alloc_list (shared void *p, size_t size)
+{
+  alloc_p last = alloc_list.prev;
+  alloc_p a = malloc (sizeof (alloc_t));
+  if (!a)
+    { perror ("malloc"); abort (); }
+  a->prev = last;
+  a->next = &alloc_list;
+  a->ptr = p;
+  a->size = size;
+  last->next = a;
+  alloc_list.prev = a;
+}
+
+/* Return the first entry in the allocated list with
+   a size matching the 'size' parameter, and delete
+   it from the allocated list.  */
+alloc_p
+remove_from_alloc_list (size_t size)
+{
+  alloc_p last = alloc_list.prev;
+  alloc_p a;
+  for (a = alloc_list.next; (a != last) && (a->size != size);
+       a = a->next) /* loop */;
+  if (a->size != size)
+    return NULL;
+  a->prev->next = a->next;
+  a->next->prev = a->prev;
+  return a;
+}
+
+void
+test24()
+{
+  const int nxt_thread = (MYTHREAD + 1) % THREADS;
+  int pass;
+  size_t i, max_alloc;
+  char *buf; 
+  alloc_t alloc_list_init = {&alloc_list, &alloc_list, 0, 0};
+  alloc_list = alloc_list_init;
+  for (i = 0, max_alloc = 0; i < n_alloc_seq; ++i)
+    max_alloc = max (max_alloc, (size_t) abs(alloc_seq[i]));
+  max_alloc += 1;  /* add 1 for null terminator */
+  buf = (char *) malloc (max_alloc);
+  if (!buf)
+    { perror ("malloc"); abort (); }
+  /* Global allocation test */
+#ifdef DEBUG
+  if (MYTHREAD == 0)
+    printf ("--- Global Allocation Test ---\n");
+#endif /* DEBUG */
+  upc_barrier 1;
+  for (pass = 1; pass <= 2; ++pass)
+    {
+      int de_alloc_pass = (pass == 2);
+      for (i = 0; i < n_alloc_seq; ++i)
+	{
+	  size_t size = abs (alloc_seq[i]) + 1;  /* add 1 for null char. */
+	  int is_alloc = (alloc_seq[i] >= 0) ^ de_alloc_pass;
+	  if (is_alloc)
+	    {
+	      int c = char_code (nxt_thread, size);
+	      shared char *ptr;
+	      shared [] char *s;
+	      ptr = upc_all_alloc (THREADS, size);
+	      if (!ptr)
+	        {
+		  fprintf (stderr, "%d: Error: upc_all_alloc() failed\n",
+		           MYTHREAD);
+		  abort ();
+		}
+	      s = (shared [] char *)&ptr[nxt_thread];
+#ifdef DEBUG
+	      printf ("%d: allocate %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	      /* set the data for the next thread */
+	      upc_memset (s, c, size-1);
+	      s[size-1] = '\0';
+	      add_to_alloc_list (ptr, size);
+	    }
+          else
+	    {
+	      int c = char_code (MYTHREAD, size);
+	      alloc_p a = remove_from_alloc_list (size);
+	      shared char *ptr;
+	      char *s;
+	      if (!a)
+	        {
+		  fprintf (stderr, "%d: Error: can't find alloc "
+		           "list entry for size %ld\n",
+		           MYTHREAD, (long int)size);
+		  abort ();
+	        }
+	      memset (buf, c, size - 1);
+	      buf[size-1] = '\0';
+	      ptr = a->ptr;
+#ifdef DEBUG
+	      printf ("%d: check %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	      /* shared -> local */
+	      s = (char *)&ptr[MYTHREAD];
+	      if (strcmp (s, buf))
+	        {
+		  fprintf (stderr, "%d: Error: global alloc pass %d:"
+		    " data comparison failed for size %ld\n",
+                    MYTHREAD, pass, (long int)size);
+		  abort ();
+		}
+	      free (a);
+	      upc_barrier 2;
+	      /* Only one thread can free the data.  Choose a
+	         a unique thread based upon the size of the data.  */
+	      if ((size_t) MYTHREAD == (size % THREADS))
+	        {
+#ifdef DEBUG
+	          printf ("%d: free %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	          upc_free (ptr);
+	        }
+	    }
+	  upc_barrier 3;
+	}
+    }
+  /* Local allocation test */
+#ifdef DEBUG
+  if (MYTHREAD == 0)
+    printf ("--- Local Allocation Test ---\n");
+#endif /* DEBUG */
+  upc_barrier 4;
+  for (pass = 1; pass <= 2; ++pass)
+    {
+      int de_alloc_pass = (pass == 2);
+      for (i = 0; i < n_alloc_seq; ++i)
+	{
+	  size_t size = abs (alloc_seq[i]) + 1;  /* add 1 for null char. */
+	  int is_alloc = (alloc_seq[i] >= 0) ^ de_alloc_pass;
+	  if (is_alloc)
+	    {
+	      int c = char_code (nxt_thread, size);
+	      shared [] char *s;
+	      s = upc_alloc (size);
+	      if (!s)
+	        {
+		  fprintf (stderr, "%d: Error: upc_all_alloc() failed\n",
+		           MYTHREAD);
+		  abort ();
+		}
+#ifdef DEBUG
+	      printf ("%d: allocate %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	      add_to_alloc_list (s, size);
+              local_alloc[MYTHREAD] = s;
+	      upc_barrier 5;
+	      /* set the data for the next thread */
+              s = local_alloc[nxt_thread];
+	      upc_memset (s, c, size-1);
+	      s[size-1] = '\0';
+	    }
+          else
+	    {
+	      int c = char_code (MYTHREAD, size);
+	      alloc_p a = remove_from_alloc_list (size);
+	      shared [] char *ptr;
+	      char *s;
+	      int t_free;
+	      if (!a)
+	        {
+		  fprintf (stderr, "%d: Error: can't find alloc "
+		           "list entry for size %ld\n",
+		           MYTHREAD, (long int)size);
+		  abort ();
+	        }
+	      ptr = a->ptr;
+	      memset (buf, c, size - 1);
+	      buf[size-1] = '\0';
+#ifdef DEBUG
+	      printf ("%d: check %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	      /* shared -> local */
+	      s = (char *)ptr;
+	      if (strcmp (s, buf))
+	        {
+		  fprintf (stderr, "%d: Error: local alloc pass %d:"
+		    " data comparison failed for size %ld\n",
+                    MYTHREAD, pass, (long int)size);
+		  abort ();
+		}
+	      free (a);
+	      local_alloc[MYTHREAD] = ptr;
+	      upc_barrier 6;
+	      /* differing threads, based upon the size of the data,
+	         will free the locally allocated data of other
+		 threads (possibly their own data).  */
+	      t_free = (MYTHREAD + size) % THREADS;
+	      ptr = local_alloc[t_free];
+#ifdef DEBUG
+              printf ("%d: free %ld\n", MYTHREAD, (long int)size);
+#endif /* DEBUG */
+	      upc_free (ptr);
+	    }
+	  upc_barrier 7;
+	}
+    }
+  free (buf);
+  upc_barrier 8;
+}
+
+int
+main()
+{
+  test24 ();
+  if (MYTHREAD == 0)
+    printf ("test24: global/local allocation test - passed.\n");
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test25.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test25.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test25.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,91 @@
+/* Copyright (C) 2008-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+shared float f1 = 1.0;
+shared float f9 = 9.0;
+
+typedef struct { double real; double imag; } dcomplex;
+shared dcomplex complex_1_2 = { 1.0, 2.0 };
+
+/* ICE: In function '__upc_init_decls':
+   internal compiler error: in upc_shared_addr,  */
+shared int * shared ptr = NULL;
+
+void
+test25 ()
+{
+   if (!MYTHREAD)
+     {
+       int error_flag = 0;
+       float f_expected, f_got;
+       double dr_expected, dr_got;
+       double di_expected, di_got;
+       f_expected = 1.0; f_got = f1;
+       if (f_got != f_expected)
+	 {
+	   fprintf (stderr, "Error: f1 initialization failed, "
+	            "expected: %0.4g got: %0.4g\n", f_expected, f_got);
+	   error_flag = 1;
+	 }
+       f_expected = 9.0; f_got = f9;
+       if (f_got != f_expected)
+	 {
+	   fprintf (stderr, "Error: f9 initialization failed, "
+	            "expected: %0.4g got: %0.4g\n", f_expected, f_got);
+	   error_flag = 1;
+	 }
+       dr_expected = 1.0; dr_got = complex_1_2.real;
+       di_expected = 2.0; di_got = complex_1_2.imag;
+       if ((dr_got != dr_expected) || (di_got != di_expected))
+	 {
+	   fprintf (stderr, "Error: complex_1_2 initialization failed, "
+	   "expected: (%0.4lg,%0.4lg) got: (%0.4lg,%0.4lg)\n",
+	   dr_expected, di_expected, dr_got, di_got);
+	   error_flag = 1;
+	 }
+      if (ptr)
+        {
+	   fprintf (stderr, "Error: ptr initialization failed, "
+	            " expected NULL pointer\n");
+	   error_flag = 1;
+	}
+      if (error_flag)
+	abort();
+    }
+}
+
+int
+main()
+{
+  test25 ();
+  if (MYTHREAD == 0)
+    printf ("test25: UPC initialization test - passed.\n");
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test26.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test26.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test26.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,239 @@
+/* Copyright (C) 2008-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define BLKSIZE 3
+#define FACTOR 33
+#define N (FACTOR * BLKSIZE)
+#define NT (N * THREADS)
+
+shared int a[NT];
+shared [BLKSIZE] int ablocked[NT];
+
+char *
+sptr (char *buf, shared void *p)
+{
+  sprintf (buf, "(0x%0lx,%ld,%ld)",
+	   (long) upc_addrfield (p), (long) upc_threadof (p),
+	   (long) upc_phaseof (p));
+  return buf;
+}
+
+enum cmp_op
+{ EQ_OP, NE_OP, GT_OP, GE_OP, LT_OP, LE_OP,
+  FIRST_OP = EQ_OP,
+  LAST_OP = LE_OP
+};
+const char * const op_name_tbl[] =
+  {"==", "!=", ">", ">=", "<", "<="};
+
+enum pkind {phaseless, phased};
+const char * const pkind_name_tbl[] =
+  {"phaseless", "phased"};
+
+void
+test_compare (enum pkind kind, enum cmp_op op,
+              int t0, int t1, int j, int k)
+{
+  const char *const kind_s = pkind_name_tbl[kind];
+  int bs = (kind == phased) ? BLKSIZE : 1;
+  /* Calculate the index of item 'j' on thread 't0'.  */
+  int jj = ((j / bs) * THREADS + t0) * bs + (j % bs);
+  /* Calculate the index of item 'k' on thread 't1'.  */
+  int kk = ((k / bs) * THREADS + t1) * bs + (k % bs);
+  int diff = (jj - kk);
+  int expected, got;
+  if (jj < 0 || jj >= NT)
+    abort ();
+  if (kk < 0 || kk >= NT)
+    abort ();
+  switch (op)
+    {
+    case EQ_OP: expected = (diff == 0); break;
+    case NE_OP: expected = (diff != 0); break;
+    case GT_OP: expected = (diff >  0); break;
+    case GE_OP: expected = (diff >= 0); break;
+    case LT_OP: expected = (diff <  0); break;
+    case LE_OP: expected = (diff <= 0); break;
+    default: abort();
+    }
+  if (kind == phased)
+    {
+      shared [] int *const pp0_phase_reset = (shared [] int *) &ablocked[jj];
+      shared [] int *const pp1_phase_reset = (shared [] int *) &ablocked[kk];
+      shared [BLKSIZE] int *pp0, *pp1;
+      pp0 = &ablocked[jj];
+      pp1 = &ablocked[kk];
+      /* Per 6.4.2p6:
+         Two compatible pointers-to-shared which point to the
+         same object (i.e.  having the same address and thread
+         components) shall compare as equal according
+	 to == and !=, regardless of whether the phase
+	 components match.  */
+      if (op == EQ_OP)
+	pp0 = (shared [BLKSIZE] int *) pp0_phase_reset;
+      else if (op == NE_OP)
+	pp1 = (shared [BLKSIZE] int *) pp1_phase_reset;
+      switch (op)
+	{
+	case EQ_OP: got = (pp0 == pp1); break;
+	case NE_OP: got = (pp0 != pp1); break;
+	case GT_OP: got = (pp0 >  pp1); break;
+	case GE_OP: got = (pp0 >= pp1); break;
+	case LT_OP: got = (pp0 <  pp1); break;
+	case LE_OP: got = (pp0 <= pp1); break;
+	default: abort ();
+	}
+      if (got != expected)
+	{
+	  char b1[100], b2[100];
+	  const char *const op_s = op_name_tbl[op];
+	  const char *const p0_s = sptr (b1, pp0);
+	  const char *const p1_s = sptr (b2, pp1);
+	  fprintf (stderr, "test26: Error: thread %d: %s PTS comparison "
+		   "%s failed.\n"
+		   "        t0=%d t1=%d j=%d k=%d jj=%d kk=%d "
+		   "p0=%s p1=%s expected=%d got=%d\n",
+		   MYTHREAD, kind_s, op_s, t0, t1, j, k, jj, kk,
+		   p0_s, p1_s, expected, got);
+	  abort ();
+	}
+      if (op == EQ_OP || op == NE_OP)
+        {
+	  /* Per C99 6.5.9, the following comparison is allowed
+	     and does not require a cast:
+	     one operand is a pointer to an object or incomplete type
+	     and the other is a pointer to a qualified or
+	     unqualified version of void.  */
+	  shared void *const vp0 = (shared void *) &ablocked[jj];
+	  shared void *const vp1 = (shared void *) &ablocked[kk];
+	  /* xp0 and xp1 are used in error diagnostics to print
+	     the operand values.  */
+	  shared void *xp0, *xp1;
+	  switch (op)
+	    {
+	    case EQ_OP:
+	      xp0 = pp0_phase_reset;
+	      xp1 = vp1;
+	      got = (pp0_phase_reset == vp1);
+	      break;
+	    case NE_OP:
+	      xp0 = vp0;
+	      xp1 = pp1_phase_reset;
+	      got = (vp0 != pp1_phase_reset);
+	      break;
+	    default: abort ();
+	    }
+	  if (got != expected)
+	    {
+	      char b1[100], b2[100];
+	      const char *const op_s = op_name_tbl[op];
+	      const char *const p0_s = sptr (b1, xp0);
+	      const char *const p1_s = sptr (b2, xp1);
+	      fprintf (stderr, "test26: Error: thread %d: %s PTS comparison "
+		       "%s to (shared void *) failed.\n"
+		       "        t0=%d t1=%d j=%d k=%d jj=%d kk=%d "
+		       "p0=%s p1=%s expected=%d got=%d\n",
+		       MYTHREAD, kind_s, op_s, t0, t1, j, k, jj, kk,
+		       p0_s, p1_s, expected, got);
+	      abort ();
+	    }
+        }
+    }
+  else
+    {
+      shared int *p0, *p1;
+      p0 = &a[jj];
+      p1 = &a[kk];
+      switch (op)
+	{
+	case EQ_OP: got = (p0 == p1); break;
+	case NE_OP: got = (p0 != p1); break;
+	case GT_OP: got = (p0 >  p1); break;
+	case GE_OP: got = (p0 >= p1); break;
+	case LT_OP: got = (p0 <  p1); break;
+	case LE_OP: got = (p0 <= p1); break;
+	default: abort ();
+	}
+      if (got != expected)
+	{
+	  char b1[100], b2[100];
+	  const char *const op_s = op_name_tbl[op];
+	  const char *const p0_s = sptr (b1, p0);
+	  const char *const p1_s = sptr (b2, p1);
+	  fprintf (stderr, "test26: Error: thread %d: %s "
+		   "PTS comparison %s failed.\n"
+		   "        t0=%d t1=%d j=%d k=%d jj=%d kk=%d "
+		   "p0=%s p1=%s expected=%d got=%d\n",
+		   MYTHREAD, kind_s, op_s, t0, t1, j, k, jj, kk,
+		   p0_s, p1_s, expected, got);
+	  abort ();
+	}
+    }
+}
+
+void
+test26 ()
+{
+  enum pkind kind;
+  enum cmp_op op;
+  int t0, t1, j, k;
+  t0 = MYTHREAD;
+  for (kind = phaseless; kind <= phased; ++kind)
+    {
+      for (op = FIRST_OP; op <= LAST_OP; ++op)
+	{
+	  int tmax = (THREADS > 128) ? 128 : THREADS;
+	  for (t1 = 0; t1 < tmax; ++t1)
+	    {
+	      for (j = 0; j < N; ++j)
+		{
+		  for (k = 0; k < N; ++k)
+		    {
+		      test_compare (kind, op, t0, t1, j, k);
+		    }
+		}
+	    }
+	}
+    }
+}
+
+
+int
+main ()
+{
+  test26 ();
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      printf ("test26: test pointer-to-shared comparison - passed.\n");
+    }
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test27.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test27.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test27.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,360 @@
+/* Copyright (C) 2008-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef shared [] int *sintptr;
+shared [] int bupc_206_A[10];
+sintptr bupc_206_S;
+
+typedef struct point_name
+{
+  double x;
+  double y;
+  int gid;
+} point_t;
+
+typedef struct
+{
+  int n;
+  shared [] point_t *points;
+} hullinfo_t;
+
+shared [] hullinfo_t *bupc_bug275a_hull;
+
+int *shared bupc_bug53_p;
+
+shared struct point_name *shared bupc_bug645_p;
+
+typedef struct heap_struct
+{
+  shared struct heap_struct *next;
+  size_t size;
+  int alloc_seq;
+} heap_t;
+typedef shared heap_t *heap_p;
+
+struct barrier_block
+{
+  int notify;
+  int wait;
+  int id[2];
+};
+
+typedef struct barrier_block barrier_block_t;
+shared barrier_block_t btree[THREADS];
+volatile int zero;
+
+shared heap_p global_heap;
+
+
+void
+bupc_bug53_test ()
+{
+  if (MYTHREAD == 0)
+    {
+      int i;
+      bupc_bug53_p = (int *) malloc (10 * sizeof (int));
+      for (i = 0; i < 10; i++)
+	bupc_bug53_p[i] = i;
+      for (i = 0; i < 10; i++)
+	{
+	  if (bupc_bug53_p[i] != i)
+	    {
+	      printf ("Error: mismatch p[%d] != %d"
+		      " - BUPC bug53 test failed.\n", i, i);
+	      abort ();
+	    }
+	}
+      free (bupc_bug53_p);
+    }
+}
+
+void
+bupc_bug206_test ()
+{
+  sintptr *local = &bupc_206_S;
+  /* Failed with ICE on following assignment.  */
+  bupc_206_S = bupc_206_A;
+  /* local[0] is an alias for 'S' */
+  local[0] = NULL;
+  if (bupc_206_S != NULL)
+    {
+      fprintf (stderr, "%d: Error: S != NULL"
+	       " - BUPC bug206 test failed.\n", MYTHREAD);
+      abort ();
+    }
+}
+
+void
+bupc_bug275a_test ()
+{
+  int i = 0;
+  point_t *lpoints;
+  /* Allocate hull struct on this thread */
+  bupc_bug275a_hull =
+    (shared [] hullinfo_t *) upc_alloc (sizeof (hullinfo_t));
+  if (!bupc_bug275a_hull)
+    {
+      fprintf (stderr, "%d: Error: can't allocate hull struct"
+	       " - bupc_bug275a test failed.\n", MYTHREAD);
+      abort ();
+    }
+  /* Allocate 10 points in each hull structure.  */
+  bupc_bug275a_hull->n = 10;
+  bupc_bug275a_hull->points =
+    (shared [] point_t *) upc_alloc (10 * sizeof (point_t));
+  if (!bupc_bug275a_hull->points)
+    {
+      fprintf (stderr, "%d: Error: can't allocate points struct"
+	       " - bupc_bug275a test failed.\n", MYTHREAD);
+      abort ();
+    }
+  for (i = 0; i < 10; ++i)
+    {
+      int k = i + 1;
+      /* Failed with ICE on references to fields of points structure.  */
+      bupc_bug275a_hull->points[i].x = k * 1;
+      bupc_bug275a_hull->points[i].y = k * 2;
+      bupc_bug275a_hull->points[i].gid = k * 3;
+    }
+  upc_fence;
+  lpoints = (point_t *) bupc_bug275a_hull->points;
+  for (i = 0; i < 10; ++i)
+    {
+      int k = i + 1;
+      if (lpoints[i].x != 1 * k || lpoints[i].y != 2 * k
+	  || lpoints[i].gid != 3 * k)
+	{
+	  fprintf (stderr, "%d: Error: lpoints[%d] mismatch"
+		   " got: (%lf,%lf,%d) expected: (%d,%d,%d)"
+		   " - BUPC bug275a test failed.\n",
+		   MYTHREAD, i,
+		   lpoints[i].x, lpoints[i].y, lpoints[i].gid,
+		   1 * k, 2 * k, 3 * k);
+	}
+    }
+  upc_free (bupc_bug275a_hull->points);
+  upc_free (bupc_bug275a_hull);
+}
+
+void
+bupc_bug645_f (struct point_name x)
+{
+  if (x.x != 5.0 || x.y != 6.0 || x.gid != 100)
+    fprintf (stderr, "%d: Error: point_name mismatch"
+	     " got: (%0.3lg,%0.3lg,%i) expected: (5,6.100)"
+	     " - BUPC bug645 test failed.\n", MYTHREAD, x.x, x.y, x.gid);
+}
+
+void
+bupc_bug645_test ()
+{
+  if (MYTHREAD == 0)
+    {
+      bupc_bug645_p = upc_global_alloc (1, sizeof (struct point_name));
+      if (!bupc_bug645_p)
+	{
+	  fprintf (stderr, "Error: upc_global_alloc() call returned NULL"
+		   " - BUPC bug645 test failed.\n");
+	  abort ();
+	}
+      bupc_bug645_p->x = 5.0;
+      bupc_bug645_p->y = 6.0;
+      bupc_bug645_p->gid = 100;
+    }
+  upc_barrier;
+  bupc_bug645_f (*bupc_bug645_p);
+}
+
+struct bupc_bug979_struct
+{
+  int curid;
+  int last;
+};
+
+void
+bupc_bug979_test ()
+{
+  shared struct bupc_bug979_struct *G;
+  int got, expected;
+  G = (shared struct bupc_bug979_struct *)
+    upc_alloc (sizeof (struct bupc_bug979_struct));
+  G->curid = 1;
+  G->last = 90;
+  upc_fence;
+  /* Failed with ICE on following assignment. */
+  G->last += 10;
+  got = G->last;
+  expected = 100;
+  if (got != expected)
+    {
+      fprintf (stderr, "%d: Error: G->last mismatch, got: %d expected: %d"
+	       " - BUPC bug979 test failed.\n", MYTHREAD, got, expected);
+      abort ();
+    }
+}
+
+void
+heap_init (shared void *heap_base, size_t heap_size)
+{
+  heap_p heap;
+  heap = (heap_p) heap_base;
+  upc_memset (heap, '\0', sizeof (heap_t));
+  /* the size of each free list entry includes its overhead. */
+  heap->size = heap_size;
+  heap->next = NULL;
+  heap->alloc_seq = 1;
+  /* Failed with ICE on 64-bit target, and "struct" pointer representation.  */
+  global_heap = heap;
+}
+
+void
+heap_merge (heap_p ptr)
+{
+  /* Failed with ICE, with "struct" pointer representation,
+     on reference to ptr->next->alloc_seq.  */
+  if (ptr->next)
+    {
+      const shared void *const next_block =
+	(shared void *) ((shared [] char *) ptr + ptr->size);
+      if ((ptr->next == next_block)
+	  && (ptr->alloc_seq == ptr->next->alloc_seq))
+	{
+	  /* adjacent, merge this block with the next */
+	  ptr->size += ptr->next->size;
+	  ptr->next = ptr->next->next;
+	}
+    }
+}
+
+#define round_up(x, r) (((x) + (r) - 1)/(r)*(r))
+#define HEAP_ALIGN 64
+
+void
+heap_test ()
+{
+  if (!MYTHREAD)
+    {
+      const size_t sz1 = round_up (sizeof (heap_t) + 195, 64);
+      const size_t sz2 = round_up (sizeof (heap_t) + 311, 64);
+      const size_t alloc_size = sz1 + sz2;
+      heap_p heap_base;
+      heap_base = (heap_p) upc_alloc (alloc_size);
+      if (!heap_base)
+	{
+	  fprintf (stderr, "Error: can't allocate heap memory"
+		   " - heap_test failed.\n");
+	  abort ();
+	}
+      heap_init (heap_base, alloc_size);
+      if (heap_base != global_heap)
+	{
+	  fprintf (stderr, "Error: heap_base != global_heap"
+		   " - heap_test failed.\n");
+	  abort ();
+	}
+      /* Fake allocations of 195 and 311.  */
+      heap_base->size = sz1;
+      heap_base->alloc_seq = 2;
+      heap_base->next = (heap_p) ((shared [] char *) heap_base + sz1);
+      heap_base->next->size = sz2;
+      heap_base->next->alloc_seq = heap_base->alloc_seq;
+      heap_base->next->next = NULL;
+      heap_merge (heap_base);
+      upc_fence;
+      if (global_heap->size != alloc_size)
+	{
+	  fprintf (stderr, "Error: unexpected heap size after merge,"
+		   "got %ld expected %ld"
+		   " - heap_test failed.\n",
+		   (long) global_heap->size, (long) alloc_size);
+	  abort ();
+	}
+      if (global_heap->alloc_seq != 2)
+	{
+	  fprintf (stderr,
+		   "Error: unexpected heap alloc sequence id after merge,"
+		   "got %d expected %d" " - heap_test failed.\n",
+		   global_heap->alloc_seq, 2);
+          abort ();
+	}
+    }
+}
+
+void
+fold_address_of_test ()
+{
+  shared int *ptr1, *ptr2;
+  zero = 0;
+  ptr1 = (shared int *) &btree[0].wait;
+  ptr2 = (shared int *) &btree[zero].wait;
+  if ((MYTHREAD == 0) && (ptr1 != ptr2))
+    {
+      fprintf (stderr, "&__upc_btreex = (%llx,%d)\n",
+	       (long long) upc_addrfield (btree), (int) upc_threadof (btree));
+      fprintf (stderr, "ptr1 = (%llx,%d)\n",
+	       (long long) upc_addrfield (ptr1), (int) upc_threadof (ptr1));
+      fprintf (stderr, "ptr2 = (%llx,%d)\n",
+	       (long long) upc_addrfield (ptr2), (int) upc_threadof (ptr2));
+      fprintf (stderr, "ptr1 != ptr2; fold_address_of test failed\n");
+      abort ();
+    }
+}
+
+void
+test27 ()
+{
+  bupc_bug53_test ();
+  upc_barrier;
+  bupc_bug206_test ();
+  upc_barrier;
+  bupc_bug275a_test ();
+  upc_barrier;
+  bupc_bug645_test ();
+  upc_barrier;
+  bupc_bug979_test ();
+  upc_barrier;
+  heap_test ();
+  upc_barrier;
+  fold_address_of_test ();
+  upc_barrier;
+}
+
+int
+main ()
+{
+  test27 ();
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      printf
+	("test27: Test miscellaneous pointer-to-shared references - passed.\n");
+    }
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test28.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test28.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test28.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,117 @@
+/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#define N 1000
+shared unsigned long A[N * THREADS];
+shared unsigned long ix;
+
+upc_lock_t *lock;
+
+/* Burn a few random cycles */
+static void
+keep_busy ()
+{
+  volatile long busy_count;
+  busy_count = 100 + (long) (random () % 900);
+  while (--busy_count > 0) /* loop */ ;
+}
+
+/* Test for Bug 350: GUPC 4.3.2 - post-increment inside array index,
+   increments twice (for struct sptr rep). This test is derived from
+   the MTU "test_locks2" test, though does a better job of testing
+   lock correctness. */
+
+void
+test28 ()
+{
+  int i;
+  if (MYTHREAD == 0)
+    ix = 0;
+  lock = upc_all_lock_alloc ();
+  if (!lock)
+    {
+      fprintf (stderr, "Error: upc_all_lock_alloc() failed.\n");
+      abort ();
+    }
+  upc_barrier;
+  /* random seed based on thread number.  */
+  srand (211 * (MYTHREAD + 1));
+  for (i = 0; i < N; ++i)
+    {
+      unsigned long ix_prev;
+      /* delay a little to randomize sequencing on the lock */
+      keep_busy ();
+      upc_lock (lock);
+      ix_prev = ix;
+      A[ix++] = ix_prev;
+      upc_unlock (lock);
+    }
+  upc_all_lock_free (lock);
+  upc_barrier;
+  if (MYTHREAD == 0)
+    {
+      int fail = 0;
+      int error_count = 0;
+      for (i = 0; i < N * THREADS; ++i)
+	{
+	  unsigned long expected = i;
+	  unsigned long got = A[i];
+	  if (got != expected)
+	    {
+	      if (++error_count <= 20)
+		fprintf (stderr, "A[%2d] = %2ld, expected %2ld\n", i, got,
+			 expected);
+	      else if (error_count == 21)
+		fprintf (stderr, "[...]\n");
+	      fail = 1;
+	    }
+	}
+      if (fail)
+	{
+	  fprintf (stderr, "test28: failed.\n");
+	  abort ();
+	}
+    }
+}
+
+int
+main ()
+{
+  test28 ();
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      printf
+	("test28: Test post-increment as shared array index - passed.\n");
+    }
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test29.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test29.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test29.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,163 @@
+/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Test Assumptions
+   1. A "long double" has at least 64 bits of mantissa, which
+      offers 19 significant decimal digits.
+   2. The value of PI below has 15 digits of fraction
+      and one whole digit, thus 16 significant decimal digits.
+   3. There is some round-off in this calculation:
+          B[j] = A[j] + (xdouble) 100.0L;
+      Thus, we might expect that B[j] drops one significant
+      digit here/there.
+   4. By allowing for a comparison to 18 significant digits, we
+      force the comparison to require at least 4 more significant
+      digits than a regular "double" (14 digits), but leave some
+      room for accumulated round-off errors.  */
+
+#undef PI
+/* PI to 15 places */
+#define PI 3.141592653589793L
+typedef long double xdouble;
+
+#define N_PER_THREAD 10000
+#define N (N_PER_THREAD * THREADS)
+strict shared xdouble A[N];
+relaxed shared xdouble B[N];
+strict shared xdouble xA1, xA2;
+relaxed shared xdouble xB1, xB2;
+
+strict shared int pass_fail = 1;
+
+#define FAIL(msg) \
+  { \
+    fprintf (stderr, "%s:%d (thread %d) %s\n", \
+                     __FILE__, __LINE__, MYTHREAD, msg); \
+    pass_fail = 0; \
+    abort (); \
+  }
+
+#define MSG_LEN 80
+
+void
+test29 ()
+{
+  int i;
+  if (!MYTHREAD)
+    {
+      xA1 = 100.0L * PI;
+      xB1 = 200.0L * PI;
+    }
+  for (i = MYTHREAD; i < N; i += THREADS)
+    {
+      A[i] = 100.0L + (xdouble) i * PI;
+    }
+  upc_barrier;
+  for (i = MYTHREAD; i < N; i += THREADS)
+    {
+      int j = (i + 1) % N;
+      B[j] = A[j] + (xdouble) 100.0L;
+    }
+  if (!MYTHREAD)
+    {
+      xA2 = xA1;
+      xB2 = xB1;
+    }
+  upc_barrier;
+  if (xA1 != 100.0L * PI)
+    FAIL ("xA1 != 100.0 * PI");
+  if (xB1 != 200.0L * PI)
+    FAIL ("xB1 != 200.0 * PI");
+  if (xA1 != xA2)
+    FAIL ("xA1 != xA2");
+  if (xB1 != xB2)
+    FAIL ("xB1 != xB2");
+  if (xA1 >= xB1)
+    FAIL ("xA1 >= xB1");
+  if (xA2 >= xB2)
+    FAIL ("xA2 >= xB2");
+  if (xB1 <= xA1)
+    FAIL ("xB1 <= xA1");
+  if (xB2 <= xA2)
+    FAIL ("xB2 <= xA2");
+  for (i = MYTHREAD; i < N; i += THREADS)
+    {
+      xdouble expected = (100.0L + (xdouble) i * PI);
+      xdouble got = A[i];
+      /* This comparison should be exact. */
+      if (got != expected)
+	{
+	  char msg[MSG_LEN];
+	  int n_chars;
+	  xdouble rel_err;
+	  rel_err = got / expected - 1.0L;
+	  if (rel_err < 0.0)
+	    rel_err = -rel_err;
+	  n_chars = snprintf (msg, MSG_LEN,
+	             "A[%d] is: %0.15Lf expected: %0.15Lf error: %0.2Le\n",
+		     i, got, expected, rel_err);
+	  if (n_chars >= MSG_LEN)
+	    sprintf (msg, "A[%d] got != expected: output overflow\n", i);
+	  FAIL (msg);
+	}
+    }
+  for (i = MYTHREAD; i < N; i += THREADS)
+    {
+      xdouble expected = (200.0L + (xdouble) i * PI);
+      xdouble got = B[i];
+      xdouble rel_err;
+      rel_err = got / expected - 1.0L;
+      if (rel_err < 0.0)
+	rel_err = -rel_err;
+      /* This comparison should be within 18 (ie, 3+15) digits. */
+      if (rel_err > 1.0e-18)
+	{
+	  char msg[MSG_LEN];
+	  int n_chars;
+	  n_chars = snprintf (msg, MSG_LEN,
+	    "B[%d] is: %0.15Lf expected: %0.15Lf error: %0.2Le\n",
+	    i, got, expected, rel_err);
+	  if (n_chars >= MSG_LEN)
+	    sprintf (msg, "B[%d] got != expected: output overflow\n", i);
+	  FAIL (msg);
+	}
+    }
+}
+
+int
+main ()
+{
+  test29 ();
+  upc_barrier;
+  if (!MYTHREAD)
+    printf ("test29: test shared access to long double type: %s.\n",
+	    pass_fail ? "passed" : "failed");
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test30.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test30.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test30.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,142 @@
+/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+#include <upc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#if defined(__GCC_UPC__) && defined(__UPC_PTS_STRUCT_REP__)
+
+struct sptr
+{
+#if __UPC_VADDR_FIRST__
+  __UPC_VADDR_TYPE__ vaddr;
+  __UPC_THREAD_TYPE__ thread;
+  __UPC_PHASE_TYPE__ phase;
+#else
+  __UPC_PHASE_TYPE__ phase;
+  __UPC_THREAD_TYPE__ thread;
+  __UPC_VADDR_TYPE__ vaddr;
+#endif
+}
+#ifdef __UPC_PTS_ALIGN__
+__attribute__ ((aligned (__UPC_PTS_ALIGN__)))
+#endif
+  ;
+
+#define EXPECTED_PTS_ALIGN (__alignof (shared int *))
+
+struct upc_struct
+{
+  size_t len;
+  shared int *addr;
+};
+
+struct c_struct
+{
+  size_t len;
+  struct sptr addr;
+};
+
+struct upc_struct upc_a[10];
+struct c_struct c_a[10];
+
+int pass_fail = 1;
+
+void
+test30 ()
+{
+  if (!MYTHREAD)
+    {
+      if (sizeof (struct upc_struct) != sizeof (struct c_struct))
+	{
+	  fprintf (stderr,
+		   "Error: struct with PTS has different size (%d)\n"
+		   "       than the size of a struct\n"
+		   "       with an equivalent representation (%d)\n",
+		   (int) sizeof (struct upc_struct),
+		   (int) sizeof (struct c_struct));
+	  pass_fail = 0;
+	}
+      if (sizeof (upc_a) != sizeof (c_a))
+	{
+	  fprintf (stderr,
+		   "Error: array of structs with PTS has different size (%d)\n"
+		   "       than the size of an array of structs\n"
+		   "       with an equivalent representation (%d)\n",
+		   (int) sizeof (upc_a), (int) sizeof (c_a));
+	  pass_fail = 0;
+	}
+      if (__alignof (upc_a[0].addr) != __alignof (c_a[0].addr))
+	{
+	  fprintf (stderr,
+		   "Error: PTS field of struct has different alignment (%d)\n"
+		   "       than the similar field of a struct with\n"
+		   "       with an equivalent representation (%d)\n",
+		   (int) __alignof (upc_a[0].addr),
+		   (int) __alignof (c_a[0].addr));
+	  pass_fail = 0;
+	}
+      if (__alignof (c_a[0].addr) != EXPECTED_PTS_ALIGN)
+	{
+	  fprintf (stderr,
+		   "Error: PTS representation field of a struct\n"
+		   "       has different alignment (%d)\n"
+		   "       than the expected alignment of a PTS (%d)\n",
+		   (int) __alignof (c_a[0].addr), (int) EXPECTED_PTS_ALIGN);
+	  pass_fail = 0;
+	}
+    }
+}
+#endif
+
+int
+main ()
+{
+#ifdef __GCC_UPC__
+  #ifdef __UPC_PTS_STRUCT_REP__
+  test30 ();
+  upc_barrier;
+  if (!MYTHREAD)
+    {
+      printf ("test30: test GUPC struct PTS alignment: %s.\n",
+	      pass_fail ? "passed" : "failed");
+      if (!pass_fail)
+	abort ();
+    }
+  #else
+  if (!MYTHREAD)
+    printf ("test30: test GUPC struct PTS alignment: passed.\n"
+	    "(This test applies only to GUPC's struct "
+	    "PTS representation)\n");
+  #endif
+#else
+  if (!MYTHREAD)
+    printf ("test30: test GUPC struct PTS alignment: non-applicable\n"
+	    "(This test must be compiled with GUPC)\n");
+#endif
+  return 0;
+}
Index: libgupc/testsuite/libgupc.upc/intrepid/test31.upc
===================================================================
--- libgupc/testsuite/libgupc.upc/intrepid/test31.upc	(.../trunk)	(revision 0)
+++ libgupc/testsuite/libgupc.upc/intrepid/test31.upc	(.../branches/gupc)	(revision 231080)
@@ -0,0 +1,103 @@
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   This file is part of the UPC runtime library test suite.
+   Written by Gary Funck <gary@intrepid.com>
+   and Nenad Vukicevic <nenad@intrepid.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <upc.h>
+#include <upc_tick.h>
+
+
+/* Generic timing function.  */
+static
+uint64_t
+ref_get_ns (void)
+{
+  struct timeval tv;
+  uint64_t t;
+  if (gettimeofday (&tv, NULL) != 0)
+    {
+      perror ("gettimeofday");
+      abort ();
+    }
+  t = (uint64_t) tv.tv_sec * 1000000000LL
+      + (uint64_t) tv.tv_usec * 1000LL;
+  return t;
+}
+
+void
+test31 (void)
+{
+  upc_tick_t start, stop, elapsed;
+  uint64_t ref_start_ns, ref_stop_ns, ref_elapsed_ns;
+  uint64_t elapsed_ns;
+  double elapsed_sec, total_elapsed_sec;
+  double ref_elapsed_sec, ref_pct_err;
+  upc_barrier;
+  ref_start_ns = ref_get_ns();
+  total_elapsed_sec = 0.0;
+  for (int n = 0; n < 100; ++n)
+    {
+      start = upc_ticks_now ();
+      /* Sleep 0.01 seconds */
+      usleep (10000L);
+      stop = upc_ticks_now ();
+      elapsed = (stop - start);
+      elapsed_ns = upc_ticks_to_ns (elapsed);
+      elapsed_sec = (double) elapsed_ns * 1.0e-9;
+      total_elapsed_sec += elapsed_sec;
+    }
+  ref_stop_ns = ref_get_ns();
+  ref_elapsed_ns = (ref_stop_ns - ref_start_ns);
+  ref_elapsed_sec = (double) ref_elapsed_ns * 1.0e-9;
+  ref_pct_err = 100.0 * (1.0 - total_elapsed_sec / ref_elapsed_sec);
+  if (ref_pct_err < 0.0)
+   ref_pct_err = -ref_pct_err;
+#ifdef DEBUG
+  printf ("elapsed: %0.5g ref: %0.5g error: %0.5g\n",
+          total_elapsed_sec, ref_elapsed_sec, ref_pct_err);
+#endif
+  if (ref_pct_err > 3.0)
+    {
+      fprintf (stderr, "upc_tick differs from reference by "
+               "more than 3%% on thread %d\n"
+	       "measured error is: %0.1f%%\n",
+	       MYTHREAD, ref_pct_err);
+      abort ();
+    }
+  upc_barrier;
+  if (!MYTHREAD)
+    printf ("test31: upc_tick wall clock timer library test - passed.\n");
+}
+
+int
+main ()
+{
+  test31 ();
+  return 0;
+}



More information about the Gcc-patches mailing list