#! /bin/sh -e

# svn-gdc-updates.dpatch by Arthur Loiret <arthur.loiret@gmail.com>
# DP: SVN updates from the gdc branch up to 20070831.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        #cd ${dir}gcc && autoconf
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        #rm ${dir}gcc/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0


diff -ruN gcc/d/ChangeLog gcc/d/ChangeLog
--- gcc/d/ChangeLog	2007-08-26 22:34:22.000000000 +0200
+++ gcc/d/ChangeLog	2007-09-02 19:33:43.000000000 +0200
@@ -1,3 +1,20 @@
+2007-08-31  David Friedman  <dvdfrdmn@users.sf.net>
+
+	* d-objfile.cc (outdata): Do not set TREE_CONSTANT on initializers
+	(Bugzilla 1453)
+
+2007-08-29  David Friedman  <dvdfrdmn@users.sf.net>
+
+	* d-decls.cc (uniqueName): Allow multiple static declaration with
+	the same name if in a function. (SF 1783085)
+
+2007-08-28  David Friedman  <dvdfrdmn@users.sf.net>
+
+	* d-codegen.cc (call): Use CommaExp correctly. (Bugzilla 1443)
+
+	* dmd/todt.c (createTsarrayDt): Don't take quadratic time to build
+	the initializer. (Bugzilla 1440)
+
 2007-08-22  David Friedman  <dvdfrdmn@users.sf.net>
 
 	Release GDC 0.24
diff -ruN gcc/d/d-codegen.cc gcc/d/d-codegen.cc
--- gcc/d/d-codegen.cc	2007-08-26 22:34:22.000000000 +0200
+++ gcc/d/d-codegen.cc	2007-09-02 19:33:43.000000000 +0200
@@ -780,10 +780,12 @@
     if (expr->op == TOKcomma)
     {
 	CommaExp * ce = (CommaExp *) expr;
+	expr = ce->e2;
+	
 	VarExp * ve;
-	expr = ce->e1;
-	gcc_assert( ce->e2->op == TOKvar &&
-	    ((VarExp *) ce->e2)->var->isFuncDeclaration() );
+	gcc_assert( ce->e2->op == TOKvar );
+	ve = (VarExp *) ce->e2;
+	gcc_assert(ve->var->isFuncDeclaration() && ! ve->var->needThis());
     }
     
     Type* t = expr->type->toBasetype();
diff -ruN gcc/d/d-decls.cc gcc/d/d-decls.cc
--- gcc/d/d-decls.cc	2007-08-26 22:34:22.000000000 +0200
+++ gcc/d/d-decls.cc	2007-09-02 19:33:43.000000000 +0200
@@ -137,10 +137,17 @@
     FuncDeclaration * f = d->isFuncDeclaration();
     VarDeclaration * v = d->isVarDeclaration();
 
-    if (d->protection == PROTprivate &&
-	!(f && ! f->fbody) &&
+    /* Check cases for which it is okay to have a duplicate symbol name.
+       Otherwise, duplicate names are an error and the condition will
+       be caught by the assembler. */
+    if (!(f && ! f->fbody) &&
 	!(v && (v->storage_class & STCextern)) &&
-	(!p || p->isModule()))
+	(
+	 // Static declarations in different scope statements
+	 (p && p->isFuncDeclaration()) ||
+
+	 // Top-level duplicate names are okay if private.
+	 ((!p || p->isModule()) && d->protection == PROTprivate) ))
     {
 	StringValue * sv;
 
diff -ruN gcc/d/dmd/todt.c gcc/d/dmd/todt.c
--- gcc/d/dmd/todt.c	2007-08-26 22:34:22.000000000 +0200
+++ gcc/d/dmd/todt.c	2007-09-02 19:33:43.000000000 +0200
@@ -73,17 +73,18 @@
 
 	target_size_t dim = tsa->dim->toInteger();
 	dt_t * adt = NULL;
+	dt_t ** padt = & adt;
 	
 	if (eoa_size * dim == eoa_size)
 	{
 	    for (target_size_t i = 0; i < dim; i++)
-		dtcontainer(& adt, NULL, elem_or_all);
+		padt = dtcontainer(padt, NULL, elem_or_all);
 	}
 	else
 	{
 	    assert(tsa->size(0) % eoa_size == 0);
 	    for (target_size_t i = 0; i < dim; i++)
-		dtcontainer(& adt, NULL,
+		padt = dtcontainer(padt, NULL,
 		    createTsarrayDt(elem_or_all, tsa->next));
 	}
 	dt_t * fdt = NULL;
diff -ruN gcc/d/d-objfile.cc gcc/d/d-objfile.cc
--- gcc/d/d-objfile.cc	2007-08-26 22:34:22.000000000 +0200
+++ gcc/d/d-objfile.cc	2007-09-02 19:33:43.000000000 +0200
@@ -954,11 +954,8 @@
 
     assert( t );
 
-    if (sym->Sdt && DECL_INITIAL( t ) == NULL_TREE) {
-	tree ini = dt2tree( sym->Sdt );
-	TREE_CONSTANT( ini ) = TREE_CONSTANT( t );
-	DECL_INITIAL( t ) = ini;
-    }
+    if (sym->Sdt && DECL_INITIAL( t ) == NULL_TREE)
+	DECL_INITIAL( t ) = dt2tree( sym->Sdt );
 
     if (! g.ofile->shouldEmit(sym))
 	return;
