Re: [Patch, Fortran] PR51816 - fix USE of intrinsic operators

2012-01-14 Thread Paul Richard Thomas
Dear Tobias,

 This patch fixes two issues related to intrinsic operators:

 a) No error for nonexisting operators:
USE m, operator(*)


 b) An bogus error if one tried to use-associate the same operator multiple 
 times:
 USE m, operator(+), operator(+)

 Those are old issues. New issue (and thus the PR is marked as regression) is 
 that the bogus error now also is printed for:
 USE m, operator(+)
 USE m, operator(+)

 Build and regtested on x86-64-linux.
 OK for trunk?

This was quite useful for me - I had got quite behind with development
of module.c; even the documentation on the wiki is badly out of date.
I will update this, as soon as I have a spare moment. :-)

This is OK for trunk.

Thanks for the patch!

Paul


Re: [Patch, Fortran] PR 51800 - Fix -finit-local-zero with automatic arrays and -fno-automatic

2012-01-14 Thread Paul Richard Thomas
Dear Tobias,


 Build and regtested on x86-64-linux.
 OK for the trunk?

That's OK for trunk - thanks!

Paul


Re: [C++ Patch] PR 51225

2012-01-14 Thread Paolo Carlini

Hi,

On 01/13/2012 03:57 PM, Paolo Carlini wrote:

Anyway, the reason we are not tsubst-ing such trees - eg, a CAST_EXPR on
a single element TREE_LIST as argument, with error_mark_node as value -
is that potential_constant_expression is false in
fold_non_dependent_expr_sfinae, thus tsubst_copy_and_build is not called
at all.


We also shouldn't call cxx_eval_constant_expression if 
potential_constant_expression is false.
Ok. At this point I'm not sure anymore whether this mild error recovery 
issue is worth more of your (and my ;) time, but anyway, I tell you what 
I did in the meanwhile.


This kind of change:

Index: pt.c
===
--- pt.c(revision 183178)
+++ pt.c(working copy)
@@ -5807,6 +5807,8 @@ convert_nontype_argument (tree type, tree expr, ts
  if (complain  tf_error)
{
  int errs = errorcount, warns = warningcount;
+ if (!require_potential_constant_expression (expr))
+   return NULL_TREE;
  expr = cxx_constant_value (expr);
  if (errorcount  errs || warningcount  warns)
inform (EXPR_LOC_OR_HERE (expr),

fixes the problem with the first snippet in PR51225, which has strictly 
to do with nontype template parameters.


But then we have the second kind of snippet, which is about the 
cxx_constant_value call part of store_init_value. In this case trying to 
avoid calling cxx_constant_value when there are no chances the value is 
constant causes regressions, because normally we produce a lot of 
diagnostics as part of cxx_eval_constant_expression which we don't 
produce anymore: for example, for constexpr-diag1.C, the diagnostics 
produced by cxx_eval_call_expression disappears. Thus, I'm not sure we 
could do. I don't think we can now attempt to either take diagnostics 
out of cxx_eval_constant_expression or beef up the diagnostics in 
potential_constant_expression?!? Maybe we should somehow figure out 
whether in the expression there are error_mark_node embedded and only in 
that conservative case completely avoid calling 
cxx_eval_constant_expression, but at present 
potential_constant_expression just returns false in that case doesn't 
tell it apart from the other cases of non-potential.


Thanks,
Paolo.


[v3] doxygen comments for reverse_iterator

2012-01-14 Thread Jonathan Wakely
2012-01-14  Jonathan Wakely  jwakely@gmail.com

* include/bits/stl_iterator.h (reverse_iterator): Doxygen comments.

Tested x86_64-linux, committed to trunk.
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1,7 +1,7 @@
 // Iterators -*- C++ -*-
 
 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-// 2010, 2011
+// 2010, 2011, 2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -114,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef typename __traits_type::referencereference;
 
   /**
-   *  The default constructor default-initializes member @p current.
+   *  The default constructor value-initializes member @p current.
*  If it is a pointer, that means it is zero-initialized.
   */
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
@@ -134,8 +134,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   : current(__x.current) { }
 
   /**
-   *  A reverse_iterator across other types can be copied in the normal
-   *  fashion.
+   *  A %reverse_iterator across other types can be copied if the
+   *  underlying %iterator can be converted to the type of @c current.
   */
   templatetypename _Iter
 reverse_iterator(const reverse_iterator_Iter __x)
@@ -149,9 +149,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return current; }
 
   /**
-   *  @return  TODO
+   *  @return  A reference to the value at @c --current
*
-   *  @doctodo
+   *  This requires that @c --current is dereferenceable.
+   *
+   *  @warning This implementation requires that for an iterator of the
+   *   underlying iterator type, @c x, a reference obtained by
+   *   @c *x remains valid after @c x has been modified or
+   *   destroyed. This is a bug: http://gcc.gnu.org/PR51823
   */
   reference
   operator*() const
@@ -161,18 +166,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  A pointer to the value at @c --current
*
-   *  @doctodo
+   *  This requires that @c --current is dereferenceable.
   */
   pointer
   operator-() const
   { return (operator*()); }
 
   /**
-   *  @return  TODO
+   *  @return  @c *this
*
-   *  @doctodo
+   *  Decrements the underlying iterator.
   */
   reverse_iterator
   operator++()
@@ -182,9 +187,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  The original value of @c *this
*
-   *  @doctodo
+   *  Decrements the underlying iterator.
   */
   reverse_iterator
   operator++(int)
@@ -195,9 +200,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  @c *this
*
-   *  @doctodo
+   *  Increments the underlying iterator.
   */
   reverse_iterator
   operator--()
@@ -207,9 +212,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  A reverse_iterator with the previous value of @c *this
*
-   *  @doctodo
+   *  Increments the underlying iterator.
   */
   reverse_iterator
   operator--(int)
@@ -220,18 +225,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  A reverse_iterator that refers to @c current - @a __n
*
-   *  @doctodo
+   *  The underlying iterator must be a Random Access Iterator.
   */
   reverse_iterator
   operator+(difference_type __n) const
   { return reverse_iterator(current - __n); }
 
   /**
-   *  @return  TODO
+   *  @return  *this
*
-   *  @doctodo
+   *  Moves the underlying iterator backwards @a __n steps.
+   *  The underlying iterator must be a Random Access Iterator.
   */
   reverse_iterator
   operator+=(difference_type __n)
@@ -241,18 +247,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  A reverse_iterator that refers to @c current - @a __n
*
-   *  @doctodo
+   *  The underlying iterator must be a Random Access Iterator.
   */
   reverse_iterator
   operator-(difference_type __n) const
   { return reverse_iterator(current + __n); }
 
   /**
-   *  @return  TODO
+   *  @return  *this
*
-   *  @doctodo
+   *  Moves the underlying iterator forwards @a __n steps.
+   *  The underlying iterator must be a Random Access Iterator.
   */
   reverse_iterator
   operator-=(difference_type __n)
@@ -262,9 +269,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-   *  @return  TODO
+   *  @return  The value at @c current - @a __n - 1
*
-   *  @doctodo
+   

Re: [PATCH, AVR] Fix PR target/50925, use hard_frame_pointer_rtx

2012-01-14 Thread Denis Chertykov
2012/1/14 Denis Chertykov cherty...@gmail.com:
 2012/1/13 Georg-Johann Lay a...@gjlay.de:
 Denis Chertykov wrote:

 Committed

 Denis


 Consider code prom PR51374

 void __vector_18 (void)
 {
    extern char slot;
    unsigned char status = (*(volatile unsigned char*) 0x2B);
    unsigned char data = (*(volatile unsigned char*) 0x2C);

    if (status  0x10)
        slot = 0;
 }

 the code with -Os -S -dp sets up a frame pointer which is not needed and 
 should
 not be there:

 __vector_18:
        push r28         ;  28  pushqi1/1       [length = 1]
        push r29         ;  29  pushqi1/1       [length = 1]
        in r28,__SP_L__  ;  30  *movhi/8        [length = 2]
        in r29,__SP_H__
 /* prologue: function */
 /* frame size = 0 */
 /* stack size = 2 */
 .L__stack_usage = 2
        in r24,0xc       ;  8   movqi_insn/4    [length = 1]
        sbis 0xb,4       ;  11  *sbix_branch    [length = 2]
        rjmp .L1
        sts slot,__zero_reg__    ;  13  movqi_insn/3    [length = 2]
 .L1:
 /* epilogue start */
        pop r29  ;  33  popqi   [length = 1]
        pop r28  ;  34  popqi   [length = 1]
        ret      ;  35  return_from_epilogue    [length = 1]

 This happens even for empty function.

 Oops.
 Something wrong happened, probably I committed a wrong untested patch.
 It must be reverted.

Commit reverted.

Denis.


[PATCH] libada: fix multilib bug

2012-01-14 Thread Andreas Schwab
s-oscons-tmplt.i must be compiled with the right MULTIFLAGS.  Tested on
powerpc-linux.

Andreas.

2012-01-14  Andreas Schwab sch...@linux-m68k.org

* gcc-interface/Makefile.in (OSCONS_EXTRACT): Add $(GNATLIBCFLAGS).

diff --git a/gcc/ada/gcc-interface/Makefile.in 
b/gcc/ada/gcc-interface/Makefile.in
index 6a7da6c..520e618 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -1,5 +1,5 @@
 # Makefile for GNU Ada Compiler (GNAT).
-#   Copyright (C) 1994-2011 Free Software Foundation, Inc.
+#   Copyright (C) 1994-2012 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -2575,7 +2575,7 @@ OSCONS_CC=`echo $(GCC_FOR_TARGET) \
   | sed -e 's^\./xgcc^../../xgcc^' -e 's^-B./^-B../../^'`
 OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS) -E -C \
   -DTARGET=\$(target)\ $(fsrcpfx)ada/s-oscons-tmplt.c  s-oscons-tmplt.i
-OSCONS_EXTRACT=$(OSCONS_CC) -S s-oscons-tmplt.i
+OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS) -S s-oscons-tmplt.i
 endif
 
 ./bldtools/oscons/xoscons: xoscons.adb xutil.ads xutil.adb
-- 
1.7.8.3

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


[PATCH] Fix g++.dg/cpp0x/constexpr-rom.C failure

2012-01-14 Thread Andreas Schwab
Fix spurious failure by disabling use of sdata.  Tested on
powerpc-linux.

Andreas.

2012-01-14  Andreas Schwab sch...@linux-m68k.org

* g++.dg/cpp0x/constexpr-rom.C: Add -G0 where applicable.

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
index aa9ff5d..5853ea1 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
@@ -1,5 +1,6 @@
 // PR c++/49673: check that test_data goes into .rodata
 // { dg-options -std=c++0x }
+// { dg-options -std=c++0x -G0 { target alpha*-*-* frv*-*-* ia64-*-* 
lm32*-*-* m32r*-*-* microblaze*-*-* mips*-*-* powerpc*-*-* rs6000*-*-* 
score*-*-* } }
 // { dg-final { scan-assembler \\.rdata { target mips*-*-* } } }
 // { dg-final { scan-assembler rodata { target { { *-*-linux-gnu || *-*-elf 
}  { ! mips*-*-* } } } } }
 
-- 
1.7.8.3

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


Re: [PATCH] Fix g++.dg/cpp0x/constexpr-rom.C failure

2012-01-14 Thread Jakub Jelinek
On Sat, Jan 14, 2012 at 08:57:00PM +0100, Andreas Schwab wrote:
 Fix spurious failure by disabling use of sdata.  Tested on
 powerpc-linux.

Please use dg-additional-options instead.

 2012-01-14  Andreas Schwab sch...@linux-m68k.org
 
   * g++.dg/cpp0x/constexpr-rom.C: Add -G0 where applicable.
 
 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C 
 b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
 index aa9ff5d..5853ea1 100644
 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
 +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
 @@ -1,5 +1,6 @@
  // PR c++/49673: check that test_data goes into .rodata
  // { dg-options -std=c++0x }
 +// { dg-options -std=c++0x -G0 { target alpha*-*-* frv*-*-* ia64-*-* 
 lm32*-*-* m32r*-*-* microblaze*-*-* mips*-*-* powerpc*-*-* rs6000*-*-* 
 score*-*-* } }
  // { dg-final { scan-assembler \\.rdata { target mips*-*-* } } }
  // { dg-final { scan-assembler rodata { target { { *-*-linux-gnu || 
 *-*-elf }  { ! mips*-*-* } } } } }

Jakub


Re: [PATCH] Fix g++.dg/cpp0x/constexpr-rom.C failure

2012-01-14 Thread Andreas Schwab
Thanks, I hadn't discovered this yet.

Andreas.

2012-01-14  Andreas Schwab sch...@linux-m68k.org

* g++.dg/cpp0x/constexpr-rom.C: Add -G0 where applicable.

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
index aa9ff5d..636f0e7 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
@@ -1,5 +1,6 @@
 // PR c++/49673: check that test_data goes into .rodata
 // { dg-options -std=c++0x }
+// { dg-additional-options -G0 { target alpha*-*-* frv*-*-* ia64-*-* lm32*-*-* 
m32r*-*-* microblaze*-*-* mips*-*-* powerpc*-*-* rs6000*-*-* score*-*-* } }
 // { dg-final { scan-assembler \\.rdata { target mips*-*-* } } }
 // { dg-final { scan-assembler rodata { target { { *-*-linux-gnu || *-*-elf 
}  { ! mips*-*-* } } } } }
 
-- 
1.7.8.3


-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


Re: [PATCH] libada: fix multilib bug

2012-01-14 Thread Arnaud Charlet
 s-oscons-tmplt.i must be compiled with the right MULTIFLAGS.  Tested on
 powerpc-linux.
 
 Andreas.
 
 2012-01-14  Andreas Schwab sch...@linux-m68k.org
 
   * gcc-interface/Makefile.in (OSCONS_EXTRACT): Add $(GNATLIBCFLAGS).

OK

 diff --git a/gcc/ada/gcc-interface/Makefile.in
 b/gcc/ada/gcc-interface/Makefile.in
 index 6a7da6c..520e618 100644
 --- a/gcc/ada/gcc-interface/Makefile.in
 +++ b/gcc/ada/gcc-interface/Makefile.in
 @@ -1,5 +1,5 @@
  # Makefile for GNU Ada Compiler (GNAT).
 -#   Copyright (C) 1994-2011 Free Software Foundation, Inc.
 +#   Copyright (C) 1994-2012 Free Software Foundation, Inc.
  
  #This file is part of GCC.
  
 @@ -2575,7 +2575,7 @@ OSCONS_CC=`echo $(GCC_FOR_TARGET) \
| sed -e 's^\./xgcc^../../xgcc^' -e 's^-B./^-B../../^'`
  OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS) -E -C \
-DTARGET=\$(target)\ $(fsrcpfx)ada/s-oscons-tmplt.c 
s-oscons-tmplt.i
 -OSCONS_EXTRACT=$(OSCONS_CC) -S s-oscons-tmplt.i
 +OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS) -S s-oscons-tmplt.i
  endif
  
  ./bldtools/oscons/xoscons: xoscons.adb xutil.ads xutil.adb


[PATCH] libffi fixes for m68k

2012-01-14 Thread Andreas Schwab
The only way to detect compiling for a plain 68000 is the absense of
other defines since __mc68000__ is always defined.  Also, gcc defines
__HAVE_68881__, not __MC68881__.  The latter fixes failures of all tests
involving floating point return values.  Tested on m68k-linux.

Andreas.

2012-01-14  Andreas Schwab sch...@linux-m68k.org

* src/m68k/sysv.S (ffi_call_SYSV): Properly test for plain
mc68000.  Test for __HAVE_68881__ in addition to __MC68881__.

---
 libffi/src/m68k/sysv.S |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libffi/src/m68k/sysv.S b/libffi/src/m68k/sysv.S
index c782f51..dfdd864 100644
--- a/libffi/src/m68k/sysv.S
+++ b/libffi/src/m68k/sysv.S
@@ -1,6 +1,6 @@
 /* ---

-   sysv.S - Copyright (c) 1998 Andreas Schwab
+   sysv.S - Copyright (c) 1998, 2012 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc. 

m68k Foreign Function Interface 
@@ -87,7 +87,7 @@ ffi_call_SYSV:
 
| If the return value pointer is NULL, assume no return value.
| NOTE: On the mc68000, tst on an address register is not supported.
-#if defined(__mc68000__)  !defined(__mcoldfire__)
+#if !defined(__mc68020__)  !defined(__mc68030__)  !defined(__mc68040__)  
!defined(__mc68060__)  !defined(__mcoldfire__)
cmp.w   #0, %a1
 #else
tst.l   %a1
@@ -109,7 +109,7 @@ retlongint:
 retfloat:
btst#2,%d2
jbeqretdouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s %fp0,(%a1)
 #else
move.l  %d0,(%a1)
@@ -119,7 +119,7 @@ retfloat:
 retdouble:
btst#3,%d2
jbeqretlongdouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d %fp0,(%a1)
 #else
move.l  %d0,(%a1)+
@@ -130,7 +130,7 @@ retdouble:
 retlongdouble:
btst#4,%d2
jbeqretpointer
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x %fp0,(%a1)
 #else
move.l  %d0,(%a1)+
@@ -199,7 +199,7 @@ ffi_closure_SYSV:
move.l  (%a0),%d1
jra .Lcls_epilogue
 .Lcls_ret_float:
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s (%a0),%fp0
 #else
move.l  (%a0),%d0
@@ -209,7 +209,7 @@ ffi_closure_SYSV:
lsr.l   #2,%d0
jne 1f
jcs .Lcls_ret_ldouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d (%a0),%fp0
 #else
move.l  (%a0)+,%d0
@@ -217,7 +217,7 @@ ffi_closure_SYSV:
 #endif
jra .Lcls_epilogue
 .Lcls_ret_ldouble:
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x (%a0),%fp0
 #else
move.l  (%a0)+,%d0
-- 
1.7.8.3


-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


[Patch, fortran] Fix temporary allocation for class assignment.

2012-01-14 Thread Paul Richard Thomas
Dear All,

As previously advertised, the attached patch fixes the problem with
using an index array in the final assignment in subroutine qsort in
class_array_3.f03.  The failure occurred because the temporary array
was assigned zero size, since the declared type is abstract.  More
generally, even if the temporary is not zero size, the dynamic type
will always be larger than the declared type.

I have used what might appear to be a rather ad-hoc mechanism; set the
element type to null in the call to gfc_trans_create_temp_array and
pass the class reference indirectly through 'initial'.  Since, for
this application, we always want the initial value to be that of the
left hand side of the assignment, all is well. I have reviewed all the
other users of gfc_trans_create_temp_array and cannot see any issues
at present.  When F2008 intrinsic assignment of classes is introduced,
some care will have to be taken in gfc_trans_assignment_1, between the
call to  gfc_conv_resolve_dependencies and that to
gfc_conv_loop_setup, to ensure that the temporary, if it exists, is
initialized correctly.  Thus, all in all, I do not think that it is in
fact ad-hoc and is rather easily extended to future needs.

Please reassure me that class array constructors do not, cannot and
will never occur!  :-)

When TRANSFER is implemented for class objects, there will likely be a
similar issue with gfc_trans_create_temp_array.

Bootstrapped and regtested on Fc9/x86_64 - OK for trunk?

Cheers

Paul

2012-01-14  Paul Thomas  pa...@gcc.gnu.org

* trans-array.c (gfc_trans_create_temp_array): In the case of a
class array temporary, detect a null 'eltype' on entry and use
'initial' to provde the class reference and so, through the
vtable, the element size for the dynamic type.
* trans-stmt.c (gfc_conv_elemental_dependencies): For class
expressions, set 'eltype' to null and pass the values via the
'initial' expression.

2012-01-14  Paul Thomas  pa...@gcc.gnu.org

* gfortran.dg/class_array_3.f03: Remove the explicit loop in
subroutine 'qsort' and use index array to assign the result.
Index: gcc/fortran/trans-array.c
===
*** gcc/fortran/trans-array.c	(revision 183162)
--- gcc/fortran/trans-array.c	(working copy)
*** gfc_trans_create_temp_array (stmtblock_t
*** 990,998 
--- 990,1012 
tree nelem;
tree cond;
tree or_expr;
+   tree class_expr = NULL_TREE;
int n, dim, tmp_dim;
int total_dim = 0;
  
+   /* This signals a class array for which we need the size of the
+  dynamic type.  Generate an eltype and then the class expression.  */
+   if (eltype == NULL_TREE  initial)
+ {
+   if (POINTER_TYPE_P (TREE_TYPE (initial)))
+ 	class_expr = build_fold_indirect_ref_loc (input_location, initial);
+   eltype = TREE_TYPE (class_expr);
+   eltype = gfc_get_element_type (eltype);
+   /* Obtain the structure (class) expression.  */
+   class_expr = TREE_OPERAND (class_expr, 0);
+   gcc_assert (class_expr);
+ }
+ 
memset (from, 0, sizeof (from));
memset (to, 0, sizeof (to));
  
*** gfc_trans_create_temp_array (stmtblock_t
*** 1133,1148 
/* Get the size of the array.  */
if (size  !callee_alloc)
  {
/* If or_expr is true, then the extent in at least one
  	 dimension is zero and the size is set to zero.  */
size = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
  			  or_expr, gfc_index_zero_node, size);
  
nelem = size;
size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
! 		size,
! 		fold_convert (gfc_array_index_type,
! 			  TYPE_SIZE_UNIT (gfc_get_element_type (type;
  }
else
  {
--- 1147,1167 
/* Get the size of the array.  */
if (size  !callee_alloc)
  {
+   tree elemsize;
/* If or_expr is true, then the extent in at least one
  	 dimension is zero and the size is set to zero.  */
size = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
  			  or_expr, gfc_index_zero_node, size);
  
nelem = size;
+   if (class_expr == NULL_TREE)
+ 	elemsize = fold_convert (gfc_array_index_type,
+ 			TYPE_SIZE_UNIT (gfc_get_element_type (type)));
+   else
+ 	elemsize = gfc_vtable_size_get (class_expr);
+ 
size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
! 			  size, elemsize);
  }
else
  {
Index: gcc/fortran/trans-stmt.c
===
*** gcc/fortran/trans-stmt.c	(revision 183161)
--- gcc/fortran/trans-stmt.c	(working copy)
*** gfc_conv_elemental_dependencies (gfc_se 
*** 282,300 
  		|| (fsym-ts.type ==BT_DERIVED
  		   fsym-attr.intent == INTENT_OUT))
  	initial = parmse.expr;
  	  else
  	initial = NULL_TREE;
  
! 	  /* Find the type