[PATCH][libstdc++-v3 parallel mode] Avoid taking address of dereferenced random access iterator

2011-03-10 Thread Johannes Singler
The attached patch patch solves a conformance problem of the parallel 
mode helper routine multiseq_partition.  I have added a test case for 
that.  multiseq_selection has similar problems, but is unused, so I plan 
to remove that completely (which might ask for renaming of the file and 
the test).


Should I use unique_ptr (or alloca, or something similar) here for a 
better exception safety (this routine is not parallel itself)?
Is it the appropriate place for the "unit test"?  It is used in the 
parallel sort.


Tested x86_64-unknown-linux-gnu: No regressions


2011-03-10  Johannes Singler  

* include/parallel/multiseq_selection.h (multiseq_partition):
Copy-construct _ValueType element on demand on heap, do not
take address of dereferenced random access iterator.
Remove unused code that has the same problem.
* testsuite/25_algorithms/sort/multiseq_selection.cc:
New unit test for multiseq_partition.

Johannes

Index: include/parallel/multiseq_selection.h
===
--- include/parallel/multiseq_selection.h	(revision 170753)
+++ include/parallel/multiseq_selection.h	(working copy)
@@ -229,15 +229,15 @@
 {
   __n /= 2;
 
-  _SeqNumber __lmax_seq = -1;  // to avoid warning
-  const _ValueType* __lmax = 0; // impossible to avoid the warning?
+  _SeqNumber __lmax_seq = -1;  // initialize to avoid warning
+  _ValueType* __lmax = 0;
   for (_SeqNumber __i = 0; __i < __m; __i++)
 {
   if (__a[__i] > 0)
 {
   if (!__lmax)
 {
-  __lmax = &(__S(__i)[__a[__i] - 1]);
+  __lmax = new _ValueType(__S(__i)[__a[__i] - 1]);
   __lmax_seq = __i;
 }
   else
@@ -245,7 +245,7 @@
   // Max, favor rear sequences.
   if (!__comp(__S(__i)[__a[__i] - 1], *__lmax))
 {
-  __lmax = &(__S(__i)[__a[__i] - 1]);
+  *__lmax = __S(__i)[__a[__i] - 1];
   __lmax_seq = __i;
 }
 }
@@ -321,45 +321,13 @@
 __S(__source)[__a[__source] - 1], __source));
 }
 }
+  delete __lmax;
 }
 
   // Postconditions:
   // __a[__i] == __b[__i] in most cases, except when __a[__i] has been
   // clamped because of having reached the boundary
 
-  // Now return the result, calculate the offset.
-
-  // Compare the keys on both edges of the border.
-
-  // Maximum of left edge, minimum of right edge.
-  _ValueType* __maxleft = 0;
-  _ValueType* __minright = 0;
-  for (_SeqNumber __i = 0; __i < __m; __i++)
-{
-  if (__a[__i] > 0)
-{
-  if (!__maxleft)
-__maxleft = &(__S(__i)[__a[__i] - 1]);
-  else
-{
-  // Max, favor rear sequences.
-  if (!__comp(__S(__i)[__a[__i] - 1], *__maxleft))
-__maxleft = &(__S(__i)[__a[__i] - 1]);
-}
-}
-  if (__b[__i] < __ns[__i])
-{
-  if (!__minright)
-__minright = &(__S(__i)[__b[__i]]);
-  else
-{
-  // Min, favor fore sequences.
-  if (__comp(__S(__i)[__b[__i]], *__minright))
-__minright = &(__S(__i)[__b[__i]]);
-}
-}
-}
-
   _SeqNumber __seq = 0;
   for (_SeqNumber __i = 0; __i < __m; __i++)
 __begin_offsets[__i] = __S(__i) + __a[__i];
Index: testsuite/25_algorithms/sort/multiseq_selection.cc
===
--- testsuite/25_algorithms/sort/multiseq_selection.cc	(revision 0)
+++ testsuite/25_algorithms/sort/multiseq_selection.cc	(revision 0)
@@ -0,0 +1,116 @@
+// { dg-require-parallel-mode "" }
+// { dg-options "-fopenmp" { target *-*-* } }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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 library 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 library; see the file COPYING3.  If not see
+// .
+
+#include 
+
+#include 
+
+bool test _

Re: 4.5 backport request...

2011-03-10 Thread Richard Guenther
On Wed, Mar 9, 2011 at 11:05 PM, DJ Delorie  wrote:
>
> May I backport this change to 4.5 ?  rx-elf can use this for a
> performance boost (a separate 4.5 target patch would be needed for
> that)

This doesn't look like a regression fix.  The changelog doesn't tell
if it is mere replacing macros by hooks, so please also attach the
patch.

Richard.

> 2010-10-19  DJ Delorie  
>
>        * doc/tm.texi.in (TARGET_ASM_JUMP_ALIGN_MAX_SKIP): New.
>        (TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Change to hook.
>        (TARGET_ASM_LOOP_ALIGN_MAX_SKIP): Likewise.
>        (TARGET_ASM_LABEL_ALIGN_MAX_SKIP): Likewise.
>        * doc/tm.texi: Regenerate.
>        * targhooks.h (default_label_align_after_barrier_max_skip,
>        default_loop_align_max_skip, default_label_align_max_skip,
>        default_jump_align_max_skip): Declare.
>        * target.def (label_align_after_barrier_max_skip): New.
>        (loop_align_max_skip): New.
>        (label_align_max_skip): New.
>        (jump_align_max_skip): New.
>        * system.h (poison): Add those macros to the list.
>        * final.c (LABEL_ALIGN_MAX_SKIP): Remove.
>        (LOOP_ALIGN_MAX_SKIP): Remove.
>        (LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Remove.
>        (JUMP_ALIGN_MAX_SKIP): Remove.
>        (default_label_align_after_barrier_max_skip): New.
>        (default_loop_align_max_skip): New.
>        (default_label_align_max_skip): New.
>        (default_jump_align_max_skip): New.
>        (compute_alignments): Use the new hooks.
>        (shorten_branches): Likewise.
>


Re: RFA (layout): PATCH for c++/48029 (ICE-on-valid with templates and arrays)

2011-03-10 Thread Richard Guenther
On Thu, Mar 10, 2011 at 3:59 AM, Jason Merrill  wrote:
> In this testcase, when we first declare the myvectypes and mytype3,
> vector has not been instantiated, so we mark the array, and the
> pointer to the array, for structural equality comparison.  When we actually
> go to instantiate mytype3, we complete vector and rebuild the array
> and pointer types, and use those to look up the template specialization.
>  Which fails to find the one we already had because the new pointer type has
> TYPE_CANONICAL and therefore hashes
> differently from the one that didn't.
>
> We deal with ARRAY_TYPE specially in iterative_hash_template_arg, but that
> doesn't cover a compound type which uses an ARRAY_TYPE, such as the pointer
> in this case.
>
> The business of having an array with the same element type and domain have
> different TYPE_CANONICAL dependending on whether or not the element type is
> complete has always seemed strange and fragile to me, so I tried removing
> the relevant code from layout_type; this produced only a single test
> failure, which was fixed by changing type_hash_eq to not trust TYPE_ALIGN if
> the type isn't complete yet.  I imagine that's what Doug was talking about
> in his comment about alignment.

Ugh.  Why do we call layout_type on arrays with incomplete element type
at all?  I suppose the array type is still considered un-layouted after
that finished (NULL TYPE_SIZE)?  So, what does layout_type provide
that the C++ FE relies on when layouting this kind of type?

Other than the above questions the patch looks ok if indeed layout_type
returns with a NULL TYPE_SIZE.

Thanks,
Richard.

> Tested (c,c++,fortran,java,lto,objc) x86_64-pc-linux-gnu.  OK for 4.5 and
> 4.6?
>
> commit 45deb1cd5953c5730e14e00c5a8f800dadea66bd
> Author: Jason Merrill 
> Date:   Wed Mar 9 16:47:10 2011 -0500
>
>        PR c++/48029
>        * stor-layout.c (layout_type): Don't set structural equality
>        on arrays of incomplete type.
>        * tree.c (type_hash_eq): Handle comparing them properly.
>        * cp/pt.c (iterative_hash_template_arg): Remove special case for
>        ARRAY_TYPE.
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index ac91698..ab2aea3 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -1569,13 +1569,6 @@ iterative_hash_template_arg (tree arg, hashval_t val)
>       val = iterative_hash_object (code, val);
>       return iterative_hash_template_arg (TREE_OPERAND (arg, 2), val);
>
> -    case ARRAY_TYPE:
> -      /* layout_type sets structural equality for arrays of
> -        incomplete type, so we can't rely on the canonical type
> -        for hashing.  */
> -      val = iterative_hash_template_arg (TREE_TYPE (arg), val);
> -      return iterative_hash_template_arg (TYPE_DOMAIN (arg), val);
> -
>     case LAMBDA_EXPR:
>       /* A lambda can't appear in a template arg, but don't crash on
>         erroneous input.  */
> diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
> index 9056d7e..ed36c5b 100644
> --- a/gcc/stor-layout.c
> +++ b/gcc/stor-layout.c
> @@ -2028,11 +2028,6 @@ layout_type (tree type)
>  #else
>        TYPE_ALIGN (type) = MAX (TYPE_ALIGN (element), BITS_PER_UNIT);
>  #endif
> -       if (!TYPE_SIZE (element))
> -         /* We don't know the size of the underlying element type, so
> -            our alignment calculations will be wrong, forcing us to
> -            fall back on structural equality. */
> -         SET_TYPE_STRUCTURAL_EQUALITY (type);
>        TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (element);
>        SET_TYPE_MODE (type, BLKmode);
>        if (TYPE_SIZE (type) != 0
> diff --git a/gcc/tree.c b/gcc/tree.c
> index c947072..61532db 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -5981,12 +5981,18 @@ type_hash_eq (const void *va, const void *vb)
>       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
>       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
>                                 TYPE_ATTRIBUTES (b->type))
> -      || TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
> -      || TYPE_MODE (a->type) != TYPE_MODE (b->type)
>       || (TREE_CODE (a->type) != COMPLEX_TYPE
>           && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
>     return 0;
>
> +  /* Be careful about comparing arrays before and after the element type
> +     has been completed; don't compare TYPE_ALIGN unless both types are
> +     complete.  */
> +  if (TYPE_SIZE (a->type) && TYPE_SIZE (b->type)
> +      && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
> +         || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
> +    return 0;
> +
>   switch (TREE_CODE (a->type))
>     {
>     case VOID_TYPE:
>
>


Re: [PATCH][libstdc++-v3 parallel mode] Avoid taking address of dereferenced random access iterator

2011-03-10 Thread Jonathan Wakely
On 10 March 2011 09:47, Johannes Singler wrote:
> The attached patch patch solves a conformance problem of the parallel mode
> helper routine multiseq_partition.  I have added a test case for that.
>  multiseq_selection has similar problems, but is unused, so I plan to remove
> that completely (which might ask for renaming of the file and the test).

Please update the copyright date in the changed file as well.

> Should I use unique_ptr (or alloca, or something similar) here for a better
> exception safety (this routine is not parallel itself)?

unique_ptr is C++0x only, auto_ptr would work.  But I see other heap
allocation in that function are already unguarded so there doesn't
seem to be much point guarding one and not the others.  How about
defining a local RAII type (and combining the three allocations into
one) e.g.

  struct _Guard
  {
  _DifferenceType* _M_ns;

  ~_Guard() { delete[] _M_ns; }
  } __guard = { };

  __guard._M_ns = new _DifferenceType[__m*3];

  _DifferenceType* __ns = __guard._M_ns;
  _DifferenceType* __a = __guard._M_ns + __m;
  _DifferenceType* __b = __guard._M_ns + 2*__m;
  _DifferenceType __l;

That ensures the _Guard destructor will clean up on exiting the
function, so you can remove the delete statements.

and
std::auto_ptr<_ValueType> __lmax;
...
  __lmax.reset(new _ValueType(__S(__i)[__a[__i] - 1]));
etc.


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Rainer Orth
After considerable discussion in this thread

Unreviewed build, lto patch
http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00868.html

Richard's recommendation was to only use the lto-plugin with known-good
linkers supporting -plugin, i.e. GNU ld or gold >= 2.21.

I'm extracting the binutils version number from gold --version since
it's more familiar than the separate gold version number and provides a
higher resolution than the gold version number that only changes once
per binutils release.

Here's the reworked patch that implements this suggestion.  I couldn't
check with gold yet since it doesn't work on Solaris so far, but
i386-pc-solaris2.11 bootstraps with Sun ld and GNU ld 2.21 work as
expected, i.e. the failure described in PR lto/46944 is gone.

Ok for mainline?

Rainer


2011-02-05  Rainer Orth  

PR lto/46944
* configure.ac (gcc_cv_gld_major_version, gcc_cv_gld_minor):
Handle in-tree gold.
(ld_vers): Extract binutils version for gold.
(gcc_cv_ld_hidden): Handle gold here.
(gcc_cv_lto_plugin): Require gld or gold 2.21.
* configure: Regenerate.
* gcc.c [HAVE_LTO_PLUGIN] (PLUGIN_COND, PLUGIN_COND_CLOSE): Remove.
(LINK_PLUGIN_SPEC): Define.
Extract from LINK_COMMAND_SPEC, integrate PLUGIN_COND,
PLUGIN_COND_CLOSE.
[!HAVE_LTO_PLUGIN] (LINK_PLUGIN_SPEC): Define, reject
-fuse-linker-plugin.
(LINK_COMMAND_SPEC): Use it.

diff -r bbab4a602b6f gcc/configure.ac
--- a/gcc/configure.ac  Sat Feb 26 09:27:25 2011 +0100
+++ b/gcc/configure.ac  Sat Mar 05 09:36:08 2011 +0100
@@ -1967,7 +1967,8 @@
 esac 
 
 AC_MSG_CHECKING(what linker to use)
-if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
+if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \
+   || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then
# Single tree build which includes ld.  We want to prefer it
# over whatever linker top-level may have detected, since
# we'll use what we're building after installation anyway.
@@ -1978,6 +1979,8 @@
|| grep 'EMUL = .*linux' ../ld/Makefile \
|| grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then
  in_tree_ld_is_elf=yes
+   elif test "$ld_is_gold" = yes; then
+ in_tree_ld_is_elf=yes
fi
for f in $gcc_cv_ld_bfd_srcdir/configure 
$gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.in 
$gcc_cv_ld_gld_srcdir/Makefile.in
do
@@ -2192,11 +2195,23 @@
 changequote(,)dnl
 if test $in_tree_ld != yes ; then
   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
-  if test x"$ld_is_gold" = xyes; then
-gcc_cv_ld_hidden=yes
-  elif echo "$ld_ver" | grep GNU > /dev/null; then
-ld_vers=`echo $ld_ver | sed -n \
-   -e 's,^.*[   ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
+  if echo "$ld_ver" | grep GNU > /dev/null; then
+if test x"$ld_is_gold" = xyes; then
+  # GNU gold --version looks like this:
+  #
+  # GNU gold (GNU Binutils 2.21.51.20110225) 1.11
+  #
+  # We extract the binutils version which is more familiar and specific
+  # than the gold version.
+  ld_vers=`echo $ld_ver | sed -n \
+ -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)) .*$,\1,p'`
+else
+  # GNU ld --version looks like this:
+  #
+  # GNU ld (GNU Binutils) 2.21.51.20110225
+  ld_vers=`echo $ld_ver | sed -n \
+ -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
+fi
 ld_date=`echo $ld_ver | sed -n 
's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
@@ -2235,7 +2250,9 @@
   fi
 else
   gcc_cv_ld_hidden=yes
-  if echo "$ld_ver" | grep GNU > /dev/null; then
+  if test x"$ld_is_gold" = xyes; then
+:
+  elif echo "$ld_ver" | grep GNU > /dev/null; then
 if test 0"$ld_date" -lt 20020404; then
   if test -n "$ld_date"; then
# If there was date string, but was earlier than 2002-04-04, fail
@@ -3176,14 +3193,14 @@
 gcc_cv_lto_plugin=no
 if test -f liblto_plugin.la; then
   if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET=" = 
x"$gcc_cv_ld"; then
-if test x"$ld_is_gold" = xyes; then
-  gcc_cv_lto_plugin=yes
-elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" 
-ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then \
+if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" 
-ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then
   gcc_cv_lto_plugin=yes
 fi
-  # Check if the linker supports --plugin-opt option
-  elif $ORIGINAL_PLUGIN_LD_FOR_TARGET --help 2>/dev/null | grep plugin-opt > 
/dev/null; then
-gcc_cv_lto_plugin=yes
+  elif echo "$ld_ver" | grep GNU > /dev/null; then
+# Require GNU ld or gold 2.21 for plugin support.
+if test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -ge 21; then
+  gcc_cv_lto_plugin=

RX: Fixing latency timings for BSET and BLCR insns

2011-03-10 Thread Nick Clifton
Hi Guys,

  I am applying the attached patch to fix a typo in the timings of the
  BSET and BCLR instructions for the RX port.

Cheers
  Nick

gcc/ChangeLog
2011-03-10  Nick Clifton  

* config/rx/rx.md (bitset_in_memory, bitclr_in_memory: Fix timings.

Index: gcc/config/rx/rx.md
===
--- gcc/config/rx/rx.md (revision 170842)
+++ gcc/config/rx/rx.md (working copy)
@@ -1643,7 +1643,7 @@
   ""
   "bset\t%1, %0.B"
   [(set_attr "length" "3")
-   (set_attr "timings" "34")]
+   (set_attr "timings" "33")]
 )
 
 (define_insn "*bitinvert"
@@ -1689,7 +1689,7 @@
   ""
   "bclr\t%1, %0.B"
   [(set_attr "length" "3")
-   (set_attr "timings" "34")]
+   (set_attr "timings" "33")]
 )
 
 (define_insn "*insv_imm"


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Paolo Bonzini

On 03/10/2011 12:26 PM, Rainer Orth wrote:

+  # GNU gold (GNU Binutils 2.21.51.20110225) 1.11
+  #
+  # We extract the binutils version which is more familiar and specific
+  # than the gold version.
+  ld_vers=`echo $ld_ver | sed -n \
+ -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)) .*$,\1,p'`

 ^^ ^^

Perhaps changing these to [^)]* is better.  Build parts are okay with 
that change.


Patch


[PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Uros Bizjak
Hello!

Using binutils-2.21, a couple of
gcc.c-torture/execute/builtins/__-chk.c testcases fail on
alphaev68-pc-linux-gnu (-lto) with:

/usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
Warning: alignment 8 of symbol `buf5' in
/tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
/tmp/ccc3QsSw.o.ironly
/usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
Warning: alignment 8 of symbol `buf7' in
/tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
/tmp/ccc3QsSw.o.ironly
/usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
Warning: alignment 8 of symbol `buf1' in
/tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
/tmp/ccc3QsSw.o.ironly

Attached patch fixes these failures.

2011-03-10  Uros Bizjak  

PR testsuite/48055
* gcc.c-torture/execute/builtins/memcpy-chk.c (buf1, buf5, buf7):
Declare as static.
* gcc.c-torture/execute/builtins/mempcpy-chk.c (buf1, buf5, buf7):
Ditto.
* gcc.c-torture/execute/builtins/memmove-chk.c (buf1, buf5, buf7):
Ditto.

Tested on alphaev68-pc-linux-gnu with binutils-2.21. OK for mainline
and release branches?

Uros
Index: gcc.c-torture/execute/builtins/memcpy-chk.c
===
--- gcc.c-torture/execute/builtins/memcpy-chk.c (revision 170823)
+++ gcc.c-torture/execute/builtins/memcpy-chk.c (working copy)
@@ -78,10 +78,10 @@
 abort ();
 }
 
-long buf1[64];
+static long buf1[64];
 char *buf2 = (char *) (buf1 + 32);
-long buf5[20];
-char buf7[20];
+static long buf5[20];
+static char buf7[20];
 
 void
 __attribute__((noinline))
Index: gcc.c-torture/execute/builtins/memmove-chk.c
===
--- gcc.c-torture/execute/builtins/memmove-chk.c(revision 170823)
+++ gcc.c-torture/execute/builtins/memmove-chk.c(working copy)
@@ -81,10 +81,10 @@
 abort ();
 }
 
-long buf1[64];
+static long buf1[64];
 char *buf2 = (char *) (buf1 + 32);
-long buf5[20];
-char buf7[20];
+static long buf5[20];
+static char buf7[20];
 
 void
 __attribute__((noinline))
Index: gcc.c-torture/execute/builtins/mempcpy-chk.c
===
--- gcc.c-torture/execute/builtins/mempcpy-chk.c(revision 170823)
+++ gcc.c-torture/execute/builtins/mempcpy-chk.c(working copy)
@@ -84,10 +84,10 @@
   mempcpy_disallowed = 0;
 }
 
-long buf1[64];
+static long buf1[64];
 char *buf2 = (char *) (buf1 + 32);
-long buf5[20];
-char buf7[20];
+static long buf5[20];
+static char buf7[20];
 
 void
 __attribute__((noinline))


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Richard Guenther
On Thu, 10 Mar 2011, Rainer Orth wrote:

> After considerable discussion in this thread
> 
>   Unreviewed build, lto patch
> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00868.html
> 
> Richard's recommendation was to only use the lto-plugin with known-good
> linkers supporting -plugin, i.e. GNU ld or gold >= 2.21.
> 
> I'm extracting the binutils version number from gold --version since
> it's more familiar than the separate gold version number and provides a
> higher resolution than the gold version number that only changes once
> per binutils release.
> 
> Here's the reworked patch that implements this suggestion.  I couldn't
> check with gold yet since it doesn't work on Solaris so far, but
> i386-pc-solaris2.11 bootstraps with Sun ld and GNU ld 2.21 work as
> expected, i.e. the failure described in PR lto/46944 is gone.
> 
> Ok for mainline?

If I read this patch correctly then

 1) it doesn't change the condition under which lto-plugin/ is built
(good)

 2) it makes -fuse-linker-plugin the default for and only for
known good linkers (GNU binutils >= 2.21) (good)

 3) it makes it impossible to use -fuse-linker-plugin explicitly
for other linkers or linkers that were not installed during
configuring gcc (bad - esp. the latter)

can you please try avoiding 3) at this stage?  Or is the whole
point of this patch 3) to be able to fix PR46944?

Ideally we'd reject broken linkers at runtime, but that would
require some major collect2 massaging (eventually falling back
to collect2 or simply reporting an error).

That said, I'm not 100% happy with 3) at this point (though
2) is very desirable).

Can we to fix 46944 change the dejagnu require-linker-plugin
to check if a linker plugin is used by default and not add
-fuse-linker-plugin?

Thanks,
Richard.

>   Rainer
> 
> 
> 2011-02-05  Rainer Orth  
> 
>   PR lto/46944
>   * configure.ac (gcc_cv_gld_major_version, gcc_cv_gld_minor):
>   Handle in-tree gold.
>   (ld_vers): Extract binutils version for gold.
>   (gcc_cv_ld_hidden): Handle gold here.
>   (gcc_cv_lto_plugin): Require gld or gold 2.21.
>   * configure: Regenerate.
>   * gcc.c [HAVE_LTO_PLUGIN] (PLUGIN_COND, PLUGIN_COND_CLOSE): Remove.
>   (LINK_PLUGIN_SPEC): Define.
>   Extract from LINK_COMMAND_SPEC, integrate PLUGIN_COND,
>   PLUGIN_COND_CLOSE.
>   [!HAVE_LTO_PLUGIN] (LINK_PLUGIN_SPEC): Define, reject
>   -fuse-linker-plugin.
>   (LINK_COMMAND_SPEC): Use it.
> 
> diff -r bbab4a602b6f gcc/configure.ac
> --- a/gcc/configure.acSat Feb 26 09:27:25 2011 +0100
> +++ b/gcc/configure.acSat Mar 05 09:36:08 2011 +0100
> @@ -1967,7 +1967,8 @@
>  esac 
>  
>  AC_MSG_CHECKING(what linker to use)
> -if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
> +if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \
> +   || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then
>   # Single tree build which includes ld.  We want to prefer it
>   # over whatever linker top-level may have detected, since
>   # we'll use what we're building after installation anyway.
> @@ -1978,6 +1979,8 @@
>   || grep 'EMUL = .*linux' ../ld/Makefile \
>   || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then
> in_tree_ld_is_elf=yes
> + elif test "$ld_is_gold" = yes; then
> +   in_tree_ld_is_elf=yes
>   fi
>   for f in $gcc_cv_ld_bfd_srcdir/configure 
> $gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.in 
> $gcc_cv_ld_gld_srcdir/Makefile.in
>   do
> @@ -2192,11 +2195,23 @@
>  changequote(,)dnl
>  if test $in_tree_ld != yes ; then
>ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
> -  if test x"$ld_is_gold" = xyes; then
> -gcc_cv_ld_hidden=yes
> -  elif echo "$ld_ver" | grep GNU > /dev/null; then
> -ld_vers=`echo $ld_ver | sed -n \
> - -e 's,^.*[   ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
> +  if echo "$ld_ver" | grep GNU > /dev/null; then
> +if test x"$ld_is_gold" = xyes; then
> +  # GNU gold --version looks like this:
> +  #
> +  # GNU gold (GNU Binutils 2.21.51.20110225) 1.11
> +  #
> +  # We extract the binutils version which is more familiar and specific
> +  # than the gold version.
> +  ld_vers=`echo $ld_ver | sed -n \
> +   -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)) .*$,\1,p'`
> +else
> +  # GNU ld --version looks like this:
> +  #
> +  # GNU ld (GNU Binutils) 2.21.51.20110225
> +  ld_vers=`echo $ld_ver | sed -n \
> +   -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
> +fi
>  ld_date=`echo $ld_ver | sed -n 
> 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
>  ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
>  ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
> @@ -2235,7 +2250,9 @@
>fi
>  else
>gcc_cv_ld_hidden=yes
> -  if echo "$ld_ver" | grep GNU > /dev/null; then
> +  if test x"$ld_is_gold" = xyes; then
> +

Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Richard Guenther
On Thu, Mar 10, 2011 at 1:19 PM, Uros Bizjak  wrote:
> Hello!
>
> Using binutils-2.21, a couple of
> gcc.c-torture/execute/builtins/__-chk.c testcases fail on
> alphaev68-pc-linux-gnu (-lto) with:
>
> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
> Warning: alignment 8 of symbol `buf5' in
> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
> /tmp/ccc3QsSw.o.ironly
> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
> Warning: alignment 8 of symbol `buf7' in
> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
> /tmp/ccc3QsSw.o.ironly
> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
> Warning: alignment 8 of symbol `buf1' in
> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
> /tmp/ccc3QsSw.o.ironly
>
> Attached patch fixes these failures.

I think this needs more investigation as there are no conflicting
definitions of those vars that would warrant this kind of diagnostic from ld.

We probably bring the vars local by making them hidden and distribute
them to multiple ltrans units (with only one definiton obviously and multiple
externs).

Richard.

> 2011-03-10  Uros Bizjak  
>
>        PR testsuite/48055
>        * gcc.c-torture/execute/builtins/memcpy-chk.c (buf1, buf5, buf7):
>        Declare as static.
>        * gcc.c-torture/execute/builtins/mempcpy-chk.c (buf1, buf5, buf7):
>        Ditto.
>        * gcc.c-torture/execute/builtins/memmove-chk.c (buf1, buf5, buf7):
>        Ditto.
>
> Tested on alphaev68-pc-linux-gnu with binutils-2.21. OK for mainline
> and release branches?
>
> Uros
>


Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Uros Bizjak
On Thu, Mar 10, 2011 at 1:30 PM, Richard Guenther
 wrote:

>> Using binutils-2.21, a couple of
>> gcc.c-torture/execute/builtins/__-chk.c testcases fail on
>> alphaev68-pc-linux-gnu (-lto) with:
>>
>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>> Warning: alignment 8 of symbol `buf5' in
>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>> /tmp/ccc3QsSw.o.ironly
>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>> Warning: alignment 8 of symbol `buf7' in
>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>> /tmp/ccc3QsSw.o.ironly
>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>> Warning: alignment 8 of symbol `buf1' in
>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>> /tmp/ccc3QsSw.o.ironly
>>
>> Attached patch fixes these failures.
>
> I think this needs more investigation as there are no conflicting
> definitions of those vars that would warrant this kind of diagnostic from ld.
>
> We probably bring the vars local by making them hidden and distribute
> them to multiple ltrans units (with only one definiton obviously and multiple
> externs).

Jan claims that this problem is a linker bug, so perhaps the patch is
still suitable for the gcc testsuite. The patch doesn't alter tests in
any way, while it avoids false positives due to linker bugs.

The linker problem was filled as binutils PR 12564 [1] against ld 2.21.

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=12564

Uros.


Re: RFA (layout): PATCH for c++/48029 (ICE-on-valid with templates and arrays)

2011-03-10 Thread Jason Merrill

On 03/10/2011 04:56 AM, Richard Guenther wrote:

Ugh.  Why do we call layout_type on arrays with incomplete element type
at all?


layout_type has been called from the language-independent 
build_array_type since the dawn of revision control.



I suppose the array type is still considered un-layouted after
that finished (NULL TYPE_SIZE)?


Yes, layout_type only sets TYPE_SIZE if the element has a size.


So, what does layout_type provide
that the C++ FE relies on when layouting this kind of type?


Nothing that the FE relies on.  It sets the size, alignment and mode of 
the array type (if the element type is complete) and also builds the 
pointer-to-element type.  None of this seems necessary for an incomplete 
element type, but it doesn't seem to do any harm either; we need the 
change to type_hash_eq either way.


While looking at the history, it occurred to me that 
COMPLETE_OR_UNBOUND_ARRAY_TYPE_P is a better test than TYPE_SIZE in the 
type_hash_eq change, so I'm going to make that tweak to the patch; I 
assume you don't object.


Jason


Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Richard Guenther
On Thu, Mar 10, 2011 at 3:44 PM, Uros Bizjak  wrote:
> On Thu, Mar 10, 2011 at 1:30 PM, Richard Guenther
>  wrote:
>
>>> Using binutils-2.21, a couple of
>>> gcc.c-torture/execute/builtins/__-chk.c testcases fail on
>>> alphaev68-pc-linux-gnu (-lto) with:
>>>
>>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>>> Warning: alignment 8 of symbol `buf5' in
>>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>>> /tmp/ccc3QsSw.o.ironly
>>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>>> Warning: alignment 8 of symbol `buf7' in
>>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>>> /tmp/ccc3QsSw.o.ironly
>>> /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
>>> Warning: alignment 8 of symbol `buf1' in
>>> /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
>>> /tmp/ccc3QsSw.o.ironly
>>>
>>> Attached patch fixes these failures.
>>
>> I think this needs more investigation as there are no conflicting
>> definitions of those vars that would warrant this kind of diagnostic from ld.
>>
>> We probably bring the vars local by making them hidden and distribute
>> them to multiple ltrans units (with only one definiton obviously and multiple
>> externs).
>
> Jan claims that this problem is a linker bug, so perhaps the patch is
> still suitable for the gcc testsuite. The patch doesn't alter tests in
> any way, while it avoids false positives due to linker bugs.

Are you sure?  Making the vars static enables folding the zero initialization.

I don't think we should make testsuite changes to paper over bugs
elsewhere.

Richard.

> The linker problem was filled as binutils PR 12564 [1] against ld 2.21.
>
> [1] http://sourceware.org/bugzilla/show_bug.cgi?id=12564
>
> Uros.
>


Re: [pph] Buffer overrun in preprocessor symbol replay

2011-03-10 Thread Diego Novillo

On 11-03-09 09:01 PM, Lawrence Crowl wrote:


Index: gcc/cp/ChangeLog.pph

2011-03-09  Lawrence Crowl  

* pph.c (pth_dump_identifiers): Split cpp_idents_used::max_length
into max_ident_length and max_value_length.
(pth_save_identifiers): Likewise.
(pth_load_identifiers): Likewise.

Index: libcpp/ChangeLog.pph

2011-03-09  Lawrence Crowl 

* include/symtab.h (struct cpp_idents_used): Split max_length
into max_ident_len and max_value_len.
* internal.h (struct cpp_lookaside): Split max_length into
max_ident_len and max_value_len.
* symtab.c (cpp_lt_create): Split cpp_lookaside::max_length
into max_ident_len and max_value_len.
* (lt_macro_value): Likewise.
* (lt_lookup): Likewise.
* (cpp_lt_capture): Likewise.  Also split cpp_idents_used::max_lenth
into max_ident_len and max_value_len.
* (cpp_lt_replay): Split cpp_idents_used::max_lenth into
max_ident_len and max_value_len.  Allocate a buffer with the sum.


OK with minor nit.


unsigned int num_entries, id;

num_entries = identifiers->num_entries;
!   pph_output_uint (stream, identifiers->max_ident_len);
!   pph_output_uint (stream, identifiers->max_value_len);
pph_output_uint (stream, num_entries);

for ( id = 0; id < num_entries; ++id )


Extra space around '(' and ')' (this was there already, but I just noticed.)

Thanks for the quick fix!  Were these the 3-4 ICEs I had noticed in pth.exp?


Diego.


Re: [PATCH][libstdc++-v3 parallel mode] Avoid taking address of dereferenced random access iterator

2011-03-10 Thread Johannes Singler

On 03/10/2011 11:37 AM, Jonathan Wakely wrote:

On 10 March 2011 09:47, Johannes Singler wrote:

The attached patch patch solves a conformance problem of the parallel mode
helper routine multiseq_partition.  I have added a test case for that.
  multiseq_selection has similar problems, but is unused, so I plan to remove
that completely (which might ask for renaming of the file and the test).


Please update the copyright date in the changed file as well.


Done.


Should I use unique_ptr (or alloca, or something similar) here for a better
exception safety (this routine is not parallel itself)?


unique_ptr is C++0x only, auto_ptr would work.  But I see other heap
allocation in that function are already unguarded so there doesn't
seem to be much point guarding one and not the others.  How about
defining a local RAII type (and combining the three allocations into
one) e.g.

   struct _Guard
   {
   _DifferenceType* _M_ns;

   ~_Guard() { delete[] _M_ns; }
   } __guard = { };

   __guard._M_ns = new _DifferenceType[__m*3];

   _DifferenceType* __ns = __guard._M_ns;
   _DifferenceType* __a = __guard._M_ns + __m;
   _DifferenceType* __b = __guard._M_ns + 2*__m;
   _DifferenceType __l;

That ensures the _Guard destructor will clean up on exiting the
function, so you can remove the delete statements.


Well, isn't it a bit ugly to define such a guard newly every time?
In other places, parallel mode uses std::vector, but I guess this is 
actually also discouraged for internal use, since it adds the  
dependency.


Johannes


Re: RFA (layout): PATCH for c++/48029 (ICE-on-valid with templates and arrays)

2011-03-10 Thread Richard Guenther
On Thu, Mar 10, 2011 at 3:56 PM, Jason Merrill  wrote:
> On 03/10/2011 04:56 AM, Richard Guenther wrote:
>>
>> Ugh.  Why do we call layout_type on arrays with incomplete element type
>> at all?
>
> layout_type has been called from the language-independent build_array_type
> since the dawn of revision control.

Ugh, indeed - now I remember.  Something I wanted to try remove at
some point ;)

>> I suppose the array type is still considered un-layouted after
>> that finished (NULL TYPE_SIZE)?
>
> Yes, layout_type only sets TYPE_SIZE if the element has a size.
>
>> So, what does layout_type provide
>> that the C++ FE relies on when layouting this kind of type?
>
> Nothing that the FE relies on.  It sets the size, alignment and mode of the
> array type (if the element type is complete) and also builds the
> pointer-to-element type.  None of this seems necessary for an incomplete
> element type, but it doesn't seem to do any harm either; we need the change
> to type_hash_eq either way.
>
> While looking at the history, it occurred to me that
> COMPLETE_OR_UNBOUND_ARRAY_TYPE_P is a better test than TYPE_SIZE in the
> type_hash_eq change, so I'm going to make that tweak to the patch; I assume
> you don't object.

No, that's fine.

Richard.

> Jason
>


[PATCH] Fix s390_delegitimize_address (PR debug/48043)

2011-03-10 Thread Jakub Jelinek
Hi!

The pr47201.c testcase ICEs on s390x-linux during var-tracking.
The problem is that s390_delegitimize_address delegitimizes:
(mem/u/c:SF (plus:SI (reg:SI 12 %r12) (const:SI (unspec:SI [(symbol_ref:SI 
("u")  )] 111))) [0 S4 A8])
into:
(symbol_ref:SI ("u")  )
Note the different mode.  This means we end up after var-tracking.c
(adjust_insn) temporarily with a
(set (reg:SF 17 %f2) (symbol_ref:SI ("u") ))
insn and things go wrong pretty quickly because of the mode mismatch.
This is the same issue as i?86 backend had:
http://gcc.gnu.org/ml/gcc-patches/2010-05/msg00133.html

Andreas has bootstrapped/regtested this.

Ok for trunk?

2011-03-09  Jakub Jelinek  

PR debug/48043
* config/s390/s390.c (s390_delegitimize_address): Make sure the 
   
result mode matches original rtl mode.

--- gcc/config/s390/s390.c.jj   2011-03-09 19:54:56.0 +0100
+++ gcc/config/s390/s390.c  2011-03-09 21:34:52.0 +0100
@@ -5027,20 +5027,29 @@ s390_delegitimize_address (rtx orig_x)
   y = XEXP (XEXP (x, 1), 0);
   if (GET_CODE (y) == UNSPEC
  && XINT (y, 1) == UNSPEC_GOT)
-   return XVECEXP (y, 0, 0);
-  return orig_x;
+   y = XVECEXP (y, 0, 0);
+  else
+   return orig_x;
 }
-
-  if (GET_CODE (x) == CONST)
+  else if (GET_CODE (x) == CONST)
 {
   y = XEXP (x, 0);
   if (GET_CODE (y) == UNSPEC
  && XINT (y, 1) == UNSPEC_GOTENT)
-   return XVECEXP (y, 0, 0);
-  return orig_x;
+   y = XVECEXP (y, 0, 0);
+  else
+   return orig_x;
 }
+  else
+return orig_x;
 
-  return orig_x;
+  if (GET_MODE (orig_x) != Pmode)
+{
+  y = lowpart_subreg (GET_MODE (orig_x), y, Pmode);
+  if (y == NULL_RTX)
+   return orig_x;
+}
+  return y;
 }
 
 /* Output operand OP to stdio stream FILE.

Jakub


C++ PATCH for c++/47198 (ice-after-error with invalid type-name)

2011-03-10 Thread Jason Merrill
The call to cp_parser_skip_to_end_of_block_or_statement from 
cp_parser_parse_and_diagnose_invalid_type_name means that we're done 
looking at the current declaration; in the testcase, we were continuing 
to try to parse a declaration after skipping past the ;, so we ended up 
treating the constructor declarator as going with the template header. 
Instead, we should clean up and return.  This patch also slightly 
improves error recovery on a few other testcases.


Tested x86_64-pc-linux-gnu, applied to trunk.
commit 2659b79922e437e422612b2a4272c199446cf543
Author: Jason Merrill 
Date:   Thu Mar 10 01:22:45 2011 -0500

PR c++/47198
* parser.c (cp_parser_single_declaration): Just return if
cp_parser_parse_and_diagnose_invalid_type_name complained.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 510fcb1..7e9b286 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20102,8 +20102,15 @@ cp_parser_single_declaration (cp_parser* parser,
 }
 
   /* Complain about missing 'typename' or other invalid type names.  */
-  if (!decl_specifiers.any_type_specifiers_p)
-cp_parser_parse_and_diagnose_invalid_type_name (parser);
+  if (!decl_specifiers.any_type_specifiers_p
+  && cp_parser_parse_and_diagnose_invalid_type_name (parser))
+{
+  /* cp_parser_parse_and_diagnose_invalid_type_name calls
+cp_parser_skip_to_end_of_block_or_statement, so don't try to parse
+the rest of this declaration.  */
+  decl = error_mark_node;
+  goto out;
+}
 
   /* If it's not a template class, try for a template function.  If
  the next token is a `;', then this declaration does not declare
@@ -20137,19 +20144,21 @@ cp_parser_single_declaration (cp_parser* parser,
   }
 }
 
-  pop_deferring_access_checks ();
-
-  /* Clear any current qualification; whatever comes next is the start
- of something new.  */
-  parser->scope = NULL_TREE;
-  parser->qualifying_scope = NULL_TREE;
-  parser->object_scope = NULL_TREE;
   /* Look for a trailing `;' after the declaration.  */
   if (!function_definition_p
   && (decl == error_mark_node
  || !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON)))
 cp_parser_skip_to_end_of_block_or_statement (parser);
 
+ out:
+  pop_deferring_access_checks ();
+
+  /* Clear any current qualification; whatever comes next is the start
+ of something new.  */
+  parser->scope = NULL_TREE;
+  parser->qualifying_scope = NULL_TREE;
+  parser->object_scope = NULL_TREE;
+
   return decl;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C 
b/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C
new file mode 100644
index 000..ce1c9ee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C
@@ -0,0 +1,8 @@
+// PR c++/47198
+// { dg-options -std=c++0x }
+
+struct S
+{
+  template < int > sometype foo (); // { dg-error "sometype. does not name a 
type" }
+  S () = default;
+};
diff --git a/gcc/testsuite/g++.dg/parse/error36.C 
b/gcc/testsuite/g++.dg/parse/error36.C
index 0d7f8cf..8fcaa2f 100644
--- a/gcc/testsuite/g++.dg/parse/error36.C
+++ b/gcc/testsuite/g++.dg/parse/error36.C
@@ -30,4 +30,3 @@ void g(const A::type &t);  // { dg-error "typename" }
 
 // PR c++/18451
 template  A::B A::b; // { dg-error "typename" }
-// { dg-error "expected" "" { target *-*-* } 32 }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C 
b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C
index eb8f312..a8be91d 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C
@@ -10,4 +10,4 @@ struct A {
 template 
 A::A()   // { dg-error "constructor|qualified name" }
 {
-} // { dg-error "end of input" }
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C 
b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C
index 0708f1f..ad026a7 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C
@@ -18,4 +18,4 @@ struct B : public A
 
 template 
 B::A_Type B::Func() { // { dg-error "typename" } implicit typename
-}  // { dg-error "expected" }
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename4.C 
b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C
index 7238470..47fb250 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/typename4.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C
@@ -23,4 +23,4 @@ struct C : public B
 
 template 
 C::A_Type C::Func() { // { dg-error "typename" } implicit typename
-}  // { dg-error "expected" }
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename6.C 
b/gcc/testsuite/g++.old-deja/g++.pt/typename6.C
index 0a5f018..7347812 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/typename6.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/typename6.C
@@ -17,4 +17,4 @@ struct B : public A
 template 
 A::A_Type B::Func()   // { dg-error "typename" } function
 {  
-} // { dg-error "expected" }
+}


Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Uros Bizjak
On Thu, Mar 10, 2011 at 3:59 PM, Richard Guenther
 wrote:

>>  wrote:
>>
 Using binutils-2.21, a couple of
 gcc.c-torture/execute/builtins/__-chk.c testcases fail on
 alphaev68-pc-linux-gnu (-lto) with:

 /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
 Warning: alignment 8 of symbol `buf5' in
 /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
 /tmp/ccc3QsSw.o.ironly
 /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
 Warning: alignment 8 of symbol `buf7' in
 /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
 /tmp/ccc3QsSw.o.ironly
 /usr/lib/gcc/alpha-unknown-linux-gnu/4.4.5/../../../../alpha-unknown-linux-gnu/bin/ld:
 Warning: alignment 8 of symbol `buf1' in
 /tmp/ccgnDykf.ltrans1.ltrans.o is smaller than 16 in
 /tmp/ccc3QsSw.o.ironly

 Attached patch fixes these failures.
>>>
>>> I think this needs more investigation as there are no conflicting
>>> definitions of those vars that would warrant this kind of diagnostic from 
>>> ld.
>>>
>>> We probably bring the vars local by making them hidden and distribute
>>> them to multiple ltrans units (with only one definiton obviously and 
>>> multiple
>>> externs).
>>
>> Jan claims that this problem is a linker bug, so perhaps the patch is
>> still suitable for the gcc testsuite. The patch doesn't alter tests in
>> any way, while it avoids false positives due to linker bugs.
>
> Are you sure?  Making the vars static enables folding the zero initialization.

I was looking at other similar testcases (snprintf-chk.c,
vsprintf-chk.c), where uninitialized buffer is declared as static (and
it didn't fail lto tests). Anyway, let's ask the author of the test
(CC'd).

> I don't think we should make testsuite changes to paper over bugs
> elsewhere.

How far do we want to reach in case the test uncovers the problem in
(sort of...) unrelated product?

Uros.


Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Jakub Jelinek
On Thu, Mar 10, 2011 at 04:48:48PM +0100, Uros Bizjak wrote:
> > Are you sure?  Making the vars static enables folding the zero 
> > initialization.
> 
> I was looking at other similar testcases (snprintf-chk.c,
> vsprintf-chk.c), where uninitialized buffer is declared as static (and
> it didn't fail lto tests). Anyway, let's ask the author of the test
> (CC'd).

The tests weren't written with LTO in mind, after all LTO wasn't supported
by GCC at that point.  But I agree with Richard, we shouldn't working around
buggy ld in the gcc testsuite, it is good to know that you have a buggy
linker...

Jakub


[DOC PATCH] Add -Wunused-but-set-* note to gcc-4.6/changes.html and mention removal of in STL headers

2011-03-10 Thread Jakub Jelinek
Hi!

This mentions -Wunused-but-set-* warnings (which are C/C++/ObjC/ObjC++, so
not sure how to mention them in the language specific areas instead) and
briefly mentions removal of  includes.  More should go probably
into gcc-4.6/porting_to.html.

--- htdocs/gcc-4.6/changes.html.jj  2011-03-10 16:32:07.0 +0100
+++ htdocs/gcc-4.6/changes.html 2011-03-10 16:52:07.0 +0100
@@ -57,6 +57,17 @@
 libquadmath library is automatically built on
 such targets when building the Fortran compiler.
 
+New -Wunused-but-set-variable and
+-Wunused-but-set-parameter warnings were added
+for C, C++, Objective-C and Objective-C++.
+These warnings diagnose variables respective parameters which
+are only set in the code and never otherwise used.
+Usually such variables are useless and often even the value
+assigned to them is computed needlessly, sometimes expensively.
+The -Wunused-but-set-variable warning is enabled by
+default by -Wall flag and 
-Wunused-but-set-parameter
+by -Wall -W flags.
+
 Support for a number of older systems and recently
 unmaintained or untested target ports of GCC has been declared
 obsolete in GCC 4.6.  Unless there is activity to revive them, the
@@ -418,6 +429,10 @@
   they can be understood by race detectors such as Helgrind, see
   http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug.html#debug.races";>Data
   Race Hunting.
+Most libstdc++ standard headers have been changed to longer include
+  cstddef header as an implementation detail.  Code that
+  relied on that header being included as side-effect of including other
+  standard headers will need include cstddef explicitly.
   
 
 Fortran

Jakub


Re: [PATCH, testsuite]: Fix PR target/48055; FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation, -O2 -flto

2011-03-10 Thread Uros Bizjak
On Thu, Mar 10, 2011 at 4:57 PM, Jakub Jelinek  wrote:
> On Thu, Mar 10, 2011 at 04:48:48PM +0100, Uros Bizjak wrote:
>> > Are you sure?  Making the vars static enables folding the zero 
>> > initialization.
>>
>> I was looking at other similar testcases (snprintf-chk.c,
>> vsprintf-chk.c), where uninitialized buffer is declared as static (and
>> it didn't fail lto tests). Anyway, let's ask the author of the test
>> (CC'd).
>
> The tests weren't written with LTO in mind, after all LTO wasn't supported
> by GCC at that point.  But I agree with Richard, we shouldn't working around
> buggy ld in the gcc testsuite, it is good to know that you have a buggy
> linker...

AFAICS, the linker is not buggy, resulting executables still work OK.

But I agree, and won't push this minor issue any further.

Thanks,
Uros.


[PATCH] PR c++/PR48035

2011-03-10 Thread Dodji Seketeli
Hello,

In the example of the patch below, the zero-initialization of the
instance of E runs past the size of the object.

That's because build_zero_init recursively tries to initialize all the
sub-objects of 'e' without handling cases where 'e' could have
sub-objects for virtual direct or indirect primary bases of E, that
would come after a sub-object for the primary base of E.

More specifically, the layout of 'e' is (I left the vptrs out
for clarity):

+subobject  <-- comes first b/c B is the primary base of E
  +subobject
+subobject <-- this one doesn't include any
  +subobjectsubjobject of B b/c B is already
   included above.

And the code currently generated tries to zero-initialize
subobject.subobject even though it is not present.

The patch below teaches build_zero_init to consider that after a
subobject for a primary base the object has no subobject for virtual
bases that are direct or indirect primary bases.

Tested on x86_64-unknown-linux-gnu and i686-unknown-linux-gnu against
trunk.

PS: Thanks to Jakub for coming up with the placement new idea that eases
the writing of a deja-gnu test for this PR, and for bootstrapping the
patch on his fast iron on i686 and x86_64 for all languages.

-- 
Dodji

>From b52987810a313657202fc7ecae6b503311146302 Mon Sep 17 00:00:00 2001
From: Dodji Seketeli 
Date: Thu, 10 Mar 2011 14:10:05 +0100
Subject: [PATCH] PR c++/PR48035

gcc/cp/

* cp-tree.h (is_primary_base_of, is_virtual_base_of): Declare new
functions.
* class.c (is_base_of, is_virtual_base_of, is_primary_base_of):
Define new functions.
* init.c (build_zero_init_1):  Extract from from build_zero_init.
Handle sub-objects for virtual primary bases allocated after a
sub-object of a primary base.
(build_zero_init_1):  Use build_zero_init_1.

gcc/testsuite/

* g++.dg/inherit/virtual8.C: New test.
---
 gcc/cp/class.c  |   74 ++
 gcc/cp/cp-tree.h|2 +
 gcc/cp/init.c   |   86 +++---
 gcc/testsuite/g++.dg/inherit/virtual8.C |   52 +++
 4 files changed, 194 insertions(+), 20 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/inherit/virtual8.C

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1325260..b811e8f 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -7008,6 +7008,80 @@ get_primary_binfo (tree binfo)
   return copied_binfo (primary_base, binfo);
 }
 
+/* This is a subroutine of is_virtual_base_of.
+
+   Returns TRUE if BASE is a direct or indirect base class of TYPE,
+   FALSE otherwise.  */
+
+static bool
+is_base_of (tree base, tree type)
+{
+  int i;
+  tree binfo;
+
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, binfo); ++i)
+{
+  if (same_type_p (BINFO_TYPE (binfo), base)
+ || is_base_of (base, BINFO_TYPE (binfo)))
+   return true;
+}
+  return false;
+}
+
+/* Returns TRUE if BASE is a direct or indirect virtual base class of
+   TYPE, FALSE otherwise.  */
+
+bool
+is_virtual_base_of (tree base, tree type)
+{
+  int i;
+  tree binfo;
+
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, binfo); ++i)
+{
+  if (!BINFO_VIRTUAL_P (binfo))
+   continue;
+
+  if (same_type_p (BINFO_TYPE (binfo), base))
+   return true;
+
+  if (is_base_of (base, BINFO_TYPE (binfo)))
+   return true;
+}
+  return false;
+}
+
+/* Returns TRUE if BASE is a direct primary base class of TYPE.  If
+   INDIRECT_P is TRUE, then the function returns TRUE if BASE is a
+   direct or indirect base class of TYPE.  Returns FALSE
+   otherwise.  */
+
+bool
+is_primary_base_of (tree base, tree type, bool indirect_p)
+{
+  int i;
+  tree binfo;
+
+  if (!CLASS_TYPE_P (type)
+  || !CLASS_TYPE_P (base))
+return false;
+
+  if (CLASSTYPE_HAS_PRIMARY_BASE_P (type)
+  && same_type_p (base,
+ BINFO_TYPE (get_primary_binfo (TYPE_BINFO (type)
+return true;
+
+  if (!indirect_p)
+return false;
+
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, binfo); ++i)
+{
+  if (is_primary_base_of (base, BINFO_TYPE (binfo), true))
+   return true;
+}
+  return false;
+}
+
 /* If INDENTED_P is zero, indent to INDENT. Return nonzero.  */
 
 static int
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4b49046..cba5ddb 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4727,6 +4727,8 @@ extern void fixup_attribute_variants  (tree);
 extern tree* decl_cloned_function_p(const_tree, bool);
 extern void clone_function_decl(tree, int);
 extern void adjust_clone_args  (tree);
+extern bool is_primary_base_of  (tree, tree, bool);
+extern bool is_virtual_base_of  (tree, tree);
 
 /* in cvt.c */
 extern tree convert_to_reference   (tree, tree, int, 

Re: [PATCH][libstdc++-v3 parallel mode] Avoid taking address of dereferenced random access iterator

2011-03-10 Thread Jonathan Wakely
On 10 March 2011 15:02, Johannes Singler wrote:
>
> Well, isn't it a bit ugly to define such a guard newly every time?

It's one of my favourite techniques, the type is local and has no
linkage, it should be nothing but a destructor call which is
guaranteed to happen when exiting that scope.

> In other places, parallel mode uses std::vector, but I guess this is
> actually also discouraged for internal use, since it adds the 
> dependency.

I don't have a strong feeling either way - for this case where the
resource is just memory, std::vector would work fine.

The local RAII type is more useful when you have other resources to
clean up which need custom handling.


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Rainer Orth
Richard Guenther  writes:

> If I read this patch correctly then
>
>  1) it doesn't change the condition under which lto-plugin/ is built
> (good)

Right.

>  2) it makes -fuse-linker-plugin the default for and only for
> known good linkers (GNU binutils >= 2.21) (good)

Indeed.

>  3) it makes it impossible to use -fuse-linker-plugin explicitly
> for other linkers or linkers that were not installed during
> configuring gcc (bad - esp. the latter)
>
> can you please try avoiding 3) at this stage?  Or is the whole
> point of this patch 3) to be able to fix PR46944?

That was my goal: the Solaris linker accepts -p , which causes
confusion when it is called with -plugin.

> Ideally we'd reject broken linkers at runtime, but that would
> require some major collect2 massaging (eventually falling back
> to collect2 or simply reporting an error).

What about making LTO_PLUGIN 3-valued?

2   linker used has full -plugin support, i.e. gld/gold >= 2.21
1   linker has some -plugin support, i.e. gold >= 2.20 < 2.21
0   linker has no known plugin support, i.e. everything else, in
particular vendor linkers

We'd default to -fuse-linker-plugin for 2, accept it if given explicitly
for 1, and reject it for 0.

This would be similar to the first version of my patch, with the
difference that we don't try to determine the level of -plugin support
from trying to run the configured linker with -plugin and check if it
works, but instead hardcode that knowledge.

> That said, I'm not 100% happy with 3) at this point (though
> 2) is very desirable).
>
> Can we to fix 46944 change the dejagnu require-linker-plugin
> to check if a linker plugin is used by default and not add
> -fuse-linker-plugin?

That might be involved since it requires parsing gcc -Wl,-debug output.
I suppose the solution outlined above is simpler and thus more robust.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Richard Guenther
On Thu, 10 Mar 2011, Rainer Orth wrote:

> Richard Guenther  writes:
> 
> > If I read this patch correctly then
> >
> >  1) it doesn't change the condition under which lto-plugin/ is built
> > (good)
> 
> Right.
> 
> >  2) it makes -fuse-linker-plugin the default for and only for
> > known good linkers (GNU binutils >= 2.21) (good)
> 
> Indeed.
> 
> >  3) it makes it impossible to use -fuse-linker-plugin explicitly
> > for other linkers or linkers that were not installed during
> > configuring gcc (bad - esp. the latter)
> >
> > can you please try avoiding 3) at this stage?  Or is the whole
> > point of this patch 3) to be able to fix PR46944?
> 
> That was my goal: the Solaris linker accepts -p , which causes
> confusion when it is called with -plugin.
> 
> > Ideally we'd reject broken linkers at runtime, but that would
> > require some major collect2 massaging (eventually falling back
> > to collect2 or simply reporting an error).
> 
> What about making LTO_PLUGIN 3-valued?
> 
> 2 linker used has full -plugin support, i.e. gld/gold >= 2.21
> 1   linker has some -plugin support, i.e. gold >= 2.20 < 2.21
> 0   linker has no known plugin support, i.e. everything else, in
> particular vendor linkers
> 
> We'd default to -fuse-linker-plugin for 2, accept it if given explicitly
> for 1, and reject it for 0.
> 
> This would be similar to the first version of my patch, with the
> difference that we don't try to determine the level of -plugin support
> from trying to run the configured linker with -plugin and check if it
> works, but instead hardcode that knowledge.
> 
> > That said, I'm not 100% happy with 3) at this point (though
> > 2) is very desirable).
> >
> > Can we to fix 46944 change the dejagnu require-linker-plugin
> > to check if a linker plugin is used by default and not add
> > -fuse-linker-plugin?
> 
> That might be involved since it requires parsing gcc -Wl,-debug output.
> I suppose the solution outlined above is simpler and thus more robust.

It might be as simple as

int res;
int main() { int x; asm ("mov res, %0" : x(g)); return x; }

which should fail to link with the plugin only (but yes, requies
target dependent assembly ...).

Or, use -save-temps and check for the existence of the resolution
file for int main() {}.  It should be named t.res for gcc -o t t.c -flto.

Richard.


[gomp3.1] In OpenMP 3.1 draft const-qualified decls having no mutable member are no longer predetermined shared

2011-03-10 Thread Jakub Jelinek
Hi!

As %subj. said, const vars are no longer predetermined shared, they
are just not allowed in private/lastprivate/reduction clauses.

Tested on x86_64-linux, committed to gomp-3_1-branch.

2011-03-10  Jakub Jelinek  

* c-omp.c (c_omp_predetermined_sharing): Don't return
OMP_CLAUSE_DEFAULT_SHARED for TREE_READONLY decls.

* c-typeck.c (c_finish_omp_clauses): Complain about
TREE_READONLY decls in private, lastprivate and reduction
clauses.

* cp-gimplify.c (cxx_omp_predetermined_sharing): Don't return
OMP_CLAUSE_DEFAULT_SHARED for decls with TYPE_READONLY
type having no mutable member.
* semantics.c (finish_omp_clauses): Complain about
TREE_READONLY decls with no mutable member in private,
lastprivate and reduction clauses.

* gcc.dg/gomp/appendix-a/a.24.1.c: Adjust for const-qualified
decls having no mutable members no longer being predetermined
shared.
* gcc.dg/gomp/sharing-1.c: Likewise.
* gcc.dg/gomp/clause-1.c: Likewise.
* g++.dg/gomp/sharing-1.C: Likewise.
* g++.dg/gomp/clause-3.C: Likewise.
* g++.dg/gomp/predetermined-1.C: Likewise.
* g++.dg/gomp/private-1.C: New test.

--- gcc/c-family/c-omp.c.jj 2011-03-03 19:59:40.0 +0100
+++ gcc/c-family/c-omp.c2011-03-10 12:04:09.0 +0100
@@ -519,12 +519,7 @@ c_split_parallel_clauses (location_t loc
 /* True if OpenMP sharing attribute of DECL is predetermined.  */
 
 enum omp_clause_default_kind
-c_omp_predetermined_sharing (tree decl)
+c_omp_predetermined_sharing (tree decl ATTRIBUTE_UNUSED)
 {
-  /* Variables with const-qualified type having no mutable member
- are predetermined shared.  */
-  if (TREE_READONLY (decl))
-return OMP_CLAUSE_DEFAULT_SHARED;
-
   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
 }
--- gcc/c-typeck.c.jj   2011-03-03 20:00:38.0 +0100
+++ gcc/c-typeck.c  2011-03-10 12:04:09.0 +0100
@@ -10406,6 +10406,7 @@ c_finish_omp_clauses (tree clauses)
   bool remove = false;
   bool need_complete = false;
   bool need_implicitly_determined = false;
+  bool no_const = false;
 
   switch (OMP_CLAUSE_CODE (c))
{
@@ -10418,11 +10419,13 @@ c_finish_omp_clauses (tree clauses)
  name = "private";
  need_complete = true;
  need_implicitly_determined = true;
+ no_const = true;
  goto check_dup_generic;
 
case OMP_CLAUSE_REDUCTION:
  name = "reduction";
  need_implicitly_determined = true;
+ no_const = true;
  t = OMP_CLAUSE_DECL (c);
  if (AGGREGATE_TYPE_P (TREE_TYPE (t))
  || POINTER_TYPE_P (TREE_TYPE (t)))
@@ -10534,6 +10537,7 @@ c_finish_omp_clauses (tree clauses)
  t = OMP_CLAUSE_DECL (c);
  need_complete = true;
  need_implicitly_determined = true;
+ no_const = true;
  if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
  error_at (OMP_CLAUSE_LOCATION (c),
@@ -10603,6 +10607,13 @@ c_finish_omp_clauses (tree clauses)
t, share_name, name);
  remove = true;
}
+ else if (no_const && TREE_READONLY (t))
+   {
+ error_at (OMP_CLAUSE_LOCATION (c),
+   "const-qualified %qE cannot appear in %qs clause",
+   t, name);
+ remove = true;
+   }
}
}
 
--- gcc/cp/cp-gimplify.c.jj 2011-02-24 14:18:07.0 +0100
+++ gcc/cp/cp-gimplify.c2011-03-10 12:04:09.0 +0100
@@ -1184,8 +1184,6 @@ cxx_omp_privatize_by_reference (const_tr
 enum omp_clause_default_kind
 cxx_omp_predetermined_sharing (tree decl)
 {
-  tree type;
-
   /* Static data members are predetermined as shared.  */
   if (TREE_STATIC (decl))
 {
@@ -1194,41 +1192,6 @@ cxx_omp_predetermined_sharing (tree decl
return OMP_CLAUSE_DEFAULT_SHARED;
 }
 
-  type = TREE_TYPE (decl);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
-{
-  if (!is_invisiref_parm (decl))
-   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
-  type = TREE_TYPE (type);
-
-  if (TREE_CODE (decl) == RESULT_DECL && DECL_NAME (decl))
-   {
- /* NVR doesn't preserve const qualification of the
-variable's type.  */
- tree outer = outer_curly_brace_block (current_function_decl);
- tree var;
-
- if (outer)
-   for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var))
- if (DECL_NAME (decl) == DECL_NAME (var)
- && (TYPE_MAIN_VARIANT (type)
- == TYPE_MAIN_VARIANT (TREE_TYPE (var
-   {
- if (TYPE_READONLY (TREE_TYPE (var)))
-   type = TREE_TYPE (var);
- break;
-   }
-   }
-}
-
-  if (type == error_mark_node)
-return OMP_CL

Re: [PATCH][C] Fix PR47939

2011-03-10 Thread Joseph S. Myers
On Wed, 2 Mar 2011, Richard Guenther wrote:

> 2011-03-02  Richard Guenther  
> 
>   PR c/47939
>   * c-decl.c (grokdeclarator): Drop to the main variant only
>   for array types.  Drop flag_gen_aux_info check.

I can't convince myself that this is safe - that is, that it will maintain 
the invariant that TYPE_MAIN_VARIANT for an array type always points to a 
version where the ultimate element type is unqualified.  The problem would 
be where the type from the declaration specifiers is a qualified type, not 
an array type, but becomes an array element type through array declarators 
being processed by grokdeclarator, and so arrays are built up directly 
with qualified element type without the unqualified variants being built 
first to become the main variants.  It certainly appears that in a case 
such as

typedef const int T;
T a[10];
const int b[10];

you get multiple copies of the const int[10] type, some of which have a 
const int[10] variant as their main variant (incorrect) and some of which 
have an int[10] variant as their main variant (correct); the canonical 
types look rather odd as well.  It's reasonable have multiple copies here 
- for the type T[10] to remember the type name T it was derived from - but 
in such a case they should still all be on the variant chain for a single 
int[10] main variant.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] Fix s390_delegitimize_address (PR debug/48043)

2011-03-10 Thread Andreas Krebbel
On 03/10/2011 04:11 PM, Jakub Jelinek wrote:
> Ok for trunk?
> 
> 2011-03-09  Jakub Jelinek  
> 
>   PR debug/48043
>   * config/s390/s390.c (s390_delegitimize_address): Make sure the 
>
>   result mode matches original rtl mode.

This is ok. Thanks!

-Andreas-


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Jakub Jelinek
On Thu, Mar 10, 2011 at 05:14:12PM +0100, Dodji Seketeli wrote:
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/inherit/virtual8.C
...
> +
> +int
> +main ()
> +{
> +char *v = new char[sizeof (E) + 16];
> +memset (v, 0x55, sizeof (E) + 16);
> +E *e = new (v) E ();
> +e->~E ();
> +
> +for (unsigned i = sizeof (E); i < sizeof (E) + 16; ++i)
> +if (v[i] != 0x55)
> +return 1;
> +
> +delete[] v;
> +return 0;
> +}

The standard way of signalizing a test failure is calling abort (),
not returning 1, see http://gcc.gnu.org/codingconventions.html
(Testsuite Conventions).  While exit (0); isn't widely used
for testcase success (and return 0; can be omitted at the end of
main in C++ or C99), abort as the method of signalizing failure
is the norm.

Jakub


[C++0x patch] constexpr in attribute argument

2011-03-10 Thread Rodrigo Rivas
Hi!

Checking the new constexpr support in the C++0x frontend, I've notices
that there is one place where a plain constant is accepted but a
constexpr is not.
Probably you have guessed (from the subject line above), it is in an
attribute argument, e.g:

constexpr int foo()
{
return 4;
}
int __attribute__((aligned(4))) a; //ok
int __attribute__((aligned(foo( b; //error: requested alignment is
not a constant

IMHO, this code is correct.

The attached patch solves this issue cleanly, I think.
In the included testsuite I've used only the attribute ((aligned)),
but I don't think that should matter too much.

Regards
--
Rodrigo

Changelog:

gcc/cp/

2011-03-10  Rodrigo Rivas Costa  

* decl2.c (cp_check_const_attributes): New.
(cplus_decl_attributes): Call cp_check_const_attributes.

gcc/testsuite/

2011-03-10  Rodrigo Rivas Costa  

   * g++.dg/cpp0x/constexpr-attribute.C: New.
commit fbd79f3f22242a865d57fd106b4d8202a5e60241
Author: Rodrigo Rivas Costa 
Date:   Thu Mar 10 15:57:47 2011 +0100

constexpr attribute

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index eb5d4f5..8a2c2e3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1264,6 +1264,25 @@ cp_reconstruct_complex_type (tree type, tree bottom)
   return cp_build_qualified_type (outer, cp_type_quals (type));
 }
 
+/* Replaces any constexpr expression that may be into the attributes
+   arguments with their reduced value.  */
+
+static void
+cp_check_const_attributes (tree attributes)
+{
+  tree attr;
+  for (attr = attributes; attr; attr = TREE_CHAIN (attr))
+{
+  tree arg;
+  for (arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
+   {
+ tree expr = TREE_VALUE (arg);
+ if (EXPR_P (expr))
+   TREE_VALUE (arg) = maybe_constant_value (expr);
+   }
+}
+}
+
 /* Like decl_attributes, but handle C++ complexity.  */
 
 void
@@ -1284,6 +1303,8 @@ cplus_decl_attributes (tree *decl, tree attributes, int 
flags)
return;
 }
 
+  cp_check_const_attributes(attributes);
+
   if (TREE_CODE (*decl) == TEMPLATE_DECL)
 decl = &DECL_TEMPLATE_RESULT (*decl);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
new file mode 100644
index 000..58b3793
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
@@ -0,0 +1,63 @@
+// { dg-options -std=c++0x }
+
+//A few constexpr's
+constexpr int foo() { return __alignof__(int); }
+
+template
+constexpr int fooT() { return __alignof__(T); }
+
+template
+constexpr int fooN() { return N; }
+
+//Now the attributes
+
+//with normal variables,
+int a __attribute__((aligned(foo(;
+int b __attribute__((aligned(fooT(;
+int c __attribute__((aligned(fooN<__alignof__(int)>(;
+
+//with variables inside a template,
+template 
+void fun()
+{
+T a __attribute__((aligned(foo(;
+T b __attribute__((aligned(fooT(;
+T c __attribute__((aligned(fooN<__alignof__(T)>(;
+T d __attribute__((aligned(fooT(;
+T e __attribute__((aligned(fooN<__alignof__(int)>(;
+}
+
+//instantiate it,
+void bar()
+{
+fun();
+}
+
+//with classes
+struct __attribute__((aligned(foo( S0
+{
+char dummy;
+};
+S0 s0;
+
+struct __attribute__((aligned(fooT( S1
+{
+char dummy;
+};
+S1 s1;
+
+//and class templates
+template 
+struct __attribute__((aligned(foo( S2
+{
+char dummy;
+};
+
+S2 s2;
+
+template 
+struct __attribute__((aligned(fooT( S3
+{
+char dummy;
+};
+S3 s3;


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-03-10 Thread Rainer Orth
Richard Guenther  writes:

>> > Can we to fix 46944 change the dejagnu require-linker-plugin
>> > to check if a linker plugin is used by default and not add
>> > -fuse-linker-plugin?
>> 
>> That might be involved since it requires parsing gcc -Wl,-debug output.
>> I suppose the solution outlined above is simpler and thus more robust.
>
> It might be as simple as
>
> int res;
> int main() { int x; asm ("mov res, %0" : x(g)); return x; }
>
> which should fail to link with the plugin only (but yes, requies
> target dependent assembly ...).

... which I'd consider far too complicated/hard to maintain to consider.

> Or, use -save-temps and check for the existence of the resolution
> file for int main() {}.  It should be named t.res for gcc -o t t.c -flto.

Only with -save-temps, otherwise it's some random file in /var/tmp.  But
even so the file is removed immediately.

And even if we decide to fix PR lto/46944 like this, we're still left
with the problem of users invoking gcc with -fuse-linker-plugin and
getting either strange errors or no effect instead of a clear
diagnostic.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Problem with procedure pointers

2011-03-10 Thread Janus Weil
>> While I am inclined to not-bump the version number, I won't mind if you
>> decide to bump it.
>
> I agree.

Ok, since you guys seem to agree on that, here is the patch without
module version bumping, but this time complete with test case and
ChangeLog.

Ok for trunk?

Cheers,
Janus


2011-03-10  Janus Weil  

PR fortran/47768
* module.c (ab_attribute,attr_bits): Add AB_PROC_POINTER_COMP.
(mio_symbol_attribute): Handle attribute 'proc_pointer_comp'.

2011-03-10  Janus Weil  

PR fortran/47768
* gfortran.dg/proc_ptr_comp_31.f90: New.


mod_ppc.diff
Description: Binary data


proc_ptr_comp_31.f90
Description: Binary data


[cxx-mem-model] testing infrastructure

2011-03-10 Thread Aldy Hernandez

Hi folks.

The following is a test harness for testing atomicity problems and data 
races in multi-threaded environments.  Please see the README file in the 
patch below, which describes the use of GDB to test in-between states in 
a possibly threaded execution.


I would like to use this branch as the repository for tests of data 
races introduced by the compiler (atomics, illegal memory hoists of 
global variables in a multi-threaded environment, etc etc).


Eventually, as part of this project, I will be adding flags to the 
compiler (-fno-allow-load-data-races, etc), which we can use to safe 
guard against these illegal data race injections by the compiler.  Until 
then, I expect all (or most) of the tests below to fail.


A few tidbits...

1. I stole the GDB checks in the guality harness to check the presence 
of GDB.  If there is a more canonical way of checking the presence of a 
working gdb, let me know.


2. There is a README explaining the infrastructure, and the anatomy of a 
test.


3. Most of this work is actually Andrew Macleod's, who is off in a 
tropical island somewhere.  I have stolen most of his tests, implemented 
the harness, and cleaned up things for submission.  All errors, are 
obviously mine.


I would appreciate comments, and/or new relevant tests/problems you have 
encountered and would like fixed in the future.  I know there are a few 
Linux kernel problems that fall into this category.


Fire away, I don't mind being crucified.
Aldy
* lib/gcc-memmodel-gdb-test.exp: New.
* gcc.dg/memmodel/speculative-store.c: New
* gcc.dg/memmodel/subfields: New
* gcc.dg/memmodel/guality.h: New
* gcc.dg/memmodel/memmodel.h: New
* gcc.dg/memmodel/global-hoist.c: New
* gcc.dg/memmodel/d2.c: New
* gcc.dg/memmodel/d3.c: New
* gcc.dg/memmodel/memmodel.gdb: New.
* gcc.dg/memmodel/memmodel.exp: New.
* gcc.dg/memmodel/README: New.
* g++.dg/memmodel/guality.h: New.
* g++.dg/memmodel/memmodel.h: New.
* g++.dg/memmodel/memmodel.gdb: New.
* g++.dg/memmodel/memmodel.exp: New.
* g++.dg/memmodel/atomics-1.C: New.

Index: lib/gcc-memmodel-gdb-test.exp
===
--- lib/gcc-memmodel-gdb-test.exp   (revision 0)
+++ lib/gcc-memmodel-gdb-test.exp   (revision 0)
@@ -0,0 +1,67 @@
+#   Copyright (C) 2011 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 of the License, 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 GCC; see the file COPYING3.  If not see
+# .
+
+# Utility for running a given test through the memmodel harness using gdb.
+# This is invoked via dg-final.
+#
+# Adapted from the guality harness.
+#
+# Call 'fail' if a given test printed "FAIL:", otherwise call 'pass'.
+
+proc memmodel-gdb-test { } {
+if { ![isnative] || [is_remote target] } { return }
+
+# This assumes that we are three frames down from dg-test, and that
+# it still stores the filename of the testcase in a local variable "name".
+# A cleaner solution would require a new DejaGnu release.
+upvar 2 name testcase
+upvar 2 prog prog
+upvar 2 srcdir testsuite_dir
+
+set gdb_name $::env(GUALITY_GDB_NAME)
+set exec_file "[file rootname [file tail $prog]].exe"
+set cmd_file "$testsuite_dir/gcc.dg/memmodel/memmodel.gdb"
+
+send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$exec_file\n"
+set res [remote_spawn target "$gdb_name -nx -nw  -x $cmd_file 
./$exec_file"]
+if { $res < 0 || $res == "" } {
+   unsupported "$testcase"
+   return
+}
+
+remote_expect target [timeout_value] {
+   -re "FAIL:" {
+   fail "$testcase"
+   remote_close target
+   return
+   }
+   # Too old GDB
+   -re "Unhandled dwarf expression|Error in sourced command file" {
+   unsupported "$testcase"
+   remote_close target
+   return
+   }
+   timeout {
+   unsupported "$testcase"
+   remote_close target
+   return
+   }
+}
+
+remote_close target
+pass "$testcase"
+return
+}
Index: gcc.dg/memmodel/speculative-store.c
===
--- gcc.dg/memmodel/speculative-store.c (revision 0)
+++ gcc.dg/memmodel/speculative-store.c (revision 0)
@@ -0,0 +1,51 @@
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+/* { dg-final { me

Re: [cxx-mem-model] testing infrastructure

2011-03-10 Thread Aldy Hernandez
Oh BTW, I have committed the aforementioned patch.  This is one of the 
benefits of having your own branch (and Andrew being on vacation).  You 
commit at will, and only later hide your head in shame after multiple 
flames-- correcting patches after the fact.


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Mike Stump
On Mar 10, 2011, at 10:22 AM, Jakub Jelinek wrote:
> The standard way of signalizing a test failure is calling abort (),
> not returning 1, see http://gcc.gnu.org/codingconventions.html

Actually, returning 0 or 1 is a perfectly fine way to signal pass/fail in the 
testsuites, as it exit.


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Jakub Jelinek
On Thu, Mar 10, 2011 at 12:31:57PM -0800, Mike Stump wrote:
> On Mar 10, 2011, at 10:22 AM, Jakub Jelinek wrote:
> > The standard way of signalizing a test failure is calling abort (),
> > not returning 1, see http://gcc.gnu.org/codingconventions.html
> 
> Actually, returning 0 or 1 is a perfectly fine way to signal pass/fail in the 
> testsuites, as it exit.

E.g.
http://gcc.gnu.org/wiki/HowToPrepareATestcase
recommends abort instead and it is existing practice too.

Jakub


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Dodji Seketeli
Jakub Jelinek  writes:

> http://gcc.gnu.org/wiki/HowToPrepareATestcase
> recommends abort instead and it is existing practice too.

Sure.  I am going to update my local copy of the patch and re-post.  I
used return as I noticed it was working.  I didn't realize the
abort/exit was the recommended custom.  Thanks for the notice.

-- 
Dodji


Re: 4.5 backport request...

2011-03-10 Thread DJ Delorie

> This doesn't look like a regression fix.  The changelog doesn't tell
> if it is mere replacing macros by hooks, so please also attach the
> patch.

The original patch is here:

http://gcc.gnu.org/ml/gcc/2010-10/msg00076.html

It would need editing for 4.5, which I'll do if there's a good chance
the change will be accepted into 4.5.

It's just replacing macros with hooks.  The macros do not pass enough
information to the backend to do insn-specific alignments, which the
RX needs for optimal performance.  The hooks have an additional
argument, which is the insn which will be aligned.

On the RX, you pay a one cycle penalty if you branch to an insn which
spans a fetch line.


Re: [cxx-mem-model] testing infrastructure

2011-03-10 Thread Mike Stump
On Mar 10, 2011, at 11:58 AM, Aldy Hernandez wrote:
> The following is a test harness for testing atomicity problems and data races 
> in multi-threaded environments.

The idea of developing a methodology for testing corner cases I think is 
interesting and neat.  volatile would be another area that one could use this 
sort of testing for, if they want.  As time goes on, I suspect we'll have an 
ever increasing need to handle multicore issues, so, I think expanding in this 
area is worthwhile.

There is a speed hit and the requirement to have a target (or simulator) for 
testing.  If one just checks generated assembly, one avoids needing a target, 
and avoids the speed hit, but at the cost of having to come up with assembles 
to match for the target, which is annoying.  I can imagine validating sequences 
with this sort of test suite and then for future testing, checking the cache 
for a sequence that is known to be ok, to speed testing.  I'll just note that 
this sort of speed hack is orthogonal and could be used for a large number of 
execute test cases, not just this class of testing.


[PATCH] With -fno-early-inlining -finline-functions-called-once don't inline functions if there is argument type mismatch (PR tree-optimization/48063)

2011-03-10 Thread Jakub Jelinek
Hi!

ipa-inline.c apparently in all spots but one where it checks
call_stmt_cannot_inline_p also checks tree_can_inline_p.  With
-fno-early-inlining tree_can_inline_p won't be called earlier and thus
code to attempt to inline functions called once doesn't ever call
it to notice there is an argument mismatch.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
Ok for trunk?

2011-03-10  Jakub Jelinek  

PR tree-optimization/48063
* ipa-inline.c (cgraph_decide_inlining): Don't try to
inline functions called once if !tree_can_inline_p (node->callers).

* gcc.dg/torture/pr48063.c: New test.

--- gcc/ipa-inline.c.jj 2011-03-03 09:11:51.0 +0100
+++ gcc/ipa-inline.c2011-03-10 20:03:41.0 +0100
@@ -1498,6 +1498,7 @@ cgraph_decide_inlining (void)
  && node->callers->caller != node
  && node->callers->caller->global.inlined_to != node
  && !node->callers->call_stmt_cannot_inline_p
+ && tree_can_inline_p (node->callers)
  && !DECL_EXTERNAL (node->decl))
{
  cgraph_inline_failed_t reason;
--- gcc/testsuite/gcc.dg/torture/pr48063.c.jj   2011-03-10 20:05:59.0 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr48063.c  2011-03-10 20:05:43.0 
+0100
@@ -0,0 +1,19 @@
+/* PR tree-optimization/48063 */
+/* { dg-do compile } */
+/* { dg-options "-fno-early-inlining" } */
+
+extern void abort (void);
+static void bar ();
+
+void
+foo ()
+{
+  bar (1);
+}
+
+static void
+bar (double i)
+{
+  if (i)
+abort ();
+}

Jakub


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Jason Merrill

On 03/10/2011 03:45 PM, Jakub Jelinek wrote:

E.g.
http://gcc.gnu.org/wiki/HowToPrepareATestcase
recommends abort instead and it is existing practice too.


In the C++ testcase most testcases return non-zero to indicate failure. 
 The main reason for this is to avoid having to deal with declaring abort.


Jason


Re: [PATCH] PR c++/PR48035

2011-03-10 Thread Jason Merrill

On 03/10/2011 11:14 AM, Dodji Seketeli wrote:

+ /* If we are initializing a sub-object of
+CURRENT_OBJECT_TYPE [for which a primary base class
+sub-object has already been initialized] then we must NOT
+initialize any sub-object from a virtual base that is a
+direct or indirect primary base of
+CURRENT_OBJECT_TYPE.  */
+ if (current_object_type
+ && is_virtual_base_of (TREE_TYPE (field), current_object_type)
+ && is_primary_base_of (TREE_TYPE (field), current_object_type,
+/*indirect_p=*/true))
+   continue;


This seems like the wrong test.  If we're currently initializing a 
subobject, then we don't want to initialize any of our virtual base 
fields unless they are primary to the current type.  We don't need to 
consider the complete object type at all.


I'm also rather nervous about using is_*_base_of tests given that a 
class can have multiple indirect bases of a particular type.  Whether or 
not there is a virtual base T of U isn't important; what is important is 
whether the current field represents a virtual base.


Jason


[committed] HP-UX 10.X reentrant functions

2011-03-10 Thread John David Anglin
In HP-UX 10, the _r suffix routines are only declared when _REENTRANT
is defined.  Previously, we only defined _REENTRANT when -threads was
specified (DCE thread model).  However, we also need the reentrant
functions in the single thread model for libgfortran.  As far as I
can tell, the reentrant functions work fine without linking with
-lcma.  This similar to the situation on HP-UX 11 where the _REENTRANT
guard has been removed.  The only remaining guard is on `errno'.

In studying this, I learned that libc had been enhanced so that libc_r
was no longer needed on HP-UX 10.  Indeed, libc has a couple of additional
reentrant functions.  In HP-UX 10.30, the library changed to a POSIX 1c
implementations  libc_r was provided in HP-UX 10 for HP-UX 9 compatibility.
So, I've changed the thread linkage to use libc on HP-UX 10.

Tested on hppa1.1.-hp-hpux10.20 with no regressions.  Committed to trunk.

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)

2011-03-10  John David Anglin  

* config/pa/pa-hpux10.h (TARGET_OS_CPP_BUILTINS): Define _REENTRANT
when _HPUX_SOURCE is defined.
(LIB_SPEC): Use -lc instead of -lc_r when -threads is specified.

Index: config/pa/pa-hpux10.h
===
--- config/pa/pa-hpux10.h   (revision 170562)
+++ config/pa/pa-hpux10.h   (working copy)
@@ -42,12 +42,14 @@
if (c_dialect_cxx ())   \
  { \
builtin_define ("_HPUX_SOURCE");\
+   builtin_define ("_REENTRANT");  \
builtin_define ("_INCLUDE_LONGLONG");   \
builtin_define ("__STDCPP__");  \
  } \
else if (!flag_iso) \
  { \
builtin_define ("_HPUX_SOURCE");\
+   builtin_define ("_REENTRANT");  \
if (preprocessing_trad_p ())\
  { \
builtin_define ("hp9000s800");  \
@@ -111,7 +113,7 @@
   "%{!shared:\
  %{!p:%{!pg:\
%{!threads:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-   %{threads:-lcma -lc_r}}}\
+   %{threads:-lcma -lc}}}\
  %{p:%{!pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc\
  %{pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc"
 


[trans-mem] Final piece of pr 47952

2011-03-10 Thread Richard Henderson
I believe this finally fixes all of the problems in 47952.  The problem
was that we needed to clone

  basic_string::~basic_string()

which is inline, and also marked extern template, like so

  extern template class basic_string;

which I believe maps things to the gnu extern inline form.

In any case, we copied the whole decl during cloning, which resulted in
the clone being considered an extern inline too, which made us believe
that the clone was available elsewhere and thus not instantiated.

This patch changes the clones such that extern inline maps to static
inline, so that the functions get instantiated locally if they are not
inlined.  I shied away from using DECL_ONE_ONLY, since it seems fairly
complicated to determine what DECL_COMDAT_GROUP a particular c++ 
function should be mapped into.

Committed.


r~


[4.7] Avoid global state in s390_handle_option

2011-03-10 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the S390 handle_option hook from using global state.

S390 already had a processor enumeration, but not one suitable for
direct use with Enum in the .opt file for handling -march/-mtune
options because two processors (z9-109 and z9-ec) in
s390_handle_arch_option have a single PROCESSOR_ value but different
flags.  Thus, a further enumeration is added that corresponds to the
-march/-mtune values, so that those options can use the Enum
facility.

Three options used sscanf in s390_handle_option to read integer
values; two of these are converted to use UInteger in the .opt file
because the valid values can all be represented as nonnegative int
values.  In the case of the third, -mwarn-framesize=, the use of
sscanf is retained (now storing into the options structure, of
course).  One format using HOST_WIDE_INT_PRINT_DEC for a value that
changed type is updated; as this was a GCC diagnostic format, not a
printf format, use of HOST_WIDE_INT_PRINT_DEC was incorrect there
anyway and %wd was the correct way of printing HOST_WIDE_INT; I fixed
the other use of HOST_WIDE_INT_PRINT_DEC in that format string, but
not some other instances of the same bug in the S390 back end.  (For
some hosts, HOST_WIDE_INT_PRINT_DEC may only be understood by system
printf and not by the GCC pretty-printers at all; furthermore,
concatenation with macro expansions does not work with i18n.)

Tested building cc1 and xgcc for cross to s390-linux-gnu.  Will commit
to trunk for 4.7 in the absence of target maintainer objections.

2011-03-10  Joseph Myers  

* config/s390/s390-opts.h: New.
* config/s390/s390.c (s390_tune, s390_tune_flags, s390_arch,
s390_arch_flags, s390_warn_framesize, s390_stack_size,
s390_stack_guard): Remove.
(s390_handle_arch_option): Return void.  Take enum
s390_arch_option value instead of string and searching array.
(s390_handle_option): Don't assert that global structures are in
use.  Access variables via opts pointer.  Use error_at.  Don't use
sscanf for -mstack-guard= or -mstack-size=.  Update call to
s390_handle_arch_option.
(s390_option_override): Update call to s390_handle_arch_option.
(s390_emit_prologue): Use %d format for s390_stack_size in
diagnostic.  Use %wd for HOST_WIDE_INT.
* config/s390/s390.h (enum processor_type): Move to s390-opts.h.
(s390_tune, s390_tune_flags, s390_arch, s390_arch_flags): Remove.
* config/s390/s390.opt (config/s390/s390-opts.h): New
HeaderInclude entry.
(s390_arch_string, s390_tune, s390_tune_flags, s390_arch,
s390_arch_flags, s390_warn_framesize): New Variable entries.
(s390_arch_option): New Enum and EnumValue entries.
(march=): Use Enum instead of Var.
(mstack-guard=, mstack-size=): Use UInteger and Var.
(mtune=): Use Enum.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/s390/s390-opts.h 
gcc-mainline/gcc/config/s390/s390-opts.h
--- gcc-mainline-1/gcc/config/s390/s390-opts.h  1969-12-31 16:00:00.0 
-0800
+++ gcc-mainline/gcc/config/s390/s390-opts.h2011-03-10 17:45:57.0 
-0800
@@ -0,0 +1,57 @@
+/* Definitions for option handling for IBM S/390.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+   2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#ifndef S390_OPTS_H
+#define S390_OPTS_H
+
+/* Which processor to generate code or schedule for. The cpu attribute
+   defines a list that mirrors this list, so changes to s390.md must be
+   made at the same time.  */
+
+enum processor_type
+{
+  PROCESSOR_9672_G5,
+  PROCESSOR_9672_G6,
+  PROCESSOR_2064_Z900,
+  PROCESSOR_2084_Z990,
+  PROCESSOR_2094_Z9_109,
+  PROCESSOR_2097_Z10,
+  PROCESSOR_2817_Z196,
+  PROCESSOR_max
+};
+
+/* This enumeration must match processor_alias_table in
+   s390_handle_arch_option.  It is different from enum processor_type
+   because some processors differ for option handling but not for
+   scheduling.  */
+
+enum s390_arch_option
+{
+  s390_arch_g5,
+  s390_arch_g6,
+  s390_arch_z900,
+  s390_arch_z990,
+  s390_arch_z9_109,
+  s390_arch_z9_ec,
+  s390_arch_z10,
+  s390_arch_z196
+};
+
+#endif
diff -rupN --exclude=.svn gcc-main

[4.7 PATCH 00/18] slim down a number of tree nodes

2011-03-10 Thread Nathan Froyd
This patch series does something similar to what:

http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02491.html

did, only it does it in a cleaner way and it addresses the problem more
generally.  It introduces a separate substructure (base class) for tree
nodes that include TREE_TYPE so that a tree node can use TREE_TYPE
without having to deal with TREE_CHAIN.  It then goes about making
changes where necessary to both use this new substructure and eliminate
unnecessary TREE_CHAIN usage.

Eliminating the block field from tree_exp would be another nice-to-have
for 4.7, but that's not on my radar of things to address at the moment.
(Matz, you want to do that? :)  Eliminating TREE_TYPE from tree_exp as
suggested on the wiki would be another interesting project, but not one
I plan on tackling.

The patch series touches every front-end in various places.  I have CC'd
the appropriate mailing lists with this introductory email, but I will
only CC those mailing lists on followup patches that touch the
appropriate FE.

I have not rigorously measured memory savings with this patch.  Based on
a (very small) sample, this patch saves ~5% of tree memory according to
dump_tree_statistics...though the amount of tree memory as reported by
dump_tree_statistics is somewhat suspect, since it doesn't include
statistics from copy_node_stat.

The patch series has been bootstrapped on x86_64-unknown-linux-gnu, both
in its entirety and with sub-patches along the way.  Indeed, the patches
were not developed in this order; the checking bits were introduced
first, then any bootstrap or testsuite failures were fixed up, then the
patches were committed in the proper order.

Nathan Froyd (18):
  add typed_tree structure
  enforce TREE_CHAIN and TREE_TYPE accesses
  remove TREE_CHAIN from *_CST nodes
  remove TREE_CHAIN from SSA_NAME nodes
  remove TREE_CHAIN from CONSTRUCTOR nodes
  define CASE_CHAIN accessor for CASE_LABEL_EXPR
  generalize build_case_label to the rest of the compiler
  convert cp *FOR_STMTs to use private scope fields
  convert cp IF_STMTs to use private scope fields
  convert cp SWITCH_STMTs to use private scope fields
  mark EXPR_PACK_EXPANSION as typed only
  make CASE_LABEL_EXPR not abuse TREE_CHAIN
  move TS_EXP to be a substructure of TS_TYPED
  move TS_STATEMENT_LIST to be a substructure of TS_TYPED
  move REAL_IDENTIFIER_TYPE_VALUE to be a field of lang_identifier
  make TS_IDENTIFIER be a substructure of TS_BASE
  introduce block_chainon and use BLOCK_CHAIN more
  make TS_BLOCK a substructure of TS_BASE

 gcc/ada/gcc-interface/ada-tree.h |2 +-
 gcc/ada/gcc-interface/misc.c |   16 ++
 gcc/ada/gcc-interface/trans.c|5 +-
 gcc/ada/gcc-interface/utils.c|4 +-
 gcc/c-decl.c |8 ++-
 gcc/c-family/c-common.c  |   14 +-
 gcc/c-family/c-common.h  |   20 +---
 gcc/c-family/c-semantics.c   |   28 ---
 gcc/c-lang.c |2 +
 gcc/c-parser.c   |2 +-
 gcc/c-typeck.c   |2 +-
 gcc/cp/cp-lang.c |   22 +
 gcc/cp/cp-objcp-common.c |   74 +++
 gcc/cp/cp-objcp-common.h |1 +
 gcc/cp/cp-tree.def   |   19 ---
 gcc/cp/cp-tree.h |   43 ++--
 gcc/cp/decl.c|   28 ++
 gcc/cp/decl2.c   |   20 ---
 gcc/cp/error.c   |2 +-
 gcc/cp/init.c|6 +-
 gcc/cp/mangle.c  |   28 +++---
 gcc/cp/name-lookup.c |   10 ++--
 gcc/cp/pt.c  |   40 +--
 gcc/cp/repo.c|2 +-
 gcc/cp/rtti.c|6 +-
 gcc/cp/search.c  |4 +-
 gcc/cp/semantics.c   |   41 +--
 gcc/cp/typeck.c  |4 +-
 gcc/except.c |5 +-
 gcc/fortran/f95-lang.c   |8 ++--
 gcc/fortran/trans-decl.c |2 +-
 gcc/fortran/trans-io.c   |2 +-
 gcc/fortran/trans-stmt.c |   14 ++---
 gcc/function.c   |   28 ++
 gcc/function.h   |1 +
 gcc/gimplify.c   |   14 +++---
 gcc/go/go-lang.c |2 +-
 gcc/java/decl.c  |   13 ++---
 gcc/java/expr.c  |9 ++--
 gcc/java/java-tree.h |2 +-
 gcc/lto-streamer-in.c|2 +-
 gcc/lto-streamer-out.c   |2 +-
 gcc/lto-streamer.c   |1 +
 gcc/lto/lto-tree.h   |2 +-
 gcc/lto/lto.c|3 +-
 gcc/objc/objc-act.c  |   18 +++
 gcc/objc/objc-act.h  |1 +
 gcc/objc/objc-lang.c |   32 +---
 gcc/objcp/objcp-lang.c   |   48 +-
 gcc/omp-low.c|7 +--
 gcc/print-tree.c |   11 +---
 gcc/tree-cfg.c   |   

[PATCH 01/18] add typed_tree structure

2011-03-10 Thread Nathan Froyd
The first step in removing TREE_CHAIN (and even TREE_TYPE) from a select
few nodes is to create separate substructures for trees-with-type and
trees-with-chain.  Since trees-with-type but no chain are expected to be
more common that vice versa, make the hierarchy reflect that.  Modify a
few macros to reflect the new inheritance structure, and add a new tree
structure enum for the new structure.  Make note that we support the new
tree structure in the LTO streamer, even though we don't need to do
anything about it yet.

-Nathan

gcc/
* tree.h (struct typed_tree): New.
(struct tree_common): Include it instead of tree_base.
(TREE_TYPE): Update for new location of type field.
(TYPE_USER_ALIGN, TYPE_PACKED): Refer to base field directly.
(DECL_USER_ALIGN, DECL_PACKED): Likewise.
(union tree_node): Add typed field.
* treestruct.def (TS_TYPED): New.
* lto-streamer.c (check_handled_ts_structures): Handle it.
* tree.c (MARK_TS_TYPED): New macro.
(MARK_TS_COMMON): Call it instead of MARK_TS_BASE.

diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index dba9d2d..546228c 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -270,6 +270,7 @@ check_handled_ts_structures (void)
   /* These are the TS_* structures that are either handled or
  explicitly ignored by the streamer routines.  */
   handled_p[TS_BASE] = true;
+  handled_p[TS_TYPED] = true;
   handled_p[TS_COMMON] = true;
   handled_p[TS_INT_CST] = true;
   handled_p[TS_REAL_CST] = true;
diff --git a/gcc/tree.c b/gcc/tree.c
index c947072..798bc08 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -356,9 +356,15 @@ initialize_tree_contains_struct (void)
 tree_contains_struct[C][TS_BASE] = 1;  \
   } while (0)
 
-#define MARK_TS_COMMON(C)  \
+#define MARK_TS_TYPED(C)   \
   do { \
 MARK_TS_BASE (C);  \
+tree_contains_struct[C][TS_TYPED] = 1; \
+  } while (0)
+
+#define MARK_TS_COMMON(C)  \
+  do { \
+MARK_TS_TYPED (C); \
 tree_contains_struct[C][TS_COMMON] = 1;\
   } while (0)
 
diff --git a/gcc/tree.h b/gcc/tree.h
index a49e335..2f772e1 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -407,12 +407,16 @@ struct GTY(()) tree_base {
   unsigned address_space : 8;
 };
 
-struct GTY(()) tree_common {
+struct GTY(()) typed_tree {
   struct tree_base base;
-  tree chain;
   tree type;
 };
 
+struct GTY(()) tree_common {
+  struct typed_tree typed;
+  tree chain;
+};
+
 /* The following table lists the uses of each of the above flags and
for which types of nodes they are defined.
 
@@ -869,7 +873,7 @@ enum tree_node_structure_enum {
In VECTOR_TYPE nodes, this is the type of the elements.  */
 #define TREE_TYPE(NODE) __extension__ \
 (*({__typeof (NODE) const __t = (NODE);
\
-&__t->common.type; }))
+&__t->typed.type; }))
 
 extern void tree_contains_struct_check_failed (const_tree,
   const enum 
tree_node_structure_enum,
@@ -2151,7 +2155,7 @@ extern enum machine_mode vector_type_mode (const_tree);
 
 /* 1 if the alignment for this type was requested by "aligned" attribute,
0 if it is the default for this type.  */
-#define TYPE_USER_ALIGN(NODE) (TYPE_CHECK (NODE)->common.base.user_align)
+#define TYPE_USER_ALIGN(NODE) (TYPE_CHECK (NODE)->base.user_align)
 
 /* The alignment for NODE, in bytes.  */
 #define TYPE_ALIGN_UNIT(NODE) (TYPE_ALIGN (NODE) / BITS_PER_UNIT)
@@ -2289,7 +2293,7 @@ extern enum machine_mode vector_type_mode (const_tree);
 
 /* Indicated that objects of this type should be laid out in as
compact a way as possible.  */
-#define TYPE_PACKED(NODE) (TYPE_CHECK (NODE)->common.base.packed_flag)
+#define TYPE_PACKED(NODE) (TYPE_CHECK (NODE)->base.packed_flag)
 
 /* Used by type_contains_placeholder_p to avoid recomputation.
Values are: 0 (unknown), 1 (false), 2 (true).  Never access
@@ -2632,7 +2636,7 @@ struct GTY(()) tree_decl_minimal {
 /* Set if the alignment of this DECL has been set by the user, for
example with an 'aligned' attribute.  */
 #define DECL_USER_ALIGN(NODE) \
-  (DECL_COMMON_CHECK (NODE)->common.base.user_align)
+  (DECL_COMMON_CHECK (NODE)->base.user_align)
 /* Holds the machine mode corresponding to the declaration of a variable or
field.  Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
FIELD_DECL.  */
@@ -2900,7 +2904,7 @@ struct GTY(()) tree_decl_with_rtl {
 #define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.fcontext)
 
 /* In a FIELD_DECL, indicates this field should be bit-packed.  */
-#define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->common.base.packed_flag)
+#define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->bas

[PATCH 03/18] remove TREE_CHAIN from *_CST nodes

2011-03-10 Thread Nathan Froyd
*_CST nodes don't need TREE_CHAIN.  Make them include typed_tree instead,
mark them as such in initialize_tree_contains_struct, and don't print out
their TREE_CHAIN.

-Nathan

gcc/
* tree.h (struct tree_int_cst, struct real_value): Include typed_tree
instead of tree_common.
(struct tree_fixed_cst, struct tree_string, struct tree_complex):
Likewise.
* tree.c (initialize_tree_contains_struct): Mark such nodes as being
TS_TYPED rather than TS_COMMON.
* print-tree.c (print_node): Don't print TREE_CHAIN for constants.

diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index b0c6899..3b5edeb 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -853,11 +853,6 @@ print_node (FILE *file, const char *prefix, tree node, int 
indent)
  }
fputc ('\"', file);
  }
- /* Print the chain at second level.  */
- if (indent == 4)
-   print_node (file, "chain", TREE_CHAIN (node), indent + 4);
- else
-   print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
  break;
 
case IDENTIFIER_NODE:
diff --git a/gcc/tree.c b/gcc/tree.c
index 68f40c9..7d73c74 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -370,15 +370,15 @@ initialize_tree_contains_struct (void)
  break;
 
case TS_COMMON:
- MARK_TS_TYPED (code);
- break;
-
case TS_INT_CST:
case TS_REAL_CST:
case TS_FIXED_CST:
case TS_VECTOR:
case TS_STRING:
case TS_COMPLEX:
+ MARK_TS_TYPED (code);
+ break;
+
case TS_IDENTIFIER:
case TS_DECL_MINIMAL:
case TS_TYPE:
diff --git a/gcc/tree.h b/gcc/tree.h
index 4ad2d3e..11c2f83 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1456,7 +1456,7 @@ extern void omp_clause_range_check_failed (const_tree, 
const char *, int,
&& TREE_INT_CST_LOW (A) < TREE_INT_CST_LOW (B)))
 
 struct GTY(()) tree_int_cst {
-  struct tree_common common;
+  struct typed_tree typed;
   double_int int_cst;
 };
 
@@ -1469,7 +1469,7 @@ struct real_value;
 #define TREE_REAL_CST(NODE) (*TREE_REAL_CST_PTR (NODE))
 
 struct GTY(()) tree_real_cst {
-  struct tree_common common;
+  struct typed_tree typed;
   struct real_value * real_cst_ptr;
 };
 
@@ -1481,7 +1481,7 @@ struct fixed_value;
 #define TREE_FIXED_CST(NODE) (*TREE_FIXED_CST_PTR (NODE))
 
 struct GTY(()) tree_fixed_cst {
-  struct tree_common common;
+  struct typed_tree typed;
   struct fixed_value * fixed_cst_ptr;
 };
 
@@ -1491,7 +1491,7 @@ struct GTY(()) tree_fixed_cst {
   ((const char *)(STRING_CST_CHECK (NODE)->string.str))
 
 struct GTY(()) tree_string {
-  struct tree_common common;
+  struct typed_tree typed;
   int length;
   char str[1];
 };
@@ -1501,7 +1501,7 @@ struct GTY(()) tree_string {
 #define TREE_IMAGPART(NODE) (COMPLEX_CST_CHECK (NODE)->complex.imag)
 
 struct GTY(()) tree_complex {
-  struct tree_common common;
+  struct typed_tree typed;
   tree real;
   tree imag;
 };
@@ -1510,7 +1510,7 @@ struct GTY(()) tree_complex {
 #define TREE_VECTOR_CST_ELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.elements)
 
 struct GTY(()) tree_vector {
-  struct tree_common common;
+  struct typed_tree typed;
   tree elements;
 };
 
-- 
1.7.0.4



[PATCH 05/18] remove TREE_CHAIN from CONSTRUCTOR nodes

2011-03-10 Thread Nathan Froyd
A straightforward conversion.

-Nathan

gcc/
* tree.h (struct tree_constructor): Include typed_tree instead of
tree_common.
* tree.c (initialize_tree_contains_struct): Mark TS_CONSTRUCTOR as
TS_TYPED instead of TS_COMMON.

diff --git a/gcc/tree.c b/gcc/tree.c
index 072ff19..da16641 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -377,6 +377,7 @@ initialize_tree_contains_struct (void)
case TS_STRING:
case TS_COMPLEX:
case TS_SSA_NAME:
+   case TS_CONSTRUCTOR:
  MARK_TS_TYPED (code);
  break;
 
@@ -389,7 +390,6 @@ initialize_tree_contains_struct (void)
case TS_BLOCK:
case TS_BINFO:
case TS_STATEMENT_LIST:
-   case TS_CONSTRUCTOR:
case TS_OMP_CLAUSE:
case TS_OPTIMIZATION:
case TS_TARGET_OPTION:
diff --git a/gcc/tree.h b/gcc/tree.h
index 80888bc..35479f9 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1614,7 +1614,7 @@ DEF_VEC_O(constructor_elt);
 DEF_VEC_ALLOC_O(constructor_elt,gc);
 
 struct GTY(()) tree_constructor {
-  struct tree_common common;
+  struct typed_tree typed;
   VEC(constructor_elt,gc) *elts;
 };
 
-- 
1.7.0.4



[PATCH 04/18] remove TREE_CHAIN from SSA_NAME nodes

2011-03-10 Thread Nathan Froyd
This conversion is straightforward.  The tricky part is converting
FREE_SSANAMES into a VEC to eliminate the only use of TREE_CHAIN on
SSA_NAMEs.

-Nathan

gcc/
* tree-flow.h (struct gimple_df): Make free_ssanames a VEC.
* tree-ssanames.c (fini_ssanames): VEC_free it.
(make_ssa_name_fn): Update for VECness of free_ssanames.
(release_ssa_name, release_dead_ssa_names): Likewise.
* tree.h (struct tree_ssa_name): Include typed_tree instead of
tree_common.
* tree.c (initialize_tree_contains_struct): Mark TS_SSA_NAME as
TS_TYPED instead of TS_COMMON.

diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 14c8827..6b48697 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -61,7 +61,7 @@ struct GTY(()) gimple_df {
   struct pointer_map_t * GTY((skip(""))) decls_to_pointers;
 
   /* Free list of SSA_NAMEs.  */
-  tree free_ssanames;
+  VEC(tree,gc) *free_ssanames;
 
   /* Hashtable holding definition for symbol.  If this field is not NULL, it
  means that the first reference to this variable in the function is a
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index c76dba5..06cdbee 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -96,7 +96,7 @@ void
 fini_ssanames (void)
 {
   VEC_free (tree, gc, SSANAMES (cfun));
-  FREE_SSANAMES (cfun) = NULL;
+  VEC_free (tree, gc, FREE_SSANAMES (cfun));
 }
 
 /* Dump some simple statistics regarding the re-use of SSA_NAME nodes.  */
@@ -124,10 +124,9 @@ make_ssa_name_fn (struct function *fn, tree var, gimple 
stmt)
   gcc_assert (DECL_P (var));
 
   /* If our free list has an element, then use it.  */
-  if (FREE_SSANAMES (fn))
+  if (!VEC_empty (tree, FREE_SSANAMES (fn)))
 {
-  t = FREE_SSANAMES (fn);
-  FREE_SSANAMES (fn) = TREE_CHAIN (FREE_SSANAMES (fn));
+  t = VEC_pop (tree, FREE_SSANAMES (fn));
 #ifdef GATHER_STATISTICS
   ssa_name_nodes_reused++;
 #endif
@@ -234,9 +233,8 @@ release_ssa_name (tree var)
   /* Note this SSA_NAME is now in the first list.  */
   SSA_NAME_IN_FREE_LIST (var) = 1;
 
-  /* And finally link it into the free list.  */
-  TREE_CHAIN (var) = FREE_SSANAMES (cfun);
-  FREE_SSANAMES (cfun) = var;
+  /* And finally put it on the free list.  */
+  VEC_safe_push (tree, gc, FREE_SSANAMES (cfun), var);
 }
 }
 
@@ -334,8 +332,8 @@ replace_ssa_name_symbol (tree ssa_name, tree sym)
 static unsigned int
 release_dead_ssa_names (void)
 {
-  tree t, next;
-  int n = 0;
+  tree t;
+  int n = VEC_length (tree, FREE_SSANAMES (cfun));
   referenced_var_iterator rvi;
 
   /* Current defs point to various dead SSA names that in turn point to
@@ -343,17 +341,7 @@ release_dead_ssa_names (void)
   FOR_EACH_REFERENCED_VAR (cfun, t, rvi)
 set_current_def (t, NULL);
   /* Now release the freelist.  */
-  for (t = FREE_SSANAMES (cfun); t; t = next)
-{
-  next = TREE_CHAIN (t);
-  /* Dangling pointers might make GGC to still see dead SSA names, so it is
-important to unlink the list and avoid GGC from seeing all subsequent
-SSA names.  In longer run we want to have all dangling pointers here
-removed (since they usually go through dead statements that consume
-considerable amounts of memory).  */
-  TREE_CHAIN (t) = NULL_TREE;
-  n++;
-}
+  VEC_free (tree, gc, FREE_SSANAMES (cfun));
   FREE_SSANAMES (cfun) = NULL;
 
   statistics_counter_event (cfun, "SSA names released", n);
diff --git a/gcc/tree.c b/gcc/tree.c
index 7d73c74..072ff19 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -376,6 +376,7 @@ initialize_tree_contains_struct (void)
case TS_VECTOR:
case TS_STRING:
case TS_COMPLEX:
+   case TS_SSA_NAME:
  MARK_TS_TYPED (code);
  break;
 
@@ -385,7 +386,6 @@ initialize_tree_contains_struct (void)
case TS_LIST:
case TS_VEC:
case TS_EXP:
-   case TS_SSA_NAME:
case TS_BLOCK:
case TS_BINFO:
case TS_STATEMENT_LIST:
diff --git a/gcc/tree.h b/gcc/tree.h
index 11c2f83..80888bc 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1970,7 +1970,7 @@ typedef struct GTY(()) ssa_use_operand_d {
 #define SSA_NAME_IMM_USE_NODE(NODE) SSA_NAME_CHECK (NODE)->ssa_name.imm_uses
 
 struct GTY(()) tree_ssa_name {
-  struct tree_common common;
+  struct typed_tree typed;
 
   /* _DECL wrapped by this SSA name.  */
   tree var;
-- 
1.7.0.4



[PATCH 06/18] define CASE_CHAIN accessor for CASE_LABEL_EXPR

2011-03-10 Thread Nathan Froyd
This patch begins a subseries of patches aimed at removing TREE_CHAIN
from expression trees.  tree-cfg.c uses TREE_CHAIN for some analysis
steps on CASE_LABEL_EXPRs.  I looked at this for a while, thinking it'd
be easy to use VECs instead, but AFAICS, it wasn't.  I went for the next
best thing, hiding TREE_CHAIN usage behind CASE_CHAIN; doing this will
enable swapping out the TREE_CHAIN for a TREE_OPERAND at a later point.

-Nathan

* tree.h (CASE_CHAIN): Define.
* tree-cfg.c (edge_to_cases_cleanup, get_cases_for_edge): Use it.
(gimple_redirect_edge_and_branch): Likewise.

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 1f533a3..bdce4cb 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -838,8 +838,8 @@ edge_to_cases_cleanup (const void *key ATTRIBUTE_UNUSED, 
void **value,
 
   for (t = (tree) *value; t; t = next)
 {
-  next = TREE_CHAIN (t);
-  TREE_CHAIN (t) = NULL;
+  next = CASE_CHAIN (t);
+  CASE_CHAIN (t) = NULL;
 }
 
   *value = NULL;
@@ -922,7 +922,7 @@ get_cases_for_edge (edge e, gimple t)
   /* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create
 a new chain.  */
   slot = pointer_map_insert (edge_to_cases, this_edge);
-  TREE_CHAIN (elt) = (tree) *slot;
+  CASE_CHAIN (elt) = (tree) *slot;
   *slot = elt;
 }
 
@@ -4900,7 +4900,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
  {
last = cases;
CASE_LABEL (cases) = label;
-   cases = TREE_CHAIN (cases);
+   cases = CASE_CHAIN (cases);
  }
 
/* If there was already an edge in the CFG, then we need
@@ -4909,8 +4909,8 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
  {
tree cases2 = get_cases_for_edge (e2, stmt);
 
-   TREE_CHAIN (last) = TREE_CHAIN (cases2);
-   TREE_CHAIN (cases2) = first;
+   CASE_CHAIN (last) = CASE_CHAIN (cases2);
+   CASE_CHAIN (cases2) = first;
  }
bitmap_set_bit (touched_switch_bbs, gimple_bb (stmt)->index);
  }
diff --git a/gcc/tree.h b/gcc/tree.h
index 35479f9..58b3b9d 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1689,6 +1689,7 @@ extern void protected_set_expr_location (tree, 
location_t);
 #define CASE_LOW(NODE) TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 0)
 #define CASE_HIGH(NODE)TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 1)
 #define CASE_LABEL(NODE)   TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 2)
+#define CASE_CHAIN(NODE)   TREE_CHAIN (CASE_LABEL_EXPR_CHECK 
(NODE))
 
 /* The operands of a TARGET_MEM_REF.  Operands 0 and 1 have to match
corresponding MEM_REF operands.  */
-- 
1.7.0.4



[PATCH 08/18] convert cp *FOR_STMTs to use private scope fields

2011-03-10 Thread Nathan Froyd
C++'s FOR_STMT and RANGE_FOR_STMT store the scope in which they occur in
the TREE_CHAIN field of tree_exp.  If we're going to remove TREE_CHAIN,
that won't work very well.  This patch introduces an extra tree operand
to both tree kinds, accessor macros for those operands, and tweaks the
code to use those macros instead of TREE_CHAIN.  The end result is nicer
code and less reliance on TREE_CHAIN.

-Nathan

gcc/cp/
* cp-tree.def (FOR_STMT, RANGE_FOR_STMT): Add an extra operand.
* cp-objcp-common.c (cp_common_init_ts): Mark them as TS_TYPED.
* cp-tree.h (FOR_SCOPE, RANGE_FOR_SCOPE): Define.
* semantics.c (begin_for_stmt): Pass an extra arg to build_stmt.
Use FOR_SCOPE instead of TREE_CHAIN.
(begin_range_for_stmt): Likewise, with RANGE_FOR_SCOPE.
(finish_for_stmt): Likewise.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 66d2d27..21fa57f 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -234,7 +234,6 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
   MARK_TS_COMMON (OVERLOAD);
   MARK_TS_COMMON (TEMPLATE_INFO);
-  MARK_TS_COMMON (FOR_STMT);
   MARK_TS_COMMON (TYPENAME_TYPE);
   MARK_TS_COMMON (TYPEOF_TYPE);
   MARK_TS_COMMON (IF_STMT);
@@ -245,8 +244,9 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
-  MARK_TS_COMMON (RANGE_FOR_STMT);
 
+  MARK_TS_TYPED (FOR_STMT);
+  MARK_TS_TYPED (RANGE_FOR_STMT);
   MARK_TS_TYPED (AGGR_INIT_EXPR);
   MARK_TS_TYPED (EXPR_STMT);
   MARK_TS_TYPED (EH_SPEC_BLOCK);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 509d5e7..fdfe9b5 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -291,12 +291,12 @@ DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3)
 
 /* Used to represent a `for' statement. The operands are
FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively.  */
-DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 4)
+DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5)
 
 /* Used to represent a range-based `for' statement. The operands are
-   RANGE_FOR_DECL, RANGE_FOR_EXPR, RANGE_FOR_BODY, respectively.  Only used
-   in templates.  */
-DEFTREECODE (RANGE_FOR_STMT, "range_for_stmt", tcc_statement, 3)
+   RANGE_FOR_DECL, RANGE_FOR_EXPR, RANGE_FOR_BODY, and RANGE_FOR_SCOPE,
+   respectively.  Only used in templates.  */
+DEFTREECODE (RANGE_FOR_STMT, "range_for_stmt", tcc_statement, 4)
 
 /* Used to represent a 'while' statement. The operands are WHILE_COND
and WHILE_BODY, respectively.  */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 1783915..e542388 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3799,12 +3799,14 @@ more_aggr_init_expr_args_p (const 
aggr_init_expr_arg_iterator *iter)
 #define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
 #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
 #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
+#define FOR_SCOPE(NODE)TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
 
 /* RANGE_FOR_STMT accessors. These give access to the declarator,
-   expression and body of the statement, respectively.  */
+   expression, body, and scope of the statement, respectively.  */
 #define RANGE_FOR_DECL(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
 #define RANGE_FOR_EXPR(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
 #define RANGE_FOR_BODY(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
+#define RANGE_FOR_SCOPE(NODE)  TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
 
 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 4af007d..c8e5619 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -856,7 +856,7 @@ begin_for_stmt (tree scope, tree init)
   tree r;
 
   r = build_stmt (input_location, FOR_STMT, NULL_TREE, NULL_TREE,
- NULL_TREE, NULL_TREE);
+ NULL_TREE, NULL_TREE, NULL_TREE);
 
   if (scope == NULL_TREE)
 {
@@ -865,7 +865,7 @@ begin_for_stmt (tree scope, tree init)
scope = begin_for_scope (&init);
 }
   FOR_INIT_STMT (r) = init;
-  TREE_CHAIN (r) = scope;
+  FOR_SCOPE (r) = scope;
 
   return r;
 }
@@ -940,8 +940,12 @@ finish_for_stmt (tree for_stmt)
   /* Pop the scope for the body of the loop.  */
   if (flag_new_for_scope > 0)
 {
-  tree scope = TREE_CHAIN (for_stmt);
-  TREE_CHAIN (for_stmt) = NULL;
+  tree scope;
+  tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT
+? &RANGE_FOR_SCOPE (for_stmt)
+: &FOR_SCOPE (for_stmt));
+  scope = *scope_ptr;
+  *scope_ptr = NULL;
   add_stmt (do_poplevel (scope));
 }
 
@@ -959,7 +963,7 @@ begin_range_for_stmt (tree scope, tree init)
   tree r;

[PATCH 10/18] convert cp SWITCH_STMTs to use private scope fields

2011-03-10 Thread Nathan Froyd
Just like the previous patches, except with SWITCH_STMT.

-Nathan

gcc/cp/
* cp-tree.def (SWITCH_STMT): Add an extra operand.
* cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED.
* cp-tree.h (SWITCH_STMT_SCOPE): Define.
* semantics.c (begin_switch__stmt): Pass scope to build_stmt.
(finish_switch_stmt): Use SWITCH_STMT_SCOPE instead of TREE_CHAIN.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index d602dfe..57358b1 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -237,13 +237,13 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (TYPENAME_TYPE);
   MARK_TS_COMMON (TYPEOF_TYPE);
   MARK_TS_COMMON (BASELINK);
-  MARK_TS_COMMON (SWITCH_STMT);
   MARK_TS_COMMON (TYPE_PACK_EXPANSION);
   MARK_TS_COMMON (EXPR_PACK_EXPANSION);
   MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
 
+  MARK_TS_TYPED (SWITCH_STMT);
   MARK_TS_TYPED (IF_STMT);
   MARK_TS_TYPED (FOR_STMT);
   MARK_TS_TYPED (RANGE_FOR_STMT);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 59f89b8..42840a8 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -313,8 +313,9 @@ DEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0)
 DEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0)
 
 /* Used to represent a 'switch' statement. The operands are
-   SWITCH_STMT_COND, SWITCH_STMT_BODY and SWITCH_STMT_TYPE, respectively.  */
-DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 3)
+   SWITCH_STMT_COND, SWITCH_STMT_BODY, SWITCH_STMT_TYPE, and
+   SWITCH_STMT_SCOPE, respectively.  */
+DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 4)
 
 /* Used to represent an expression statement.  Use `EXPR_STMT_EXPR' to
obtain the expression.  */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 2340812..3249ef0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3812,6 +3812,7 @@ more_aggr_init_expr_args_p (const 
aggr_init_expr_arg_iterator *iter)
 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
 #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
+#define SWITCH_STMT_SCOPE(NODE)TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 
3)
 
 /* STMT_EXPR accessor.  */
 #define STMT_EXPR_STMT(NODE)   TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0)
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 4071494..689ad00 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1018,10 +1018,9 @@ begin_switch_stmt (void)
 {
   tree r, scope;
 
-  r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, 
NULL_TREE);
-
   scope = do_pushlevel (sk_block);
-  TREE_CHAIN (r) = scope;
+  r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, 
NULL_TREE, scope);
+
   begin_cond (&SWITCH_STMT_COND (r));
 
   return r;
@@ -1077,8 +1076,8 @@ finish_switch_stmt (tree switch_stmt)
   pop_switch ();
   finish_stmt ();
 
-  scope = TREE_CHAIN (switch_stmt);
-  TREE_CHAIN (switch_stmt) = NULL;
+  scope = SWITCH_STMT_SCOPE (switch_stmt);
+  SWITCH_STMT_SCOPE (switch_stmt) = NULL;
   add_stmt (do_poplevel (scope));
 }
 
-- 
1.7.0.4



[PATCH 07/18] generalize build_case_label to the rest of the compiler

2011-03-10 Thread Nathan Froyd
If we're going to add another TREE_OPERAND to CASE_LABEL_EXPR, then we'd
have to update a number of calls to buildN or similar to know about the
new operand.  But that's not a good idea; the new operand is a strictly
private thing and FEs in particular shouldn't have to know anything
about it.  Instead, define a build_case_label that accepts the current
three operands CASE_LABEL_EXPR requires; build_case_label can then be
updated later.  (Actually, since it can use CASE_CHAIN, it doesn't have
to be updated at all!)

This patch does lose location information on CASE_LABEL_EXPRs from the C
family of front-ends; it did not seem worth it to have a number of
places pass input_location when said information isn't even used.  I'm
happy to add the location_t argument back to CASE_LABEL_EXPRs if people
think that's worthwhile.

-Nathan

gcc/ada/
* gcc-interface/trans.c (Case_Statement_to_gnu): Call build_case_label.

gcc/
* except.c (sjlj_emit_dispatch_table): Call build_case_label.
* gimplify.c (gimplify_switch_expr): Likewise.
* omp-low.c (expand_omp_sections): Likewise.
* tree-eh.c (lower_try_finally_switch): Likewise.
(lower_eh_dispatch): Likewise.
* tree.h (build_case_label): Declare.
* tree.c (build_case_label): Define.

gcc/c-family/
* c-common.c (c_add_case_label): Omit the loc argument to
build_case_label.
* c-common.h (build_case_label): Remove.
* c-semantics.c (build_case_label): Remove.

gcc/cp/
* decl.c (finish_case_label): Omit the loc argument to
build_case_label.

gcc/fortran/
* trans-decl.c (gfc_trans_entry_master_switch): Call build_case_label.
* trans-io.c (add_case): Likewise.
* trans-stmt.c (gfc_trans_integer_select): Likewise.
(gfc_trans_character_select): Likewise.

gcc/java/
* expr.c (expand_java_switch): Call build_case_label.
(expand_java_add_case): Likewise.

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index e438960..90220f2 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -2047,9 +2047,8 @@ Case_Statement_to_gnu (Node_Id gnat_node)
  if ((!gnu_low || TREE_CODE (gnu_low) == INTEGER_CST)
  && (!gnu_high || TREE_CODE (gnu_high) == INTEGER_CST))
{
- add_stmt_with_node (build3
- (CASE_LABEL_EXPR, void_type_node,
-  gnu_low, gnu_high,
+ add_stmt_with_node (build_case_label
+ (gnu_low, gnu_high,
   create_artificial_label (input_location)),
  gnat_choice);
  choices_added_p = true;
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 7207335..da859ec 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5298,7 +5298,7 @@ c_add_case_label (location_t loc, splay_tree cases, tree 
cond, tree orig_type,
 }
 
   /* Add a CASE_LABEL to the statement-tree.  */
-  case_label = add_stmt (build_case_label (loc, low_value, high_value, label));
+  case_label = add_stmt (build_case_label (low_value, high_value, label));
   /* Register this case label in the splay tree.  */
   splay_tree_insert (cases,
 (splay_tree_key) low_value,
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 7e4f0a1..382d535 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -829,7 +829,6 @@ extern void warn_for_omitted_condop (location_t, tree);
 
 extern tree do_case (location_t, tree, tree);
 extern tree build_stmt (location_t, enum tree_code, ...);
-extern tree build_case_label (location_t, tree, tree, tree);
 extern tree build_real_imag_expr (location_t, enum tree_code, tree);
 
 /* These functions must be defined by each front-end which implements
diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c
index 0f9f51e..a5bd9ba 100644
--- a/gcc/c-family/c-semantics.c
+++ b/gcc/c-family/c-semantics.c
@@ -131,15 +131,6 @@ build_stmt (location_t loc, enum tree_code code, ...)
   return ret;
 }
 
-/* Create a CASE_LABEL_EXPR tree node and return it.  */
-
-tree
-build_case_label (location_t loc,
- tree low_value, tree high_value, tree label_decl)
-{
-  return build_stmt (loc, CASE_LABEL_EXPR, low_value, high_value, label_decl);
-}
-
 /* Build a REALPART_EXPR or IMAGPART_EXPR, according to CODE, from ARG.  */
 
 tree
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 14d530a..6ff6974 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2933,7 +2933,7 @@ finish_case_label (location_t loc, tree low_value, tree 
high_value)
   /* For templates, just add the case label; we'll do semantic
 analysis at instantiation-time.  */
   label = build_decl (loc, LABEL_DECL, NULL_TREE, NULL_TREE);
-  return add_stmt (build_case_label (loc, low_value, high_value, label));
+ 

[PATCH 13/18] move TS_EXP to be a substructure of TS_TYPED

2011-03-10 Thread Nathan Froyd
After all that, we can finally make tree_exp inherit from typed_tree.
Quite anticlimatic.

-Nathan

gcc/
* tree.h (struct tree_exp): Inherit from struct typed_tree.
* tree.c (initialize_tree_contains_struct): Mark TS_EXP as TS_TYPED
instead of TS_COMMON.

diff --git a/gcc/tree.c b/gcc/tree.c
index d63e7d5..16100a6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -378,6 +378,7 @@ initialize_tree_contains_struct (void)
case TS_COMPLEX:
case TS_SSA_NAME:
case TS_CONSTRUCTOR:
+   case TS_EXP:
  MARK_TS_TYPED (code);
  break;
 
@@ -386,7 +387,6 @@ initialize_tree_contains_struct (void)
case TS_TYPE:
case TS_LIST:
case TS_VEC:
-   case TS_EXP:
case TS_BLOCK:
case TS_BINFO:
case TS_STATEMENT_LIST:
diff --git a/gcc/tree.h b/gcc/tree.h
index c81186a..461674c 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1905,7 +1905,7 @@ enum omp_clause_default_kind
   (OMP_CLAUSE_SUBCODE_CHECK (NODE, 
OMP_CLAUSE_DEFAULT)->omp_clause.subcode.default_kind)
 
 struct GTY(()) tree_exp {
-  struct tree_common common;
+  struct typed_tree typed;
   location_t locus;
   tree block;
   tree GTY ((special ("tree_exp"),



[PATCH 16/18] make TS_IDENTIFIER be a substructure of TS_BASE

2011-03-10 Thread Nathan Froyd
Now that we've done the requisite surgery on the C++ FE, we can
eliminate TREE_CHAIN and TREE_TYPE from IDENTIFIER_NODEs.  Doing so
turns up a couple different places that need to be tweaked.

The bit I'm not quite sure about is free_lang_data_in_decl and
find_decls_types_r.  Previously, due to C++ FE machinations, we'd free
REAL_IDENTIFIER_TYPE_VALUE naturally, through punning of TREE_TYPE.  Now
that we've shuffled that field into lang_identifier, that bit of
identifiers won't get freed...and I don't know if that causes problems.
Anybody more knowledgeable than I willing to weigh in on that?

-Nathan

gcc/
* print-tree.c (print_node): Check for TS_TYPED structures before
accessing TREE_TYPE.
* tree.h (struct tree_identifier): Inherit from tree_base, not
tree_common.
(HT_IDENT_TO_GCC_IDENT): Adjust for said change.
* tree.c (initialize_tree_contains_struct): Mark TS_IDENTIFIER as
TS_BASE instead of TS_COMMON.
(free_lang_data_in_decl): Don't set TREE_TYPE of DECL_NAME.
(find_decls_types_r): Check for TS_TYPED structures before accessing
TREE_TYPE.
* varasm.c (assemble_name): Remove assert.

gcc/c-family/
* c-common.h (struct c_common_identifier): Inherit from tree_base,
not tree_common.

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index e7fe209..961dea7 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -306,7 +306,7 @@ enum c_tree_index
 /* Identifier part common to the C front ends.  Inherits from
tree_identifier, despite appearances.  */
 struct GTY(()) c_common_identifier {
-  struct tree_common common;
+  struct tree_base base;
   struct cpp_hashnode node;
 };
 
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index d8acd1b..1a1e33f 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -321,7 +321,7 @@ print_node (FILE *file, const char *prefix, tree node, int 
indent)
   if (indent <= 4)
print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
 }
-  else
+  else if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
 {
   print_node (file, "type", TREE_TYPE (node), indent + 4);
   if (TREE_TYPE (node))
diff --git a/gcc/tree.c b/gcc/tree.c
index 81ee05e..001e8c8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -366,6 +366,7 @@ initialize_tree_contains_struct (void)
   switch (ts_code)
{
case TS_TYPED:
+   case TS_IDENTIFIER:
  MARK_TS_BASE (code);
  break;
 
@@ -383,7 +384,6 @@ initialize_tree_contains_struct (void)
  MARK_TS_TYPED (code);
  break;
 
-   case TS_IDENTIFIER:
case TS_DECL_MINIMAL:
case TS_TYPE:
case TS_LIST:
@@ -4495,10 +4495,6 @@ free_lang_data_in_decl (tree decl)
   TREE_LANG_FLAG_5 (decl) = 0;
   TREE_LANG_FLAG_6 (decl) = 0;
 
-  /* Identifiers need not have a type.  */
-  if (DECL_NAME (decl))
-TREE_TYPE (DECL_NAME (decl)) = NULL_TREE;
-
   free_lang_data_in_one_sizepos (&DECL_SIZE (decl));
   free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl));
   if (TREE_CODE (decl) == FIELD_DECL)
@@ -4795,7 +4791,8 @@ find_decls_types_r (tree *tp, int *ws, void *data)
   fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld);
 }
 
-  fld_worklist_push (TREE_TYPE (t), fld);
+  if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPED))
+fld_worklist_push (TREE_TYPE (t), fld);
 
   return NULL_TREE;
 }
diff --git a/gcc/tree.h b/gcc/tree.h
index c81186a..f4d18f8 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1529,11 +1529,11 @@ struct GTY(()) tree_vector {
pointer, and vice versa.  */
 
 #define HT_IDENT_TO_GCC_IDENT(NODE) \
-  ((tree) ((char *) (NODE) - sizeof (struct tree_common)))
+  ((tree) ((char *) (NODE) - sizeof (struct tree_base)))
 #define GCC_IDENT_TO_HT_IDENT(NODE) (&((struct tree_identifier *) (NODE))->id)
 
 struct GTY(()) tree_identifier {
-  struct tree_common common;
+  struct tree_base base;
   struct ht_identifier id;
 };
 
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 76675cd..4c429de 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2300,7 +2300,6 @@ assemble_name (FILE *file, const char *name)
   ultimate_transparent_alias_target (&id);
   if (id != id_orig)
name = IDENTIFIER_POINTER (id);
-  gcc_assert (! TREE_CHAIN (id));
 }
 
   assemble_name_raw (file, name);
-- 
1.7.0.4



[PATCH 14/18] move TS_STATEMENT_LIST to be a substructure of TS_TYPED

2011-03-10 Thread Nathan Froyd
STATEMENT_LISTs use TREE_CHAIN for approximately nothing, so let's try
to shrink them.  This patch involves quite a bit of refactoring in the C
and C++ FEs, as they used TREE_CHAIN to hold a stack of STATEMENT_LISTs
being built.  Most of the noise comes from unifying the checking macro
name between the C FE and the C++ FE.  The new checks in add_stmt are
required to make sure that cur_stmt_list can always point at something
when calling append_to_statement_list_force.

I would have liked to remove TREE_TYPE, too; I tried, but doing so was
leading to lots of ugly hacks, so I postponed that for a different day.

-Nathan

gcc/
* c-decl.c (c_push_function_context): Copy the current statement
list stack.
(add_stmt): Check building_stmt_list_p and push_stmt if necessary.
(finish_struct): Call building_stmt_list_p instead of checking
cur_stmt_list.
* c-parser.c (c_parser_postfix_expression): Likewise.
* c-typeck.c (c_end_compound_stmt): Likewise.
* print-tree.c (print_node) [STATEMENT_LIST]: Don't print TREE_CHAIN.
* tree-iterator.c (stmt_list_cache): Change to a VEC.
(alloc_stmt_list): Adjust for stmt_list_cache's new type.
(free_stmt_list): Likewise.
* tree.h (struct tree_statement_list): Include typed_tree instead
of tree_common.
* tree.c (initialize_tree_contains_struct): Mark TS_STATEMENT_LIST
as TS_TYPED instead of TS_COMMON.

gcc/c-family/
* c-common.h (struct stmt_tree_s) [x_cur_stmt_list]: Change to a VEC.
(stmt_list_stack): Define.
(cur_stmt_list): Adjust for new type of x_cur_stmt_list.
* c-semantics.c (push_stmt_list, pop_stmt_list): Likewise.

gcc/cp/
* cp-tree.h (building_stmt_tree): Delete.
* decl.c (save_function_data): Tweak initializer for x_cur_stmt_list.
(build_aggr_init_full_exprs): Call building_stmt_list_p
instead of building_stmt_tree.
(initialize_local_var): Likewise.
(finish_function): Likewise.
* decl2.c (finish_anon_union): Likewise.
* init.c (begin_init_stmts): Likewise.
(finish_init_stmts): Likewise.
(expand_aggr_init_1): Likewise.
* name-lookup.c (do_local_using_decl): Likewise.
(do_namespace_alias): Likewise.
(do_using_directive): Likewise.
(cp_emit_debug_info_for_using): Likewise.
* semantics.c (add_stmt): Check building_stmt_list_p and push_stmt
if necessary.

diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 14aef5f..9b87608 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -556,6 +556,8 @@ add_stmt (tree t)
 
   /* Add T to the statement-tree.  Non-side-effect statements need to be
  recorded during statement expressions.  */
+  if (!building_stmt_list_p ())
+push_stmt_list ();
   append_to_statement_list_force (t, &cur_stmt_list);
 
   return t;
@@ -7213,7 +7215,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, 
tree attributes,
   /* If we're inside a function proper, i.e. not file-scope and not still
  parsing parameters, then arrange for the size of a variable sized type
  to be bound now.  */
-  if (cur_stmt_list && variably_modified_type_p (t, NULL_TREE))
+  if (building_stmt_list_p () && variably_modified_type_p (t, NULL_TREE))
 add_stmt (build_stmt (loc,
  DECL_EXPR, build_decl (loc, TYPE_DECL, NULL, t)));
 
@@ -8461,6 +8463,8 @@ c_push_function_context (void)
   cfun->language = p;
 
   p->base.x_stmt_tree = c_stmt_tree;
+  c_stmt_tree.x_cur_stmt_list
+= VEC_copy (tree, gc, c_stmt_tree.x_cur_stmt_list);
   p->x_break_label = c_break_label;
   p->x_cont_label = c_cont_label;
   p->x_switch_stack = c_switch_stack;
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 382d535..e7fe209 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -451,8 +451,8 @@ typedef enum ref_operator {
 /* Information about a statement tree.  */
 
 struct GTY(()) stmt_tree_s {
-  /* The current statement list being collected.  */
-  tree x_cur_stmt_list;
+  /* A stack of statement lists being collected.  */
+  VEC(tree,gc) *x_cur_stmt_list;
 
   /* In C++, Nonzero if we should treat statements as full
  expressions.  In particular, this variable is no-zero if at the
@@ -482,11 +482,17 @@ struct GTY(()) c_language_function {
   struct stmt_tree_s x_stmt_tree;
 };
 
+#define stmt_list_stack (current_stmt_tree ()->x_cur_stmt_list)
+
 /* When building a statement-tree, this is the current statement list
-   being collected.  It's TREE_CHAIN is a back-pointer to the previous
-   statement list.  */
+   being collected.  We define it in this convoluted way, rather than
+   using VEC_last, because it must be an lvalue.  */
+
+#define cur_stmt_list  \
+  (*(VEC_address (tree, stmt_list_stack)   \
+ + VEC_length (tree, stmt_list_stack) - 1))
 
-#define cur_stmt_

[PATCH 15/18] move REAL_IDENTIFIER_TYPE_VALUE to be a field of lang_identifier

2011-03-10 Thread Nathan Froyd
IDENTIFIER_NODE is next up for a shrinking.  To do that, though, we have
to do some surgery on the C++ FE, as it uses TREE_TYPE (!) of such nodes
to store local data.  Fortunately, we can move that information into
lang_identifier; unfortunately, that means we need to introduce a number
of conditionals because the punning of TREE_TYPE no longer works.  On
the plus side, it's much more obvious where REAL_IDENTIFIER_TYPE_VALUE
was supposed to be used, as it was used inconsistently before.

I'm not overly fond of the conditionals (especially in error_operand_p)
but I don't think it's reasonable to make IDENTIFIER_NODE bigger and
penalize the other FEs just because the C++ FE is playing games with
TREE_TYPE.  I'm open to suggestions of how to avoid some of the
ugliness.  There's also one small potential problem with doing this that
I'll mention in the next patch.

-Nathan

gcc/cp/
* cp-tree.h (struct lang_identifier): Add local_class_scope_type
field.
(REAL_IDENTIFIER_TYPE_VALUE): Use that field, rather than TREE_TYPE.
(SET_IDENTIFIER_TYPE_VALUE): Use REAL_IDENTIFIER_TYPE_VALUE rather
than TREE_TYPE.
(error_operand_p): Make special check for IDENTIFIER_NODE.
(DECL_CONV_FN_TYPE): Use REAL_IDENTIFIER_TYPE_VALUE.
* decl.c (cp_finish_decl, grok_op_properties): Likewise.
(compute_array_index_type): Check for IDENTIFIER_NODE.
* decl2.c (constrain_visibility_for_template): Likewise.
(determine_visibility): Use REAL_IDENTIFIER_TYPE_VALUE.
(import_export_decl): Likewise.
* error.c (dump_decl): Likewise.
* mangle.c (write_template_prefix): Check for IDENTIFIER_NODE.
Refactor to only check once.
(write_unqualified_id): Use REAL_IDENTIFIER_TYPE_VALUE.
(hash_type): Likewise.
(compare_type): Likewise.
(mangle_conv_op_name_for_type): Likewise.
* name-lookup.c (do_class_using_decl): Likewise.
(find_parameter_packs_r): Likewise.
(lookup_template_function): Check for IDENTIFIER_NODE.
(any_template_arguments_need_structural_equality_p): Likewise.
(tsubst_identifier): New function.
(tsubst_copy, tsubst_copy_and_build): Call it.
* repo.c (repo_emit_p): Use REAL_IDENTIFIER_TYPE_VALUE.
* rtti.c (get_tinfo_decl, tinfo_base_init): Likewise.
(emit_tinfo_decl): Likewise.
* search.c (lookup_fnfields_1): Likewise.
(lookup_member): Check for IDENTIFIER_NODE.
* semantics.c (finish_id_expression): Use REAL_IDENTIFIER_TYPE_VALUE.
(finish_id_expression): Check for IDENTIFIER_NODE.
* typeck.c (finish_class_member_access_expr): Likewise.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fd28593..a3e59b0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -222,6 +222,7 @@ struct GTY(()) lang_identifier {
   cxx_binding *bindings;
   tree class_template_info;
   tree label_value;
+  tree local_class_scope_type;
 };
 
 /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
@@ -448,13 +449,15 @@ typedef enum impl_conv_void {
 #define IDENTIFIER_BINDING(NODE) \
   (LANG_IDENTIFIER_CAST (NODE)->bindings)
 
-/* TREE_TYPE only indicates on local and class scope the current
-   type. For namespace scope, the presence of a type in any namespace
-   is indicated with global_type_node, and the real type behind must
-   be found through lookup.  */
+/* For namespace scope, the presence of a type in any namespace is
+   indicated with global_type_node, and the real type behind must be
+   found through lookup.  For local and class scope, we can grab the
+   type from the identifier directly.  */
 #define IDENTIFIER_TYPE_VALUE(NODE) identifier_type_value (NODE)
-#define REAL_IDENTIFIER_TYPE_VALUE(NODE) TREE_TYPE (NODE)
-#define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
+#define REAL_IDENTIFIER_TYPE_VALUE(NODE) \
+  (LANG_IDENTIFIER_CAST (NODE)->local_class_scope_type)
+#define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) \
+  (REAL_IDENTIFIER_TYPE_VALUE (NODE) = (TYPE))
 #define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
 
 #define IDENTIFIER_LABEL_VALUE(NODE) \
@@ -1104,7 +1107,10 @@ struct GTY(()) language_function {
 
 #define error_operand_p(NODE)  \
   ((NODE) == error_mark_node   \
-   || ((NODE) && TREE_TYPE ((NODE)) == error_mark_node))
+|| ((NODE) \
+   && ((TREE_CODE (NODE) == IDENTIFIER_NODE\
+? REAL_IDENTIFIER_TYPE_VALUE (NODE)\
+: TREE_TYPE (NODE)) == error_mark_node)))
 
 /* TRUE if a tree code represents a statement.  */
 extern bool statement_code_p[MAX_TREE_CODES];
@@ -2121,8 +2127,10 @@ struct GTY((variable_size)) lang_decl {
 
 /* If FN is a conversion operator, the type to which it converts.
Otherwise, NULL_TREE.  */
-#define DECL_CONV_FN_T

[PATCH 09/18] convert cp IF_STMTs to use private scope fields

2011-03-10 Thread Nathan Froyd
Just like the previous *FOR_STMT conversions, except with IF_STMTs.

-Nathan

gcc/cp/
* cp-tree.def (IF_STMT): Add an extra operand.
* cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED.
* cp-tree.h (IF_SCOPE): Define.
* semantics.c (begin_if_stmt): Pass scope to build_stmt.
(finish_if_stmt): Use IF_SCOPE instead of TREE_CHAIN.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 21fa57f..d602dfe 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -236,7 +236,6 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (TEMPLATE_INFO);
   MARK_TS_COMMON (TYPENAME_TYPE);
   MARK_TS_COMMON (TYPEOF_TYPE);
-  MARK_TS_COMMON (IF_STMT);
   MARK_TS_COMMON (BASELINK);
   MARK_TS_COMMON (SWITCH_STMT);
   MARK_TS_COMMON (TYPE_PACK_EXPANSION);
@@ -245,6 +244,7 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
 
+  MARK_TS_TYPED (IF_STMT);
   MARK_TS_TYPED (FOR_STMT);
   MARK_TS_TYPED (RANGE_FOR_STMT);
   MARK_TS_TYPED (AGGR_INIT_EXPR);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index fdfe9b5..59f89b8 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -284,10 +284,10 @@ DEFTREECODE (MUST_NOT_THROW_EXPR, "must_not_throw_expr", 
tcc_expression, 1)
 DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", tcc_statement, 3)
 
 /* Represents an 'if' statement. The operands are IF_COND,
-   THEN_CLAUSE, and ELSE_CLAUSE, respectively.  */
+   THEN_CLAUSE, and ELSE_CLAUSE, and the current scope, respectively.  */
 /* ??? It is currently still necessary to distinguish between IF_STMT
and COND_EXPR for the benefit of templates.  */
-DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3)
+DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 4)
 
 /* Used to represent a `for' statement. The operands are
FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively.  */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e542388..2340812 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3781,6 +3781,7 @@ more_aggr_init_expr_args_p (const 
aggr_init_expr_arg_iterator *iter)
 #define IF_COND(NODE)  TREE_OPERAND (IF_STMT_CHECK (NODE), 0)
 #define THEN_CLAUSE(NODE)  TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
 #define ELSE_CLAUSE(NODE)  TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
+#define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3)
 
 /* WHILE_STMT accessors. These give access to the condition of the
while statement and the body of the while statement, respectively.  */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c8e5619..4071494 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -662,8 +662,8 @@ begin_if_stmt (void)
 {
   tree r, scope;
   scope = do_pushlevel (sk_block);
-  r = build_stmt (input_location, IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
-  TREE_CHAIN (r) = scope;
+  r = build_stmt (input_location, IF_STMT, NULL_TREE,
+ NULL_TREE, NULL_TREE, scope);
   begin_cond (&IF_COND (r));
   return r;
 }
@@ -711,8 +711,8 @@ finish_else_clause (tree if_stmt)
 void
 finish_if_stmt (tree if_stmt)
 {
-  tree scope = TREE_CHAIN (if_stmt);
-  TREE_CHAIN (if_stmt) = NULL;
+  tree scope = IF_SCOPE (if_stmt);
+  IF_SCOPE (if_stmt) = NULL;
   add_stmt (do_poplevel (scope));
   finish_stmt ();
 }
-- 
1.7.0.4



[PATCH 02/18] enforce TREE_CHAIN and TREE_TYPE accesses

2011-03-10 Thread Nathan Froyd
Now that we have a structure where not every node might include
TREE_CHAIN or TREE_TYPE, we need to make sure that when we call said
accessors that the argument is properly typed.  This requires a number
of changes:

- It's not enough for FEs to assume that FE-specific DECLs are the only
  tree that needs to be marked specially; we need to mark things as
  TS_TYPED or TS_COMMON.

- To facilitate doing so, move the MARK_* macros for initializing
  tree_contains_struct to tree.h so they are accessible to FEs.

- Additionally, rearrange *_init_ts methods for the C-family languages
  so that we can share code where code needs to be shared.

- Finally, various places need to check for TS_COMMON structure before
  blindly calling TREE_CHAIN.

-Nathan

gcc/ada/
* gcc-interface/ada-tree.h (union lang_tree_node): Check for
TS_COMMON before calling TREE_CHAIN.
* gcc-interface/misc.c (gnat_init_ts): New function.
(LANG_HOOKS_INIT_TS): Define.

gcc/
* c-decl.c (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.
* print-tree.c (print_node): Likewise.
* tree-inline.c (copy_tree_r): Likewise.
* c-lang.c (LANG_HOOKS_INIT_TS): Define.
* lto-streamer-in.c (lto_input_tree_pointers): Check for TS_TYPED
instead of TS_COMMON.
* lto-streamer-out.c (lto_output_tree_pointers): Likewise.
* tree.c (initialize_tree_contains_struct): Handle TS_TYPED.
(copy_node_stat): Zero TREE_CHAIN only if necessary.
(MARK_TS_BASE, MARK_TS_TYPED, MARK_TS_COMMON): Move these...
(MARK_TS_DECL_COMMON, MARK_TS_DECL_COMMON, MARK_TS_DECL_WRTL):
...and these...
(MARK_TS_DECL_WITH_VIS, MARK_TS_DECL_NON_COMMON): ...and these...
* tree.h: ...here.
(TREE_CHAIN): Check for a TS_COMMON structure.
(TREE_TYPE): Check for a TS_TYPED structure.

gcc/c-family/
* c-common.h (c_common_init_ts): Declare.
* c-common.c (c_common_init_ts): Define.

gcc/cp/
* cp-lang.c (cp_init_ts): Call cp_common_init_ts.  Move
tree_contains_struct initialization to...
* cp-objcp-common.c (cp_common_init_ts): ...here.  Use MARK_*
macros.
* cp-objcp-common.h (cp_common_init_ts): Declare.
* cp-tree.h (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.

gcc/fortran/
* f95-lang.c (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.

gcc/go/
* go-lang.c (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.

gcc/java/
* java-tree.h (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.

gcc/lto/
* lto-tree.h (union lang_tree_node): Check for TS_COMMON before
calling TREE_CHAIN.
* lto.c (lto_fixup_common): Likewise.

gcc/objc/
* objc-lang.c (objc_init_ts): Move code for this function...
* objc-act.c (objc_common_init_ts): ...here. Define.
* objc-act.h (objc_common_init_ts): Declare.

gcc/objcp/
* objcp-lang.c (objcxx_init_ts): Call objc_common_init_ts and
cp_common_init_ts.

diff --git a/gcc/ada/gcc-interface/ada-tree.h b/gcc/ada/gcc-interface/ada-tree.h
index 9002fa1..3542349 100644
--- a/gcc/ada/gcc-interface/ada-tree.h
+++ b/gcc/ada/gcc-interface/ada-tree.h
@@ -25,7 +25,7 @@
 
 /* The resulting tree type.  */
 union GTY((desc ("0"),
-  chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
+  chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), 
TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
   lang_tree_node
 {
   union tree_node GTY((tag ("0"),
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 4f7a5e1..89823ca 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -696,6 +696,20 @@ gnat_eh_personality (void)
   return gnat_eh_personality_decl;
 }
 
+/* Initialize language-specific bits of tree_contains_struct.  */
+
+static void
+gnat_init_ts (void)
+{
+  MARK_TS_COMMON (UNCONSTRAINED_ARRAY_TYPE);
+
+  MARK_TS_TYPED (UNCONSTRAINED_ARRAY_REF);
+  MARK_TS_TYPED (LOOP_STMT);
+  MARK_TS_TYPED (STMT_STMT);
+  MARK_TS_TYPED (EXIT_STMT);
+  MARK_TS_TYPED (NULL_EXPR);
+}
+
 /* Definitions for our language-specific hooks.  */
 
 #undef  LANG_HOOKS_NAME
@@ -754,6 +768,8 @@ gnat_eh_personality (void)
 #define LANG_HOOKS_EH_PERSONALITY  gnat_eh_personality
 #undef  LANG_HOOKS_DEEP_UNSHARING
 #define LANG_HOOKS_DEEP_UNSHARING  true
+#undef  LANG_HOOKS_INIT_TS
+#define LANG_HOOKS_INIT_TS gnat_init_ts
 
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index b438b06..14aef5f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -242,7 +242,7 @@ extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate
 /* The resulting tree type.  */
 
 union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"

[PATCH 11/18] mark EXPR_PACK_EXPANSION as typed only

2011-03-10 Thread Nathan Froyd
EXPR_PACK_EXPANSION nodes store things in TREE_CHAIN, for symmetry with
TYPE_PACK_EXPANSIONs.  In the interest of expendiency towards slimming
tree_exp, this patch moves EXPR_PACK_EXPANSION's use of TREE_CHAIN into
a local TREE_OPERAND.  I suppose the conditional would be needed in any
event later on...

The odd case in mangle.c is needed to avoid mangling
PACK_EXPANSION_PARAMETER_PACKS; doing so would lead to an ICE.

-Nathan

gcc/cp/
* cp-tree.def (EXPR_PACK_EXPANSION): Add an operand.
* cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED.
* cp-tree.h (PACK_EXPANSION_PARAMETER_PACKS): Use the new operand
of EXPR_PACK_EXPANSION.
* mangle.c (write_expression): Don't mangle all of EXPR_PACK_EXPANSION.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 57358b1..90a4a9b 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -238,11 +238,11 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (TYPEOF_TYPE);
   MARK_TS_COMMON (BASELINK);
   MARK_TS_COMMON (TYPE_PACK_EXPANSION);
-  MARK_TS_COMMON (EXPR_PACK_EXPANSION);
   MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
 
+  MARK_TS_TYPED (EXPR_PACK_EXPANSION);
   MARK_TS_TYPED (SWITCH_STMT);
   MARK_TS_TYPED (IF_STMT);
   MARK_TS_TYPED (FOR_STMT);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 42840a8..366013a 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -413,7 +413,7 @@ DEFTREECODE (TYPE_PACK_EXPANSION, "type_pack_expansion", 
tcc_type, 0)
 
EXPR_PACK_EXPANSION plays precisely the same role as TYPE_PACK_EXPANSION,
but will be used for expressions.  */
-DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 1)
+DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 2)
 
 /* Selects the Ith parameter out of an argument pack. This node will
be used when instantiating pack expansions; see
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3249ef0..7bdf9e0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2713,7 +2713,10 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 
 /* The list of parameter packs used in the PACK_EXPANSION_* node. The
TREE_VALUE of each TREE_LIST contains the parameter packs.  */
-#define PACK_EXPANSION_PARAMETER_PACKS(NODE) TREE_CHAIN (NODE)
+#define PACK_EXPANSION_PARAMETER_PACKS(NODE)   \
+  *(TREE_CODE (NODE) == EXPR_PACK_EXPANSION\
+? &TREE_OPERAND (NODE, 1)  \
+: &TREE_CHAIN (TYPE_PACK_EXPANSION_CHECK (NODE)))
 
 /* Determine if this is an argument pack.  */
 #define ARGUMENT_PACK_P(NODE)  \
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 4d2ace6..e4d53c5 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2653,6 +2653,10 @@ write_expression (tree expr)
  len = 2;
  break;
 
+   case EXPR_PACK_EXPANSION:
+ len = 1;
+ break;
+
default:
  len = TREE_OPERAND_LENGTH (expr);
  break;



[PATCH 17/18] introduce block_chainon and use BLOCK_CHAIN more

2011-03-10 Thread Nathan Froyd
BLOCKs have a TREE_CHAIN and a TREE_TYPE; TREE_TYPE is useless for
blocks, but we can't remove TREE_TYPE without also removing TREE_CHAIN.
This patch lays the groundwork to do just that.  It changes places that
use chainon on BLOCKs to use block_chainon, which works identically to
chainon except it uses BLOCK_CHAIN.  And it fixes up a few places that
used TREE_CHAIN when they meant BLOCK_CHAIN.

-Nathan

gcc/ada/
* gcc-interface/utils.c (gnat_poplevel): Use block_chainon.

gcc/
* function.h (block_chainon): Declare.
* function.c (block_chainon): Define.

gcc/cp/
* decl.c (poplevel): Use block_chainon.

gcc/fortran/
* f95-lang.c (poplevel): Use BLOCK_CHAIN and block_chainon.

gcc/java/
* decl.c (poplevel): Use BLOCK_CHAIN and block_chainon.

diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index eac87e0..dd06ca3 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -395,8 +395,8 @@ gnat_poplevel (void)
   else if (BLOCK_VARS (block) == NULL_TREE)
 {
   BLOCK_SUBBLOCKS (level->chain->block)
-   = chainon (BLOCK_SUBBLOCKS (block),
-  BLOCK_SUBBLOCKS (level->chain->block));
+   = block_chainon (BLOCK_SUBBLOCKS (block),
+BLOCK_SUBBLOCKS (level->chain->block));
   BLOCK_CHAIN (block) = free_block_chain;
   free_block_chain = block;
 }
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a0ef39f..de96ac2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -794,7 +794,7 @@ poplevel (int keep, int reverse, int functionbody)
 }
   else if (block)
 current_binding_level->blocks
-  = chainon (current_binding_level->blocks, block);
+  = block_chainon (current_binding_level->blocks, block);
 
   /* If we did not make a block for the level just exited,
  any blocks made for inner levels
@@ -803,7 +803,7 @@ poplevel (int keep, int reverse, int functionbody)
  of something else.  */
   else if (subblocks)
 current_binding_level->blocks
-  = chainon (current_binding_level->blocks, subblocks);
+  = block_chainon (current_binding_level->blocks, subblocks);
 
   /* Each and every BLOCK node created here in `poplevel' is important
  (e.g. for proper debugging information) so if we created one
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 687f60b..aebe397 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -444,7 +444,7 @@ poplevel (int keep, int reverse, int functionbody)
 
   /* Record the BLOCK node just built as the subblock its enclosing scope.  */
   for (subblock_node = subblock_chain; subblock_node;
-   subblock_node = TREE_CHAIN (subblock_node))
+   subblock_node = BLOCK_CHAIN (subblock_node))
 BLOCK_SUPERCONTEXT (subblock_node) = block_node;
 
   /* Clear out the meanings of the local variables of this level.  */
@@ -475,7 +475,7 @@ poplevel (int keep, int reverse, int functionbody)
   else if (block_node)
 {
   current_binding_level->blocks
-   = chainon (current_binding_level->blocks, block_node);
+   = block_chainon (current_binding_level->blocks, block_node);
 }
 
   /* If we did not make a block for the level just exited, any blocks made for
@@ -484,7 +484,7 @@ poplevel (int keep, int reverse, int functionbody)
  else.  */
   else if (subblock_chain)
 current_binding_level->blocks
-  = chainon (current_binding_level->blocks, subblock_chain);
+  = block_chainon (current_binding_level->blocks, subblock_chain);
   if (block_node)
 TREE_USED (block_node) = 1;
 
diff --git a/gcc/function.c b/gcc/function.c
index 3f721fb..094cf74 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4167,6 +4167,34 @@ blocks_nreverse (tree t)
   return prev;
 }
 
+/* Concatenate two chains of blocks (chained through BLOCK_CHAIN)
+   by modifying the last node in chain 1 to point to chain 2.  */
+
+tree
+block_chainon (tree op1, tree op2)
+{
+  tree t1;
+
+  if (!op1)
+return op2;
+  if (!op2)
+return op1;
+
+  for (t1 = op1; BLOCK_CHAIN (t1); t1 = BLOCK_CHAIN (t1))
+continue;
+  BLOCK_CHAIN (t1) = op2;
+
+#ifdef ENABLE_TREE_CHECKING
+  {
+tree t2;
+for (t2 = op2; t2; t2 = BLOCK_CHAIN (t2))
+  gcc_assert (t2 != t1);
+  }
+#endif
+
+  return op1;
+}
+
 /* Count the subblocks of the list starting with BLOCK.  If VECTOR is
non-NULL, list them all into VECTOR, in a depth-first preorder
traversal of the block tree.  Also clear TREE_ASM_WRITTEN in all
diff --git a/gcc/function.h b/gcc/function.h
index 6e7f539..73af294 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -713,6 +713,7 @@ extern void number_blocks (tree);
 
 extern void clear_block_marks (tree);
 extern tree blocks_nreverse (tree);
+extern tree block_chainon (tree, tree);
 
 /* Return size needed for stack frame based on slots so far allocated.
This size counts from zero.  It is not rounded to STACK_BOUNDARY;
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
in

[PATCH 18/18] make TS_BLOCK a substructure of TS_BASE

2011-03-10 Thread Nathan Froyd
Now that we've  encapsulated all uses of BLOCK_CHAINON properly, we can
make BLOCKs inherit from tree_base and redirect BLOCK_CHAINON to use a
tree_block-private field instead of tree_common's chain.  Doing so saves
the never-used TREE_TYPE field.

-Nathan

gcc/
* tree.c (initialize_tree_contains_struct): Mark TS_BLOCK as
TS_BASE instead of TS_COMMON.
* tree.h (struct tree_block): Inherit from tree_base, not tree_common.
Add chain field.
(BLOCK_CHAIN): Use new chain field.

gcc/c-family/
* c-common.c (warning_candidate_p): Check for BLOCKs.

gcc/java/
* decl.c (poplevel): Don't access TREE_TYPE of BLOCKs.
* expr.c (build_jni_stub): Likewise.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index da859ec..15dcd63 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -2340,6 +2340,9 @@ warning_candidate_p (tree x)
   if (DECL_P (x) && DECL_ARTIFICIAL (x))
 return 0;
 
+  if (TREE_CODE (x) == BLOCK)
+return 0;
+
   /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
  (lvalue_p) crash on TRY/CATCH. */
   if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x)))
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index 6e94dff..713b11a 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -1425,10 +1425,7 @@ poplevel (int keep, int reverse, int functionbody)
 
   block = 0;
   if (keep || functionbody)
-{
-  block = make_node (BLOCK);
-  TREE_TYPE (block) = void_type_node;
-}
+block = make_node (BLOCK);
 
   if (current_binding_level->exception_range)
 expand_end_java_handler (current_binding_level->exception_range);
@@ -1456,7 +1453,7 @@ poplevel (int keep, int reverse, int functionbody)
}
  *var = NULL;

- bind = build3 (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block), 
+ bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block), 
 BLOCK_EXPR_BODY (block), block);
  BIND_EXPR_BODY (bind) = current_binding_level->stmts;
  
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 3be1cff..b9293e0 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2649,7 +2649,6 @@ build_jni_stub (tree method)
   method_args = DECL_ARGUMENTS (method);
   block = build_block (env_var, NULL_TREE, method_args, NULL_TREE);
   TREE_SIDE_EFFECTS (block) = 1;
-  TREE_TYPE (block) = TREE_TYPE (TREE_TYPE (method));
 
   /* Compute the local `env' by calling _Jv_GetJNIEnvNewFrame.  */
   body = build2 (MODIFY_EXPR, ptr_type_node, env_var,
diff --git a/gcc/tree.c b/gcc/tree.c
index 001e8c8..3518666 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -367,6 +367,7 @@ initialize_tree_contains_struct (void)
{
case TS_TYPED:
case TS_IDENTIFIER:
+   case TS_BLOCK:
  MARK_TS_BASE (code);
  break;
 
@@ -388,7 +389,6 @@ initialize_tree_contains_struct (void)
case TS_TYPE:
case TS_LIST:
case TS_VEC:
-   case TS_BLOCK:
case TS_BINFO:
case TS_OMP_CLAUSE:
case TS_OPTIMIZATION:
diff --git a/gcc/tree.h b/gcc/tree.h
index f4d18f8..4a23c8f 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2039,9 +2039,7 @@ struct GTY(()) tree_omp_clause {
   VEC_index (tree, BLOCK_NONLOCALIZED_VARS (NODE), N)
 #define BLOCK_SUBBLOCKS(NODE) (BLOCK_CHECK (NODE)->block.subblocks)
 #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
-/* Note: when changing this, make sure to find the places
-   that use chainon or nreverse.  */
-#define BLOCK_CHAIN(NODE) TREE_CHAIN (BLOCK_CHECK (NODE))
+#define BLOCK_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.chain)
 #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
 #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag)
 
@@ -2082,7 +2080,8 @@ struct GTY(()) tree_omp_clause {
 #define BLOCK_SOURCE_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.locus)
 
 struct GTY(()) tree_block {
-  struct tree_common common;
+  struct tree_base base;
+  tree chain;
 
   unsigned abstract_flag : 1;
   unsigned block_num : 31;
-- 
1.7.0.4



[PATCH 12/18] make CASE_LABEL_EXPR not abuse TREE_CHAIN

2011-03-10 Thread Nathan Froyd
Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
see here.

-Nathan

gcc/
* tree.def (CASE_LABEL_EXPR): Add an operand.
* tree.h (CASE_CHAIN): Use TREE_OPERAND instead of TREE_CHAIN.

diff --git a/gcc/tree.def b/gcc/tree.def
index eb94ad2..9c6606d 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -863,7 +863,7 @@ DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 3)
CASE_HIGH, respectively. If CASE_LOW is NULL_TREE, the label is a
'default' label. If CASE_HIGH is NULL_TREE, the label is a normal case
label.  CASE_LABEL is the corresponding LABEL_DECL.  */
-DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 3)
+DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 4)
 
 /* Used to represent an inline assembly statement.  ASM_STRING returns a
STRING_CST for the instruction (e.g., "mov x, y"). ASM_OUTPUTS,
diff --git a/gcc/tree.h b/gcc/tree.h
index 3e1ff2c..c81186a 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1689,7 +1689,7 @@ extern void protected_set_expr_location (tree, 
location_t);
 #define CASE_LOW(NODE) TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 0)
 #define CASE_HIGH(NODE)TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 1)
 #define CASE_LABEL(NODE)   TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 2)
-#define CASE_CHAIN(NODE)   TREE_CHAIN (CASE_LABEL_EXPR_CHECK 
(NODE))
+#define CASE_CHAIN(NODE)   TREE_OPERAND (CASE_LABEL_EXPR_CHECK 
(NODE), 3)
 
 /* The operands of a TARGET_MEM_REF.  Operands 0 and 1 have to match
corresponding MEM_REF operands.  */
-- 
1.7.0.4



Re: [C++0x patch] constexpr in attribute argument

2011-03-10 Thread Jason Merrill
How about just calling maybe_constant_value call after the 
fold_non_dependent_expr call in cp_parser_parenthesized_expression_list?


Jason


Re: [PATCH 14/18] move TS_STATEMENT_LIST to be a substructure of TS_TYPED

2011-03-10 Thread Jason Merrill

On 03/10/2011 11:23 PM, Nathan Froyd wrote:

The new checks in add_stmt are
required to make sure that cur_stmt_list can always point at something
when calling append_to_statement_list_force.


Why haven't we already pushed before we get to add_stmt?

Jason


Re: RFA (layout): PATCH for c++/48029 (ICE-on-valid with templates and arrays)

2011-03-10 Thread H.J. Lu
On Wed, Mar 9, 2011 at 6:59 PM, Jason Merrill  wrote:
> In this testcase, when we first declare the myvectypes and mytype3,
> vector has not been instantiated, so we mark the array, and the
> pointer to the array, for structural equality comparison.  When we actually
> go to instantiate mytype3, we complete vector and rebuild the array
> and pointer types, and use those to look up the template specialization.
>  Which fails to find the one we already had because the new pointer type has
> TYPE_CANONICAL and therefore hashes
> differently from the one that didn't.
>
> We deal with ARRAY_TYPE specially in iterative_hash_template_arg, but that
> doesn't cover a compound type which uses an ARRAY_TYPE, such as the pointer
> in this case.
>
> The business of having an array with the same element type and domain have
> different TYPE_CANONICAL dependending on whether or not the element type is
> complete has always seemed strange and fragile to me, so I tried removing
> the relevant code from layout_type; this produced only a single test
> failure, which was fixed by changing type_hash_eq to not trust TYPE_ALIGN if
> the type isn't complete yet.  I imagine that's what Doug was talking about
> in his comment about alignment.
>
> Tested (c,c++,fortran,java,lto,objc) x86_64-pc-linux-gnu.  OK for 4.5 and
> 4.6?
>
> commit 45deb1cd5953c5730e14e00c5a8f800dadea66bd
> Author: Jason Merrill 
> Date:   Wed Mar 9 16:47:10 2011 -0500
>
>        PR c++/48029
>        * stor-layout.c (layout_type): Don't set structural equality
>        on arrays of incomplete type.
>        * tree.c (type_hash_eq): Handle comparing them properly.
>        * cp/pt.c (iterative_hash_template_arg): Remove special case for
>        ARRAY_TYPE.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48069

-- 
H.J.