[patch, fortran] Fix PR 52668, bogus warning for only list

2012-03-25 Thread Thomas Koenig

Hello world,

this fixes a 4.7/4.8 regression with a bogus warning for variables
which were excluded from being imported by "use, only" if they
were in a common block inside the module.

Regression-tested.  OK for trunk and for 4.7 after a few days?

Thomas

2012-03-25  Thomas Koenig  

PR fortran/52668
* module.c:  Only mark symbols as use_only if they have been
imported via an only list.

2012-03-25  Thomas Koenig  

PR fortran/52668
* gfortran.dg/use_only_6.f90: New test.
Index: module.c
===
--- module.c	(Revision 184854)
+++ module.c	(Arbeitskopie)
@@ -4389,9 +4389,24 @@ load_needed (pointer_info *p)
 
   /* Mark as only or rename for later diagnosis for explicitly imported
  but not used warnings; don't mark internal symbols such as __vtab,
- __def_init etc.  */
+ __def_init etc. Only mark them if they have been explicitly loaded.  */
+
   if (only_flag && sym->name[0] != '_' && sym->name[1] != '_')
-sym->attr.use_only = 1;
+{
+  gfc_use_rename *u;
+
+  /* Search the use/rename list for the variable; if the variable is
+	 found, mark it.  */
+  for (u = gfc_rename_list; u; u = u->next)
+	{
+	  if (strcmp (u->use_name, sym->name) == 0)
+	{
+	  sym->attr.use_only = 1;
+	  break;
+	}
+	}
+}
+
   if (p->u.rsym.renamed)
 sym->attr.use_rename = 1;
 
! { dg-do compile }
! PR 52668 - there used to be a bogus warning about not using b.
! Original test case by Arnaud Desitter.
module mm
  integer :: a, b
  common /mm1/ a, b
end module mm

subroutine aa()
  use mm, only: a
  implicit none
  a = 1
end subroutine aa
! { dg-final { cleanup-modules "mm" } }


New template for 'cpplib' made available

2012-03-25 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.  (If you have
any questions, send them to .)

A new POT file for textual domain 'cpplib' has been made available
to the language teams for translation.  It is archived as:

http://translationproject.org/POT-files/cpplib-4.7.0.pot

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

Below is the URL which has been provided to the translators of your
package.  Please inform the translation coordinator, at the address
at the bottom, if this information is not current:

ftp://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2

Translated PO files will later be automatically e-mailed to you.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




New template for 'gcc' made available

2012-03-25 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.  (If you have
any questions, send them to .)

A new POT file for textual domain 'gcc' has been made available
to the language teams for translation.  It is archived as:

http://translationproject.org/POT-files/gcc-4.7.0.pot

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

Below is the URL which has been provided to the translators of your
package.  Please inform the translation coordinator, at the address
at the bottom, if this information is not current:

ftp://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2

Translated PO files will later be automatically e-mailed to you.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Re: C++ PATCH to add auto return type deduction with -std=c++1y

2012-03-25 Thread Marc Glisse

On Sun, 25 Mar 2012, Jason Merrill wrote:

As I mentioned in my patch to add -std=c++1y, I've been working on a proposal 
for the next standard to support return type deduction for normal functions, 
not just lambdas.  This patch implements that proposal.


Nice. I like the way you seem to be going for the basic, uncontroversial 
version (extensions can always be discussed later), instead of trying to 
figure out something universal.


If I understand correctly, you pick the first return statement for type 
deduction, and other returns (if any) are only checked afterwards for 
exact consistency, which simplifies the problem quite a bit while still 
allowing some recursion (although interestingly, constexpr functions 
require the use of a single return with ?: whereas your auto functions 
prefer an if and several returns). Naturally, auto functions have to be 
instantiated a bit more eagerly than regular functions, and there is no 
try to sfinae the auto deduction. That seems to fit many simple functions 
quite nicely with little room for unintended consequences.


I tried to send this message before with the proposal attached in HTML, but 
the mailing list rejects HTML attachments, so I've dropped it.  I'm happy to 
send it separately to anyone interested.


I guess I'll have plenty of chances to look at it once it is submitted 
(it isn't like I'd have much to contribute...).


--
Marc Glisse


PR regression/52696

2012-03-25 Thread Jan Hubicka
Hi,
while backporting predict.c fix I forgot to backport followup fix for a typo 
causing fnsplit
test failure on some setups.

Bootstrapped/regtested and comitted.
Honza
Index: ChangeLog
===
--- ChangeLog   (revision 185774)
+++ ChangeLog   (working copy)
@@ -1,6 +1,12 @@
 2012-03-24  Jan Hubicka  
 
Backport from mainline
+   PR regression/52696
+   * predict.c (predict_paths_for_bb): Fix typo.
+   
+2012-03-24  Jan Hubicka  
+
+   Backport from mainline
PR middle-end/51737
* cgraph.c (cgraph_remove_node_and_inline_clones): Add FORBIDDEN_NODE
parameter.
Index: predict.c
===
--- predict.c   (revision 185773)
+++ predict.c   (working copy)
@@ -1832,7 +1832,7 @@ predict_paths_for_bb (basic_block cur, b
 prevent visiting given BB twice.  */
   if (found)
 predict_edge_def (e, pred, taken);
-  else if (!bitmap_set_bit (visited, e->src->index))
+  else if (bitmap_set_bit (visited, e->src->index))
predict_paths_for_bb (e->src, e->src, pred, taken, visited);
 }
   for (son = first_dom_son (CDI_POST_DOMINATORS, cur);


New German PO file for 'gcc' (version 4.7.0)

2012-03-25 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the German team of translators.  The file is available at:

http://translationproject.org/latest/gcc/de.po

(This file, 'gcc-4.7.0.de.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Re: C++ PATCH to add auto return type deduction with -std=c++1y

2012-03-25 Thread Basile Starynkevitch
On Sun, 25 Mar 2012 12:17:10 +0200 (CEST)
Marc Glisse  wrote:

> On Sun, 25 Mar 2012, Jason Merrill wrote:
> 
> > As I mentioned in my patch to add -std=c++1y, I've been working on a 
> > proposal 
> > for the next standard to support return type deduction for normal 
> > functions, 
> > not just lambdas.  This patch implements that proposal.
> 
> Nice. I like the way you seem to be going for the basic, uncontroversial 
> version (extensions can always be discussed later), instead of trying to 
> figure out something universal.
> 
> If I understand correctly, you pick the first return statement for type 
> deduction, and other returns (if any) are only checked afterwards for 
> exact consistency [...]

I am not a C++ or a GCC front-end expert, but I am not sure it is the right 
approach for
functions starting with
   if (!p) return nullptr;
where p is a formal argument.

Or perhaps I am misunderstanding what Marc is saying.

I would rather suggest using all the return statements to infer the type of the 
function,
not only the first one.

Regards.
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


Re: C++ PATCH to add auto return type deduction with -std=c++1y

2012-03-25 Thread Marc Glisse

On Sun, 25 Mar 2012, Basile Starynkevitch wrote:


On Sun, 25 Mar 2012 12:17:10 +0200 (CEST)
Marc Glisse  wrote:


On Sun, 25 Mar 2012, Jason Merrill wrote:


As I mentioned in my patch to add -std=c++1y, I've been working on a proposal
for the next standard to support return type deduction for normal functions,
not just lambdas.  This patch implements that proposal.


Nice. I like the way you seem to be going for the basic, uncontroversial
version (extensions can always be discussed later), instead of trying to
figure out something universal.

If I understand correctly, you pick the first return statement for type
deduction, and other returns (if any) are only checked afterwards for
exact consistency [...]


I am not a C++ or a GCC front-end expert, but I am not sure it is the right 
approach for
functions starting with
  if (!p) return nullptr;
where p is a formal argument.

Or perhaps I am misunderstanding what Marc is saying.

I would rather suggest using all the return statements to infer the type of the 
function,
not only the first one.


First, note that I only explained my understanding from a quick look at 
the testsuite examples and a couple minutes playing with it, the actual 
proposal may well be very different. However:


- a first goal is simple functions, with a single return statement (which 
may even often be the only statement).
- inferring a common type is very hard to define (std::common_type has a 
number of funny properties).
- since he rejects code that has several returns with different types, any 
kind of inference you later manage to add will be 100% compatible.


Yes, it has limitations (it is because I hit them that I guessed the 
"first return statement" rule), but it never does the wrong thing, at 
worst it rejects code that is already invalid today. I agree that 
inference from all returns would be great, later...


--
Marc Glisse


PR lto/51663 (COMDAT vars not optimized out)

2012-03-25 Thread Jan Hubicka
Hi,
this PR is about odd inconsistencies about comdat variables being or not being
optimized out at -O0 with LTO.  This is a side effect of the logic where COMDAT
variables are output on demand at -O0, while static variables are output
always.  This logic is here from pre-cgraph times where we did not optimized
out unused static vars in C at all, but we did, sort-of, optimized out unused
comdats in C++ FE.

Some tools depends on strings stored into unused static vars to survive and it
probably makes sense to behave this way at -O0.

Now this all becomes bit incosistent when LTO brings COMDAT vars private with
LTO even at -O0.

This patch moves this handling earlier. At a time we finalize decl we check
toplevel_reorder and in !toplevel_reorder we mark all non-COMDAT non-artifical
variables as forced to output

Rest of compiler now can work same was at -O0 or not.  This is cleaner and more
consistent.

Richi, does this fix all issues you saw?  It seems to work on the testcase 
provided,
but I know it comes from some more involved analysis.

Do we want to avoid privatization of symbols with LTO at -O0?  It probably 
makes sense
to do so as the privatization breaks debugging.  What about -fwhole-program? In 
this
case I would lean towards still honoring it since user has to explicitely ask 
for it.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

PR lto/51663
* varpool.c (varpool_finalize_decl): Handle toplevel_reorder here.
(decide_is_variable_needed): Do not handle toplevel reorder here.
* cgraph.h (varpool_can_remove_if_no_refs): Likewise.
* ipa.c (cgraph_remove_unreachable_nodes): Remove unreachable vars
even at -O0.
Index: cgraph.h
===
--- cgraph.h(revision 185774)
+++ cgraph.h(working copy)
@@ -947,8 +947,6 @@ static inline bool
 varpool_can_remove_if_no_refs (struct varpool_node *node)
 {
   return (!node->force_output && !node->used_from_other_partition
- && (flag_toplevel_reorder || DECL_COMDAT (node->decl)
- || DECL_ARTIFICIAL (node->decl))
  && (DECL_COMDAT (node->decl) || !node->externally_visible));
 }
 
Index: ipa.c
===
--- ipa.c   (revision 185774)
+++ ipa.c   (working copy)
@@ -419,11 +419,6 @@ cgraph_remove_unreachable_nodes (bool be
   if (file)
 fprintf (file, "\n");
 
-  /* We must release unused extern inlines or sanity checking will fail.  Rest 
of transformations
- are undesirable at -O0 since we do not want to remove anything.  */
-  if (!optimize)
-return changed;
-
   if (file)
 fprintf (file, "Reclaiming variables:");
   for (vnode = varpool_nodes; vnode; vnode = vnext)
@@ -463,6 +458,10 @@ cgraph_remove_unreachable_nodes (bool be
   if (file)
 fprintf (file, "\n");
 
+  /* Rest of transformations are undesirable at -O0.  */
+  if (!optimize)
+return changed;
+
 #ifdef ENABLE_CHECKING
   verify_cgraph ();
 #endif
Index: varpool.c
===
--- varpool.c   (revision 185774)
+++ varpool.c   (working copy)
@@ -334,10 +334,6 @@ decide_is_variable_needed (struct varpoo
   && !DECL_EXTERNAL (decl))
 return true;
 
-  /* When not reordering top level variables, we have to assume that
- we are going to keep everything.  */
-  if (!flag_toplevel_reorder)
-return true;
   return false;
 }
 
@@ -405,7 +401,11 @@ varpool_finalize_decl (tree decl)
   if (node->needed)
 varpool_enqueue_needed_node (node);
   node->finalized = true;
-  if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl))
+  if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl)
+  /* Traditionally we do not eliminate static variables when not
+optimizing and when not doing toplevel reoder.  */
+  || (!flag_toplevel_reorder && !DECL_COMDAT (node->decl)
+ && !DECL_ARTIFICIAL (node->decl)))
 node->force_output = true;
 
   if (decide_is_variable_needed (node, decl))


New Japanese PO file for 'cpplib' (version 4.7.0)

2012-03-25 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'cpplib' has been submitted
by the Japanese team of translators.  The file is available at:

http://translationproject.org/latest/cpplib/ja.po

(This file, 'cpplib-4.7.0.ja.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/cpplib/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/cpplib.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Contents of PO file 'cpplib-4.7.0.ja.po'

2012-03-25 Thread Translation Project Robot


cpplib-4.7.0.ja.po.gz
Description: Binary data
The Translation Project robot, in the
name of your translation coordinator.



Fix libjava bootstrap failure around IUCLC

2012-03-25 Thread Gerald Pfeifer
This has been introduced by

  2012-03-16  Andrew John Hughes  

* Makefile.am: Add natVMConsole.cc.
:
* java/io/VMConsole.h: Initial generation.
* java/io/VMConsole.java: Copied from classpath/vm/reference.
* java/io/natVMConsole.cc: Implemented readPassword.

where now bootstrap on FreeBSD, Darwin and possibly others is broken.

Tested on amd64-unknown-freebsd8.3.  Okay?

Gerald


2012-03-25  Gerald Pfeifer  

PR libgcj/52694
* java/io/natVMConsole.cc (IUCLC): Define, if undefined.

Index: java/io/natVMConsole.cc
===
--- java/io/natVMConsole.cc (revision 185766)
+++ java/io/natVMConsole.cc (working copy)
@@ -19,6 +19,10 @@
 #include 
 #include 
 
+#ifndef IUCLC
+#define IUCLC 0
+#endif
+
 #define TERMIOS_ECHO_IFLAGS (IUCLC|IXON|IXOFF|IXANY)
 #define TERMIOS_ECHO_LFLAGS (ECHO|ECHOE|ECHOK|ECHONL|TOSTOP)
 


PATCH: Add MaskNeeded property to option handling

2012-03-25 Thread H.J. Lu
Hi Joseph,

I need to support InverseMask(XXX) in options without the corresponding
Mask(XXX) since XXX is never set directly via a command line option. This
patch adds a MaskNeeded property which turns InverseMask(XXX) into
the inverse version of Mask(XXX), which allocates a unique bit and defines
the same set of macros as Mask(XXX).  Does it look OK?

Thanks.


H.J.

2012-03-25  H.J. Lu  

* opth-gen.awk: Handle MaskNeeded.

* doc/options.texi: Document MaskNeeded.

diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 0a54183..fb501cf 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -364,6 +364,14 @@ The main purpose of this property is to support synonymous 
options.
 The first option should use @samp{Mask(@var{name})} and the others
 should use @samp{Mask(@var{name}) MaskExists}.
 
+@item MaskNeeded
+It turns @samp{InverseMask(@var{othername})} into the inverse version of
+@samp{Mask(@var{othername})}.
+
+This property only applies to @samp{InverseMask(@var{othername})}.  Its
+main purpose is to support @samp{InverseMask(@var{othername})} without
+the corresponding @samp{Mask(@var{othername})}.
+
 @item Enum(@var{name})
 The option's argument is a string from the set of strings associated
 with the corresponding @samp{Enum} record.  The string is checked and
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 541bc3e..1885b2c 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -309,6 +309,21 @@ for (i = 0; i < n_opts; i++) {
if (name != "" && !flag_set_p("MaskExists", flags[i]))
print "#define " mask name " (" mask_1 " << " masknum[vname]++ 
")"
 }
+for (i = 0; i < n_opts; i++) {
+   name = opt_args("InverseMask", flags[i])
+   if (name != "" && flag_set_p("MaskNeeded", flags[i])) {
+   vname = var_name(flags[i])
+   mask = "MASK_"
+   mask_1 = "1"
+   if (vname != "") {
+   mask = "OPTION_MASK_"
+   if (host_wide_int[vname] == "yes")
+   mask_1 = "HOST_WIDE_INT_1"
+   }
+   print "#define " mask name " (" mask_1 \
+ " << " masknum[vname]++ ")"
+   }
+}
 for (i = 0; i < n_extra_masks; i++) {
print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")"
 }
@@ -342,6 +357,21 @@ for (i = 0; i < n_opts; i++) {
print "#define " macro name \
  " ((" vname " & " mask name ") != 0)"
 }
+for (i = 0; i < n_opts; i++) {
+   name = opt_args("InverseMask", flags[i])
+   if (name != "" && flag_set_p("MaskNeeded", flags[i])) {
+   vname = var_name(flags[i])
+   macro = "OPTION_"
+   mask = "OPTION_MASK_"
+   if (vname == "") {
+   vname = "target_flags"
+   macro = "TARGET_"
+   mask = "MASK_"
+   }
+   print "#define " macro name \
+ " ((" vname " & " mask name ") != 0)"
+   }
+}
 for (i = 0; i < n_extra_masks; i++) {
print "#define TARGET_" extra_masks[i] \
  " ((target_flags & MASK_" extra_masks[i] ") != 0)"


Re: C++ PATCH to add auto return type deduction with -std=c++1y

2012-03-25 Thread Gabriel Dos Reis
On Sun, Mar 25, 2012 at 8:32 AM, Marc Glisse  wrote:

> - a first goal is simple functions, with a single return statement (which
> may even often be the only statement).

yes, this is something we tend to forget: simple things should stay simple, no
matter how clever we think we can get.  for that reason, I like the approach.

-- Gaby


[Ada] Return early from rest_of_record_type_compilation

2012-03-25 Thread Eric Botcazou
Now that rest_of_record_type_compilation only deals with the generation of XVE 
types, we can return early for types that don't need one.

Tested on i586-suse-linux, applied on the mainline.


2012-03-25  Eric Botcazou  

* gcc-interface/utils.c (finish_record_type): Return early for padded
types and tidy up.


-- 
Eric Botcazou
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 185742)
+++ gcc-interface/utils.c	(working copy)
@@ -863,12 +863,15 @@ finish_record_type (tree record_type, tr
 void
 rest_of_record_type_compilation (tree record_type)
 {
-  tree field_list = TYPE_FIELDS (record_type);
-  tree field;
-  enum tree_code code = TREE_CODE (record_type);
   bool var_size = false;
+  tree field;
+
+  /* If this is a padded type, the bulk of the debug info has already been
+ generated for the field's type.  */
+  if (TYPE_IS_PADDING_P (record_type))
+return;
 
-  for (field = field_list; field; field = DECL_CHAIN (field))
+  for (field = TYPE_FIELDS (record_type); field; field = DECL_CHAIN (field))
 {
   /* We need to make an XVE/XVU record if any field has variable size,
 	 whether or not the record does.  For example, if we have a union,
@@ -879,7 +882,7 @@ rest_of_record_type_compilation (tree re
   if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST
 	  /* If a field has a non-constant qualifier, the record will have
 	 variable size too.  */
-	  || (code == QUAL_UNION_TYPE
+	  || (TREE_CODE (record_type) == QUAL_UNION_TYPE
 	  && TREE_CODE (DECL_QUALIFIER (field)) != INTEGER_CST))
 	{
 	  var_size = true;
@@ -887,12 +890,9 @@ rest_of_record_type_compilation (tree re
 	}
 }
 
-  /* If this record is of variable size, rename it so that the
- debugger knows it is and make a new, parallel, record
- that tells the debugger how the record is laid out.  See
- exp_dbug.ads.  But don't do this for records that are padding
- since they confuse GDB.  */
-  if (var_size && !TYPE_IS_PADDING_P (record_type))
+  /* If this record type is of variable size, make a parallel record type that
+ will tell the debugger how the former is laid out (see exp_dbug.ads).  */
+  if (var_size)
 {
   tree new_record_type
 	= make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE
@@ -1052,8 +1052,7 @@ rest_of_record_type_compilation (tree re
 	  prev_old_field = old_field;
 	}
 
-  TYPE_FIELDS (new_record_type)
-	= nreverse (TYPE_FIELDS (new_record_type));
+  TYPE_FIELDS (new_record_type) = nreverse (TYPE_FIELDS (new_record_type));
 
   add_parallel_type (TYPE_STUB_DECL (record_type), new_record_type);
 }


[Ada] Do not generate both XVS and XVE type

2012-03-25 Thread Eric Botcazou
There is no need to generate both an XVS and an XVE type for the same record 
type; we can limit ourselves to the XVS type, which is the simplest of the two 
types.

Tested on i586-suse-linux, applied on the mainline.


2012-03-25  Eric Botcazou  

* gcc-interface/utils.c (add_parallel_type): Take a TYPE instead of a
DECL and adjust.  Move around.
(has_parallel_type): New predicate.
(rest_of_record_type_compilation): Return early if the type already
has a parallel type.
* gcc-interface/gigi.h (add_parallel_type): Adjust.
* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes.


-- 
Eric Botcazou
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 185778)
+++ gcc-interface/utils.c	(working copy)
@@ -855,6 +855,29 @@ finish_record_type (tree record_type, tr
 rest_of_record_type_compilation (record_type);
 }
 
+/* Append PARALLEL_TYPE on the chain of parallel types of TYPE.  */
+
+void
+add_parallel_type (tree type, tree parallel_type)
+{
+  tree decl = TYPE_STUB_DECL (type);
+
+  while (DECL_PARALLEL_TYPE (decl))
+decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl));
+
+  SET_DECL_PARALLEL_TYPE (decl, parallel_type);
+}
+
+/* Return true if TYPE has a parallel type.  */
+
+static bool
+has_parallel_type (tree type)
+{
+  tree decl = TYPE_STUB_DECL (type);
+
+  return DECL_PARALLEL_TYPE (decl) != NULL_TREE;
+}
+
 /* Wrap up compilation of RECORD_TYPE, i.e. output all the debug information
associated with it.  It need not be invoked directly in most cases since
finish_record_type takes care of doing so, but this can be necessary if
@@ -871,6 +894,10 @@ rest_of_record_type_compilation (tree re
   if (TYPE_IS_PADDING_P (record_type))
 return;
 
+  /* If the type already has a parallel type (XVS type), then we're done.  */
+  if (has_parallel_type (record_type))
+return;
+
   for (field = TYPE_FIELDS (record_type); field; field = DECL_CHAIN (field))
 {
   /* We need to make an XVE/XVU record if any field has variable size,
@@ -1054,23 +1081,10 @@ rest_of_record_type_compilation (tree re
 
   TYPE_FIELDS (new_record_type) = nreverse (TYPE_FIELDS (new_record_type));
 
-  add_parallel_type (TYPE_STUB_DECL (record_type), new_record_type);
+  add_parallel_type (record_type, new_record_type);
 }
 }
 
-/* Append PARALLEL_TYPE on the chain of parallel types for decl.  */
-
-void
-add_parallel_type (tree decl, tree parallel_type)
-{
-  tree d = decl;
-
-  while (DECL_PARALLEL_TYPE (d))
-d = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (d));
-
-  SET_DECL_PARALLEL_TYPE (d, parallel_type);
-}
-
 /* Utility function of above to merge LAST_SIZE, the previous size of a record
with FIRST_BIT and SIZE that describe a field.  SPECIAL is true if this
represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 185742)
+++ gcc-interface/decl.c	(working copy)
@@ -1779,7 +1779,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
   if (debug_info_p
 	  && Is_Packed_Array_Type (gnat_entity)
 	  && present_gnu_tree (Original_Array_Type (gnat_entity)))
-	add_parallel_type (TYPE_STUB_DECL (gnu_type),
+	add_parallel_type (gnu_type,
 			   gnat_to_gnu_type
 			   (Original_Array_Type (gnat_entity)));
 
@@ -1854,7 +1854,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	{
 	  /* Make the original array type a parallel type.  */
 	  if (present_gnu_tree (Original_Array_Type (gnat_entity)))
-		add_parallel_type (TYPE_STUB_DECL (gnu_type),
+		add_parallel_type (gnu_type,
    gnat_to_gnu_type
    (Original_Array_Type (gnat_entity)));
 
@@ -2637,7 +2637,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		}
 
 	  finish_record_type (gnu_bound_rec, gnu_field_list, 0, true);
-	  add_parallel_type (TYPE_STUB_DECL (gnu_type), gnu_bound_rec);
+	  add_parallel_type (gnu_type, gnu_bound_rec);
 	}
 
 	  /* If this is a packed array type, make the original array type a
@@ -2647,7 +2647,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	{
 	  if (Is_Packed_Array_Type (gnat_entity)
 		  && present_gnu_tree (Original_Array_Type (gnat_entity)))
-		add_parallel_type (TYPE_STUB_DECL (gnu_type),
+		add_parallel_type (gnu_type,
    gnat_to_gnu_type
    (Original_Array_Type (gnat_entity)));
 	  else
@@ -2655,7 +2655,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		  tree gnu_base_decl
 		= gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, 0);
 		  if (!DECL_ARTIFICIAL (gnu_base_decl))
-		add_parallel_type (TYPE_STUB_DECL (gnu_type),
+		add_parallel_type (gnu_type,
    TREE_TYPE (TREE_TYPE (gnu_base_decl)));
 		}
 	}
@@ -3529,8 +3529,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 			 0, 0),
   0, true);
 
-		  add_parallel_type (TYPE_STUB_DECL (gn

[Ada] Fix ICE in insert_clobbers_for_var in SJLJ mode

2012-03-25 Thread Eric Botcazou
We have a call to builtin_alloca_with_align:

  S10b.27_153 = .builtin_alloca_with_align (5, 8);

and CCP replaces it with a static allocation:

  S10b.27_153 = &TMP;

and is trying to add a special out-of-scope CLOBBER for the new variable TMP,
under the assumption that every call to builtin_alloca_with_align is dominated 
by a call to builtin_stack_save.  But this isn't true here:

:
  FRAME.29.M17b = system.secondary_stack.ss_mark (); [return slot optimization]

:
  saved_stack.28_9(ab) = .builtin_stack_save ();

because the call to system.secondary_stack.ss_mark creates an abnormal edge to 
the setjmp dispatcher and we have a setjmp receiver after builtin_stack_save.

This is a latent issue and GCC 4.7+ now chokes on it.  The way out is to tell 
the compiler that system.secondary_stack.ss_mark is a well-behaved function, 
more precisely a "leaf" function.

Tested on i586-suse-linux, applied on the mainline and 4.7 branch.


2012-03-25  Eric Botcazou  

* gcc-interface/decl.c (SS_MARK_NAME): New define.
(gnat_to_gnu_entity) : Prepend leaf attribute on entities
whose name is SS_MARK_NAME.


2012-03-25  Eric Botcazou  

* gnat.dg/concat2.ad[sb]: New test.


-- 
Eric Botcazou
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 185779)
+++ gcc-interface/decl.c	(working copy)
@@ -81,6 +81,9 @@
 #define FOREIGN_FORCE_REALIGN_STACK 0
 #endif
 
+/* The (internal) name of the System.Secondary_Stack.SS_Mark function.  */
+#define SS_MARK_NAME "system__secondary_stack__ss_mark"
+
 struct incomplete
 {
   struct incomplete *next;
@@ -4405,6 +4408,21 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	 get_identifier ("force_align_arg_pointer"), NULL_TREE,
 	 gnat_entity);
 
+	/* ??? Declare System.Secondary_Stack.SS_Mark as leaf, in order to
+	   avoid creating abnormal edges in SJLJ mode, which can break the
+	   dominance relationship if there is a dynamic stack allocation.
+	   We cannot do this in System.Secondary_Stack directly since it's
+	   a compiler unit and this would introduce bootstrap path issues.  */
+	if (IDENTIFIER_LENGTH (gnu_entity_name) == strlen (SS_MARK_NAME)
+	&& IDENTIFIER_POINTER (gnu_entity_name)[0] == SS_MARK_NAME[0]
+	&& IDENTIFIER_POINTER (gnu_entity_name)[1] == SS_MARK_NAME[1]
+	&& IDENTIFIER_POINTER (gnu_entity_name)[2] == SS_MARK_NAME[2]
+	&& gnu_entity_name == get_identifier (SS_MARK_NAME))
+	  prepend_one_attribute_to
+	(&attr_list, ATTR_MACHINE_ATTRIBUTE,
+	 get_identifier ("leaf"), NULL_TREE,
+	 gnat_entity);
+
 	/* The lists have been built in reverse.  */
 	gnu_param_list = nreverse (gnu_param_list);
 	if (has_stub)
with Text_IO; use Text_IO;

package body Concat2 is

   function Get_Param return String is
   begin
  return "";
   end;

   procedure Browse is
  Mode : constant String := Get_Param;
  Mode_Param   : constant String := "MODE=" & Mode;
   begin
  Put_Line (Mode_Param);
   end;

end Concat2;

-- { dg-do compile }
-- { dg-options "-O" }

package Concat2 is

   procedure Browse;

end Concat2;


[Ada] Minor tweak in gnat_to_gnu_entity

2012-03-25 Thread Eric Botcazou
This has probably no effects in practice, but for the sake of consistency...

Tested on i586-suse-linux, applied on the mainline.


2012-03-25  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Copy
the TYPE_PACKED flag from the base type.


-- 
Eric Botcazou
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 185780)
+++ gcc-interface/decl.c	(working copy)
@@ -3263,6 +3263,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
 	  gnu_type = make_node (RECORD_TYPE);
 	  TYPE_NAME (gnu_type) = gnu_entity_name;
+	  TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type);
 
 	  /* Set the size, alignment and alias set of the new type to
 		 match that of the old one, doing required substitutions.  */


[PATCH gcc-4.7/changes.html] Update for -ftrack-macro-expansion and -Wunused-local-typedefs

2012-03-25 Thread Dodji Seketeli
Hello,

I forgot to update changes.html when the -ftrack-macro-expansion and
Wunused-local-typedefs changes went in.

Fixed thus.  I hope it is not too late, now that 4.7 is out.

OK for CVS head?

* htdocs/gcc-4.7/changes.html: Update for
-ftrack-macro-expansion and -Wunused-local-typedefs.

cvs diff: Diffing .
Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v
retrieving revision 1.104
diff -u -r1.104 changes.html
--- changes.html25 Mar 2012 14:17:11 -  1.104
+++ changes.html25 Mar 2012 17:30:49 -
@@ -239,6 +239,17 @@
   and can use it to improve generated code.
   
 
+  A new -Wunused-local-typedefs warning was added for C, C++,
+  Objective-C and Objective-C++.  This warning diagnoses typedefs
+  locally defined in a function, and otherwise not used.
+  
+
+  A new experimental -ftrack-macro-expansion option was added for
+  C, C++, Objective-C, Objective-C and Fortran.  It allows the
+  compiler to emit diagnostic about the current macro expansion
+  stack when a compilation error occurs in a macro expansion.
+  
+
   
 
   Experimental support for transactional memory has been added.

-- 
Dodji


Re: Propagate profile counts after switch case expansion (issue5896043)

2012-03-25 Thread Jan Hubicka
> This patch propagates execution count of thee case labels of a
> switch-case statement after its expansion. Bootstraps and all
> tests pass. OK for trunk?

Hi,
while this is resonable thing to do, I belive it would make most sense
to make switch lowering at gimple level: i.e. reorganize the existing
code to produce gimple statement and change expansion code to produce
tablejump from every gimple switch statement that was left in the
code.

This would be both cleaner and would allow gimple optimizers to improve the
generated code. Incrementally it would also allow us to improve switch exansion
that is quite baroque and not realy producing very good code in some common
cases.

If you would be interested working on this (i.e. reorganizing the expansion
code to produce gimple), I would be very happy. If not, I can review the
profile updating part for mainline, since in any case this is desriable thing
to do.

Honza


Re: PATCH: Add --with-abi= support to x86_64-*-*

2012-03-25 Thread Nathanael Nerode (GCC)
On 03/14/2012 12:22 PM, H.J. Lu wrote:
> On Fri, Mar 2, 2012 at 10:00 AM, H.J. Lu  wrote:
>> Hi,
>>
>> This patch adds --with-abi= support to x86_64-*-* to configure GCC with
>>
>> --with-abi=x32
>> --with-abi=mx32
>> --with-multilib-list=mx32
>>
>> to set the default ABI to x32.  In i386 backend, ISA_64BIT is used to
>> generate i386 code or x86-64 code.  This patch adds a new bit,
>> ISA_X86_64 to generate 32bit x86-64 code or 64bit x86-64 code.  Now it
>> has
>>
>> OPTION_MASK_ISA_64BIT   32bit x86-64 code or 64bit x86-64 code
>> OPTION_MASK_ISA_X86_64  64bit x86-64 code
>> OPTION_MASK_ISA_X32 32bit x86-64 code
>>
>> It also extends TARGET_BI_ARCH to support
>>
>> TARGET_BI_ARCH == 1, by default, OPTION_MASK_ISA_X86_64
>> TARGET_BI_ARCH == 2, by default, OPTION_MASK_ISA_X32
>>
>> I also added check --with-multilib-list for x86-64 Linux targets only if
>> multilib is enabled.
>>
>> Tested on Linux/x32.  OK for trunk?
>>


> Hi,
> 
> Can any build maintainers review this patch?

I don't feel comfortable reviewing this, because I don't fully
comprehend the intricacy of the interactions in this area.  It *looks*
good, but I don't trust my review abilities here.  If this has been
tested *in each of the possible modes* on x86-64, then I would approve
it, but there are an awful lot of combinations, and "Tested on
Linux/x32" does not tell me whether it works correctly on all of them.

Perhaps someone else will be more able to review this by reading through
the logic tree.

> 
> Thanks.
> 



[patch] Call assemble_external only from final.c and from MI-thunk hooks

2012-03-25 Thread Steven Bosscher
Hello,

This patch removes all calls to assemble_external from places other
than final.c and MI-thunk generators.

This is step 2 toward addressing PR17982 on the trunk for GCC 4.8. The
next, and final, step will be to change pending_assemble_externals to
pending_assemble_visibility, and fold assemble_external_real() back
into assemble_external.

Bootstrapped & tested all default languages on
x86_64-unknown-linux-gnu and on powerpc64-unknown-linux-gnu.

Also cross-built c and c++ to mips-elf and tested on mips-sim
(mips-elf was the only target I could find that really emits something
for its ASM_OUTPUT_EXTERNAL target macro and has a sim in gdb. I
hard-coded mips_output_external, by replacing "if
(!TARGET_EXPLICIT_RELOCS && ..." with "if (1 && ...").

OK for trunk?

Ciao!
Steven

* toplev.c (check_global_declaration_1): Do not call assemble_external.
* expr.c (emit_block_move_libcall_fn): Likewise.
(clear_storage_libcall_fn): Likewise.
(expand_expr_addr_expr_1): Likewise.
(expand_expr_real_1): Likewise.
* calls.c (rtx_for_function_call): Likewise.
* toplev.c (check_global_declaration_1): Do not call assemble_external.
* expr.c (emit_block_move_libcall_fn): Likewise.
(clear_storage_libcall_fn): Likewise.
(expand_expr_addr_expr_1): Likewise.
(expand_expr_real_1): Likewise.
* calls.c (rtx_for_function_call): Likewise.

Index: toplev.c
===
--- toplev.c(revision 185768)
+++ toplev.c(working copy)
@@ -486,7 +486,6 @@ check_global_declaration_1 (tree decl)
warning (OPT_Wunused_function, "%q+F declared % but never 
defined", decl);
   /* This symbol is effectively an "extern" declaration now.  */
   TREE_PUBLIC (decl) = 1;
-  assemble_external (decl);
 }
 
   /* Warn about static fns or vars defined but not used.  */
@@ -591,7 +590,7 @@ compile_file (void)
 
   output_shared_constant_pool ();
   output_object_blocks ();
-  finish_tm_clone_pairs ();
+  finish_tm_clone_pairs ();
 
   /* Write out any pending weak symbol declarations.  */
   weak_finish ();
Index: expr.c
===
--- expr.c  (revision 185768)
+++ expr.c  (working copy)
@@ -1375,8 +1375,7 @@ emit_block_move_via_libcall (rtx dst, rtx src, rtx
 }
 
 /* A subroutine of emit_block_move_via_libcall.  Create the tree node
-   for the function we use for block copies.  The first time FOR_CALL
-   is true, we call assemble_external.  */
+   for the function we use for block copies.  */
 
 static GTY(()) tree block_move_fn;
 
@@ -1419,7 +1418,6 @@ emit_block_move_libcall_fn (int for_call)
 {
   emitted_extern = true;
   make_decl_rtl (block_move_fn);
-  assemble_external (block_move_fn);
 }
 
   return block_move_fn;
@@ -2747,8 +2745,7 @@ set_storage_via_libcall (rtx object, rtx size, rtx
 }
 
 /* A subroutine of set_storage_via_libcall.  Create the tree node
-   for the function we use for block clears.  The first time FOR_CALL
-   is true, we call assemble_external.  */
+   for the function we use for block clears.  */
 
 tree block_clear_fn;
 
@@ -2791,7 +2788,6 @@ clear_storage_libcall_fn (int for_call)
 {
   emitted_extern = true;
   make_decl_rtl (block_clear_fn);
-  assemble_external (block_clear_fn);
 }
 
   return block_clear_fn;
@@ -7413,11 +7409,8 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enu
  result = XEXP (result, 0);
 
  /* ??? Is this needed anymore?  */
- if (DECL_P (exp) && !TREE_USED (exp) == 0)
-   {
- assemble_external (exp);
- TREE_USED (exp) = 1;
-   }
+ if (DECL_P (exp))
+   TREE_USED (exp) = 1;
 
  if (modifier != EXPAND_INITIALIZER
  && modifier != EXPAND_CONST_ADDRESS
@@ -9012,11 +9005,7 @@ expand_expr_real_1 (tree exp, rtx target, enum mac
   /* Ensure variable marked as used even if it doesn't go through
 a parser.  If it hasn't be used yet, write out an external
 definition.  */
-  if (! TREE_USED (exp))
-   {
- assemble_external (exp);
- TREE_USED (exp) = 1;
-   }
+  TREE_USED (exp) = 1;
 
   /* Show we haven't gotten RTL for this yet.  */
   temp = 0;
Index: calls.c
===
--- calls.c (revision 185768)
+++ calls.c (working copy)
@@ -1642,13 +1642,8 @@ rtx_for_function_call (tree fndecl, tree addr)
   /* Get the function to call, in the form of RTL.  */
   if (fndecl)
 {
-  /* If this is the first use of the function, see if we need to
-make an external definition for it.  */
   if (!TREE_USED (fndecl) && fndecl != current_function_decl)
-   {
- assemble_external (fndecl);
- TREE_USED (fndecl) = 1;
-   }
+   TREE_USED (fndecl) = 1;
 
   

Re: Propagate profile counts after switch case expansion (issue5896043)

2012-03-25 Thread Easwaran Raman
On Sun, Mar 25, 2012 at 12:22 PM, Jan Hubicka  wrote:
>> This patch propagates execution count of thee case labels of a
>> switch-case statement after its expansion. Bootstraps and all
>> tests pass. OK for trunk?
>
> Hi,
> while this is resonable thing to do, I belive it would make most sense
> to make switch lowering at gimple level: i.e. reorganize the existing
> code to produce gimple statement and change expansion code to produce
> tablejump from every gimple switch statement that was left in the
> code.
>
> This would be both cleaner and would allow gimple optimizers to improve the
> generated code. Incrementally it would also allow us to improve switch 
> exansion
> that is quite baroque and not realy producing very good code in some common
> cases.
>
> If you would be interested working on this (i.e. reorganizing the expansion
> code to produce gimple), I would be very happy. If not, I can review the
> profile updating part for mainline, since in any case this is desriable thing
> to do.

I am planning to explore improvements to switch expansion (peeling
some cases and using jump tables for the rest, for example) and I
think the reorganization you suggest is the right way to do such
improvements. But until I can spend time on it and get it done, I
would like this patch to get reviewed and checked in.

Thanks,
Easwaran

> Honza