Re: [Patch, Fortran] PR 63674: procedure pointer and non/pure procedure

2014-12-14 Thread Janus Weil
>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk?
>
> s/'%s'/%qs/g
> nowadays.

Good point, thank you. Updated patch attached.

I guess I still new formal approval by someone with reviewer status ...

Cheers,
Janus
Index: gcc/fortran/resolve.c
===
--- gcc/fortran/resolve.c   (Revision 218705)
+++ gcc/fortran/resolve.c   (Arbeitskopie)
@@ -2746,6 +2746,7 @@ static int
 pure_function (gfc_expr *e, const char **name)
 {
   int pure;
+  gfc_component *comp;
 
   *name = NULL;
 
@@ -2754,8 +2755,14 @@ pure_function (gfc_expr *e, const char **name)
 && e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
 return pure_stmt_function (e, e->symtree->n.sym);
 
-  if (e->value.function.esym)
+  comp = gfc_get_proc_ptr_comp (e);
+  if (comp)
 {
+  pure = gfc_pure (comp->ts.interface);
+  *name = comp->name;
+}
+  else if (e->value.function.esym)
+{
   pure = gfc_pure (e->value.function.esym);
   *name = e->value.function.esym->name;
 }
@@ -2801,6 +2808,40 @@ pure_stmt_function (gfc_expr *e, gfc_symbol *sym)
 }
 
 
+/* Check if a non-pure function function is allowed in the current context. */
+
+static bool check_pure_function (gfc_expr *e)
+{
+  const char *name = NULL;
+  if (!pure_function (e, &name) && name)
+{
+  if (forall_flag)
+{
+  gfc_error ("Reference to non-PURE function %qs at %L inside a "
+ "FORALL %s", name, &e->where,
+ forall_flag == 2 ? "mask" : "block");
+  return false;
+}
+  else if (gfc_do_concurrent_flag)
+{
+  gfc_error ("Reference to non-PURE function %qs at %L inside a "
+ "DO CONCURRENT %s", name, &e->where,
+ gfc_do_concurrent_flag == 2 ? "mask" : "block");
+  return false;
+}
+  else if (gfc_pure (NULL))
+{
+  gfc_error ("Reference to non-PURE function %qs at %L "
+ "within a PURE procedure", name, &e->where);
+  return false;
+}
+
+  gfc_unset_implicit_pure (NULL);
+}
+  return true;
+}
+
+
 /* Resolve a function call, which means resolving the arguments, then figuring
out which entity the name refers to.  */
 
@@ -2809,7 +2850,6 @@ resolve_function (gfc_expr *expr)
 {
   gfc_actual_arglist *arg;
   gfc_symbol *sym;
-  const char *name;
   bool t;
   int temp;
   procedure_type p = PROC_INTRINSIC;
@@ -2982,34 +3022,10 @@ resolve_function (gfc_expr *expr)
 #undef GENERIC_ID
 
   need_full_assumed_size = temp;
-  name = NULL;
 
-  if (!pure_function (expr, &name) && name)
-{
-  if (forall_flag)
-   {
- gfc_error ("Reference to non-PURE function %qs at %L inside a "
-"FORALL %s", name, &expr->where,
-forall_flag == 2 ? "mask" : "block");
- t = false;
-   }
-  else if (gfc_do_concurrent_flag)
-   {
- gfc_error ("Reference to non-PURE function %qs at %L inside a "
-"DO CONCURRENT %s", name, &expr->where,
-gfc_do_concurrent_flag == 2 ? "mask" : "block");
- t = false;
-   }
-  else if (gfc_pure (NULL))
-   {
- gfc_error ("Function reference to %qs at %L is to a non-PURE "
-"procedure within a PURE procedure", name, &expr->where);
- t = false;
-   }
+  if (!check_pure_function(expr))
+t = false;
 
-  gfc_unset_implicit_pure (NULL);
-}
-
   /* Functions without the RECURSIVE attribution are not allowed to
* call themselves.  */
   if (expr->value.function.esym && !expr->value.function.esym->attr.recursive)
@@ -3056,23 +3072,32 @@ resolve_function (gfc_expr *expr)
 
 /* Subroutine resolution */
 
-static void
-pure_subroutine (gfc_code *c, gfc_symbol *sym)
+static bool
+pure_subroutine (gfc_symbol *sym, const char *name, locus *loc)
 {
   if (gfc_pure (sym))
-return;
+return true;
 
   if (forall_flag)
-gfc_error ("Subroutine call to %qs in FORALL block at %L is not PURE",
-  sym->name, &c->loc);
+{
+  gfc_error ("Subroutine call to %qs in FORALL block at %L is not PURE",
+ name, loc);
+  return false;
+}
   else if (gfc_do_concurrent_flag)
-gfc_error ("Subroutine call to %qs in DO CONCURRENT block at %L is not "
-  "PURE", sym->name, &c->loc);
+{
+  gfc_error ("Subroutine call to %qs in DO CONCURRENT block at %L is not "
+ "PURE", name, loc);
+  return false;
+}
   else if (gfc_pure (NULL))
-gfc_error ("Subroutine call to %qs at %L is not PURE", sym->name,
-  &c->loc);
+{
+  gfc_error ("Subroutine call to %qs at %L is not PURE", name, loc);
+  return false;
+}
 
   gfc_unset_implicit_pure (NULL);
+  return true;
 }
 
 
@@ -3087,7 +3112,8 @@ resolve_generic_s0 (gfc_code *c, gfc_symbol *sym)
   if (s 

Re: [patch c++]: Fix PR/63996

2014-12-14 Thread Andreas Schwab
Kai Tietz  writes:

> New testcase in g++.dg/cpp1y as pr63996.C
>
> // { dg-do compile { target c++14 } }
>
> constexpr int
> foo (int i)
> {
>   int a[i] = { };
> }
>
> constexpr int j = foo (1); // { dg-error "is not a constant expression" }

FAIL: g++.dg/cpp1y/pr63996.C  -std=c++14 (test for excess errors)
Excess errors:
/usr/local/gcc/gcc-20141214/gcc/testsuite/g++.dg/cpp1y/pr63996.C:6:10: error: 
ISO C++ forbids variable length array 'a' [-Wvla]

Andreas.

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


Re: [Patch, Fortran] PR 63674: procedure pointer and non/pure procedure

2014-12-14 Thread FX
> Good point, thank you. Updated patch attached.
> I guess I still new formal approval by someone with reviewer status …

OK

Re: [PATCH][testsuite] Mark as UNSUPPORTED tests that don't fit into tiny memory model

2014-12-14 Thread Andreas Schwab
domi...@lps.ens.fr (Dominique Dhumieres) writes:

>> Here it is. Committed as r218662 to get things going again.
>
> The same change should be done for libitm and libatomic.

And boehm-gc.

Andreas.

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


Re: [Patch, Fortran] PR 63674: procedure pointer and non/pure procedure

2014-12-14 Thread Janus Weil
2014-12-14 12:00 GMT+01:00 FX :
>> Good point, thank you. Updated patch attached.
>> I guess I still new formal approval by someone with reviewer status …
>
> OK

Thanks, committed as r218717.

Cheers,
Janus


Re: PATCH: PR rtl-optimization/64037: Miscompilation with -Os and enum class : char parameter

2014-12-14 Thread H.J. Lu
On Mon, Dec 08, 2014 at 11:16:58PM +0100, Uros Bizjak wrote:
> Hello!
> 
> > On Tue, Nov 25, 2014 at 5:05 PM, H.J. Lu  wrote:
> >> On Tue, Nov 25, 2014 at 7:01 AM, Richard Biener
> >>  wrote:
> >>> On Tue, Nov 25, 2014 at 1:57 PM, H.J. Lu  wrote:
>  Hi,
> 
>  The enclosed testcase fails on x86 when compiled with -Os since we pass
>  a byte parameter with a byte load in caller and read it as an int in
>  callee.  The reason it only shows up with -Os is x86 backend encodes
>  a byte load with an int load if -O isn't used.  When a byte load is
>  used, the upper 24 bits of the register have random value for none
>  WORD_REGISTER_OPERATIONS targets.
> 
>  It happens because setup_incoming_promotions in combine.c has
> 
>    /* The mode and signedness of the argument before any promotions 
>  happen
>   (equal to the mode of the pseudo holding it at that stage).  */
>    mode1 = TYPE_MODE (TREE_TYPE (arg));
>    uns1 = TYPE_UNSIGNED (TREE_TYPE (arg));
> 
>    /* The mode and signedness of the argument after any source 
>  language and
>   TARGET_PROMOTE_PROTOTYPES-driven promotions.  */
>    mode2 = TYPE_MODE (DECL_ARG_TYPE (arg));
>    uns3 = TYPE_UNSIGNED (DECL_ARG_TYPE (arg));
> 
>    /* The mode and signedness of the argument as it is actually 
>  passed,
>   after any TARGET_PROMOTE_FUNCTION_ARGS-driven ABI promotions.  
>  */
>    mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode2, &uns3,
>   TREE_TYPE (cfun->decl), 0);
> 
>  while they are actually passed in register by assign_parm_setup_reg in
>  function.c:
> 
>    /* Store the parm in a pseudoregister during the function, but we may
>   need to do it in a wider mode.  Using 2 here makes the result
>   consistent with promote_decl_mode and thus expand_expr_real_1.  */
>    promoted_nominal_mode
>  = promote_function_mode (data->nominal_type, data->nominal_mode, 
>  &unsignedp,
>   TREE_TYPE (current_function_decl), 2);
> 
>  where nominal_type and nominal_mode are set up with TREE_TYPE (parm)
>  and TYPE_MODE (nominal_type). TREE_TYPE here is
> >>>
> >>> I think the bug is here, not in combine.c.  Can you try going back in 
> >>> history
> >>> for both snippets and see if they matched at some point?
> >>>
> >>
> >> The bug was introduced by
> >>
> >> https://gcc.gnu.org/ml/gcc-cvs/2007-09/msg00613.html
> >>
> >> commit 5d93234932c3d8617ce92b77b7013ef6bede9508
> >> Author: shinwell 
> >> Date:   Thu Sep 20 11:01:18 2007 +
> >>
> >>   gcc/
> >>   * combine.c: Include cgraph.h.
> >>   (setup_incoming_promotions): Rework to allow more aggressive
> >>   elimination of sign extensions when all call sites of the
> >>   current function are known to lie within the current unit.
> >>
> >>
> >> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128618
> >> 138bc75d-0d04-0410-961f-82ee72b054a4
> >>
> >> Before this commit, combine.c has
> >>
> >>   enum machine_mode mode = TYPE_MODE (TREE_TYPE (arg));
> >>   int uns = TYPE_UNSIGNED (TREE_TYPE (arg));
> >>
> >>   mode = promote_mode (TREE_TYPE (arg), mode, &uns, 1);
> >>   if (mode == GET_MODE (reg) && mode != DECL_MODE (arg))
> >> {
> >>   rtx x;
> >>   x = gen_rtx_CLOBBER (DECL_MODE (arg), const0_rtx);
> >>   x = gen_rtx_fmt_e ((uns ? ZERO_EXTEND : SIGN_EXTEND), mode, 
> >> x);
> >>   record_value_for_reg (reg, first, x);
> >> }
> >>
> >> It matches function.c:
> >>
> >>   /* This is not really promoting for a call.  However we need to be
> >>  consistent with assign_parm_find_data_types and expand_expr_real_1.  
> >> */
> >>   promoted_nominal_mode
> >> = promote_mode (data->nominal_type, data->nominal_mode, &unsignedp, 1);
> >>
> >> r128618 changed
> >>
> >> mode = promote_mode (TREE_TYPE (arg), mode, &uns, 1);
> >>
> >> to
> >>
> >> mode3 = promote_mode (DECL_ARG_TYPE (arg), mode2, &uns3, 1);
> >>
> >> It breaks none WORD_REGISTER_OPERATIONS targets.
> >
> > Hmm, I think that DECL_ARG_TYPE makes a difference only
> > for non-WORD_REGISTER_OPERATIONS targets.
> >
> > But yeah, isolated the above change looks wrong.
> >
> > Your patch is ok for trunk if nobody objects within 24h and for branches
> > after a week.
> >
> > Thanks,
> > Richard.
> 
> This patch caused PR64213.
> 

Here is the updated patch.  The difference is

  mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns3,
 TREE_TYPE (cfun->decl), 0);

vs

  mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns1,
 TREE_TYPE (cfun->decl), 0);

I made a mistake in my previous patch where I shouldn't have changed
&uns3 to &uns1

[gomp4] Merge trunk r218679 (2014-12-12) into gomp-4_0-branch

2014-12-14 Thread Thomas Schwinge
Hi!

In r218719, I have committed a merge from trunk r218679 (2014-12-12) into
gomp-4_0-branch.


Grüße,
 Thomas


pgp_QoHKRWj1T.pgp
Description: PGP signature


Re: PATCH: PR rtl-optimization/64037: Miscompilation with -Os and enum class : char parameter

2014-12-14 Thread Richard Biener
On December 14, 2014 3:08:28 PM CET, "H.J. Lu"  wrote:
>On Mon, Dec 08, 2014 at 11:16:58PM +0100, Uros Bizjak wrote:
>> Hello!
>> 
>> > On Tue, Nov 25, 2014 at 5:05 PM, H.J. Lu 
>wrote:
>> >> On Tue, Nov 25, 2014 at 7:01 AM, Richard Biener
>> >>  wrote:
>> >>> On Tue, Nov 25, 2014 at 1:57 PM, H.J. Lu 
>wrote:
>>  Hi,
>> 
>>  The enclosed testcase fails on x86 when compiled with -Os since
>we pass
>>  a byte parameter with a byte load in caller and read it as an
>int in
>>  callee.  The reason it only shows up with -Os is x86 backend
>encodes
>>  a byte load with an int load if -O isn't used.  When a byte load
>is
>>  used, the upper 24 bits of the register have random value for
>none
>>  WORD_REGISTER_OPERATIONS targets.
>> 
>>  It happens because setup_incoming_promotions in combine.c has
>> 
>>    /* The mode and signedness of the argument before any
>promotions happen
>>   (equal to the mode of the pseudo holding it at that
>stage).  */
>>    mode1 = TYPE_MODE (TREE_TYPE (arg));
>>    uns1 = TYPE_UNSIGNED (TREE_TYPE (arg));
>> 
>>    /* The mode and signedness of the argument after any
>source language and
>>   TARGET_PROMOTE_PROTOTYPES-driven promotions.  */
>>    mode2 = TYPE_MODE (DECL_ARG_TYPE (arg));
>>    uns3 = TYPE_UNSIGNED (DECL_ARG_TYPE (arg));
>> 
>>    /* The mode and signedness of the argument as it is
>actually passed,
>>   after any TARGET_PROMOTE_FUNCTION_ARGS-driven ABI
>promotions.  */
>>    mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode2,
>&uns3,
>>   TREE_TYPE (cfun->decl), 0);
>> 
>>  while they are actually passed in register by
>assign_parm_setup_reg in
>>  function.c:
>> 
>>    /* Store the parm in a pseudoregister during the function, but
>we may
>>   need to do it in a wider mode.  Using 2 here makes the
>result
>>   consistent with promote_decl_mode and thus
>expand_expr_real_1.  */
>>    promoted_nominal_mode
>>  = promote_function_mode (data->nominal_type,
>data->nominal_mode, &unsignedp,
>>   TREE_TYPE (current_function_decl),
>2);
>> 
>>  where nominal_type and nominal_mode are set up with TREE_TYPE
>(parm)
>>  and TYPE_MODE (nominal_type). TREE_TYPE here is
>> >>>
>> >>> I think the bug is here, not in combine.c.  Can you try going
>back in history
>> >>> for both snippets and see if they matched at some point?
>> >>>
>> >>
>> >> The bug was introduced by
>> >>
>> >> https://gcc.gnu.org/ml/gcc-cvs/2007-09/msg00613.html
>> >>
>> >> commit 5d93234932c3d8617ce92b77b7013ef6bede9508
>> >> Author: shinwell 
>> >> Date:   Thu Sep 20 11:01:18 2007 +
>> >>
>> >>   gcc/
>> >>   * combine.c: Include cgraph.h.
>> >>   (setup_incoming_promotions): Rework to allow more aggressive
>> >>   elimination of sign extensions when all call sites of the
>> >>   current function are known to lie within the current unit.
>> >>
>> >>
>> >> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128618
>> >> 138bc75d-0d04-0410-961f-82ee72b054a4
>> >>
>> >> Before this commit, combine.c has
>> >>
>> >>   enum machine_mode mode = TYPE_MODE (TREE_TYPE (arg));
>> >>   int uns = TYPE_UNSIGNED (TREE_TYPE (arg));
>> >>
>> >>   mode = promote_mode (TREE_TYPE (arg), mode, &uns, 1);
>> >>   if (mode == GET_MODE (reg) && mode != DECL_MODE (arg))
>> >> {
>> >>   rtx x;
>> >>   x = gen_rtx_CLOBBER (DECL_MODE (arg), const0_rtx);
>> >>   x = gen_rtx_fmt_e ((uns ? ZERO_EXTEND :
>SIGN_EXTEND), mode, x);
>> >>   record_value_for_reg (reg, first, x);
>> >> }
>> >>
>> >> It matches function.c:
>> >>
>> >>   /* This is not really promoting for a call.  However we need to
>be
>> >>  consistent with assign_parm_find_data_types and
>expand_expr_real_1.  */
>> >>   promoted_nominal_mode
>> >> = promote_mode (data->nominal_type, data->nominal_mode,
>&unsignedp, 1);
>> >>
>> >> r128618 changed
>> >>
>> >> mode = promote_mode (TREE_TYPE (arg), mode, &uns, 1);
>> >>
>> >> to
>> >>
>> >> mode3 = promote_mode (DECL_ARG_TYPE (arg), mode2, &uns3, 1);
>> >>
>> >> It breaks none WORD_REGISTER_OPERATIONS targets.
>> >
>> > Hmm, I think that DECL_ARG_TYPE makes a difference only
>> > for non-WORD_REGISTER_OPERATIONS targets.
>> >
>> > But yeah, isolated the above change looks wrong.
>> >
>> > Your patch is ok for trunk if nobody objects within 24h and for
>branches
>> > after a week.
>> >
>> > Thanks,
>> > Richard.
>> 
>> This patch caused PR64213.
>> 
>
>Here is the updated patch.  The difference is
>
>  mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns3,
>TREE_TYPE (cfun->decl), 0);
>
>vs
>
>  mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns1,
>  

[C++ Patch] PR 58882

2014-12-14 Thread Paolo Carlini

Hi,

in order to handle correctly the testcase, thus do not ICE on it, I 
think we have simply to replace the existing gcc_unreachable with a 
normal error call. Additionally, I noticed that we aren't handling 
correctly things like constexpr user-defined type-conversion operators, 
thus I added the kind of build_expr_type_conversion / 
maybe_constant_value massaging which we are already using elsewhere. 
Finally, we have got an accepts-invalid issue with scoped enumerations, 
thus the INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P check.


Tested x86_64-linux.

Thanks,
Paolo.


/cp
2014-12-14  Paolo Carlini  

PR c++/58882
* decl.c (check_array_designated_initializer): Diagnose gracefully
C99 designators which aren't integral constant-expressions; allow
constexpr user-defined type conversion operators.

/testsuite
2014-12-14  Paolo Carlini  

PR c++/58882
* g++.dg/ext/desig8.C: New.
* g++.dg/cpp0x/desig1.C: Likewise.
Index: cp/decl.c
===
--- cp/decl.c   (revision 218716)
+++ cp/decl.c   (working copy)
@@ -4996,18 +4996,22 @@ check_array_designated_initializer (constructor_el
  return false;
}
 
-  ce->index = cxx_constant_value (ce->index);
-
-  if (TREE_CODE (ce->index) == INTEGER_CST)
+  tree ce_index = build_expr_type_conversion (WANT_INT | WANT_ENUM,
+ ce->index, true);
+  if (ce_index
+ && INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (ce_index))
+ && (TREE_CODE (ce_index = maybe_constant_value (ce_index))
+ == INTEGER_CST))
{
  /* A C99 designator is OK if it matches the current index.  */
- if (wi::eq_p (ce->index, index))
+ if (wi::eq_p (ce_index, index))
return true;
  else
sorry ("non-trivial designated initializers not supported");
}
   else
-   gcc_unreachable ();
+   error ("C99 designator %qE is not an integral constant-expression",
+  ce->index);
 
   return false;
 }
Index: testsuite/g++.dg/cpp0x/desig1.C
===
--- testsuite/g++.dg/cpp0x/desig1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/desig1.C (working copy)
@@ -0,0 +1,27 @@
+// PR c++/58882
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  constexpr operator int() const { return 0; }
+};
+
+int a[] = { [A()] = 0 };
+
+enum E { e0 };
+
+struct B
+{
+  constexpr operator E() const { return E::e0; }
+};
+
+int b[] = { [B()] = 0 };
+
+enum class SE { se0 };
+
+struct C
+{
+  constexpr operator SE() const { return SE::se0; }
+};
+
+int c[] = { [C()] = 0 }; // { dg-error "integral constant-expression" }
Index: testsuite/g++.dg/ext/desig8.C
===
--- testsuite/g++.dg/ext/desig8.C   (revision 0)
+++ testsuite/g++.dg/ext/desig8.C   (working copy)
@@ -0,0 +1,3 @@
+// PR c++/58882
+
+int a[] = { [0.] = 0 }; // { dg-error "integral constant-expression" }


[PATCH] Remove dead code in omp-low.c

2014-12-14 Thread Andi Kleen
From: Andi Kleen 

Since the accelerator changes omp_expand_local is not used anymore.
Remove the dead function and another function used by it.

gcc/:

2014-12-14  Andi Kleen  

* omp-low.c (build_omp_regions_root): Remove dead function.
(omp_expand_local): Dito.
* omp-low.h: Dito.
---
 gcc/omp-low.c | 30 --
 gcc/omp-low.h |  1 -
 2 files changed, 31 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index a2e4737..908d280 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -8753,36 +8753,6 @@ build_omp_regions_1 (basic_block bb, struct omp_region 
*parent,
 build_omp_regions_1 (son, parent, single_tree);
 }
 
-/* Builds the tree of OMP regions rooted at ROOT, storing it to
-   root_omp_region.  */
-
-static void
-build_omp_regions_root (basic_block root)
-{
-  gcc_assert (root_omp_region == NULL);
-  build_omp_regions_1 (root, NULL, true);
-  gcc_assert (root_omp_region != NULL);
-}
-
-/* Expands omp construct (and its subconstructs) starting in HEAD.  */
-
-void
-omp_expand_local (basic_block head)
-{
-  build_omp_regions_root (head);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-{
-  fprintf (dump_file, "\nOMP region tree\n\n");
-  dump_omp_region (dump_file, root_omp_region, 0);
-  fprintf (dump_file, "\n");
-}
-
-  remove_exit_barriers (root_omp_region);
-  expand_omp (root_omp_region);
-
-  free_omp_regions ();
-}
-
 /* Scan the CFG and build a tree of OMP regions.  Return the root of
the OMP region tree.  */
 
diff --git a/gcc/omp-low.h b/gcc/omp-low.h
index ac587d0..718e707 100644
--- a/gcc/omp-low.h
+++ b/gcc/omp-low.h
@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3.  If not see
 struct omp_region;
 
 extern tree find_omp_clause (tree, enum omp_clause_code);
-extern void omp_expand_local (basic_block);
 extern void free_omp_regions (void);
 extern tree omp_reduction_init (tree, tree);
 extern bool make_gimple_omp_edges (basic_block, struct omp_region **, int *);
-- 
2.1.3



Go patch committed: Fix crash when tracked field used in global init

2014-12-14 Thread Ian Lance Taylor
My recent patch for tracked fields had a bug that caused a compiler
crash when they were used in a global initializer.  This patch fixes
it.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff -r 5f3aca373b7d go/expressions.cc
--- a/go/expressions.cc Sat Dec 13 16:54:07 2014 -0800
+++ b/go/expressions.cc Sun Dec 14 11:36:36 2014 -0800
@@ -10731,7 +10731,7 @@
 return this;
 
   // References from functions generated by the compiler don't count.
-  if (function->func_value()->is_type_specific_function())
+  if (function != NULL && function->func_value()->is_type_specific_function())
 return this;
 
   // We have found a reference to a tracked field.  Build a call to


[match-and-simplify] print capture name

2014-12-14 Thread Prathamesh Kulkarni
Print name of capture in patterns written by user.

* genmatch.c
  (capture::name): New.
  (capture::capture): New default argument.
  (parse_capture): Pass id to capture::capture.
  (print_operand): Print name of capture if available.

Thanks,
Prathamesh


Re: [match-and-simplify] print capture name

2014-12-14 Thread Prathamesh Kulkarni
On 15 December 2014 at 02:03, Prathamesh Kulkarni
 wrote:
> Print name of capture in patterns written by user.
>
> * genmatch.c
>   (capture::name): New.
>   (capture::capture): New default argument.
>   (parse_capture): Pass id to capture::capture.
>   (print_operand): Print name of capture if available.
>
oops, forgot to attach the patch.

> Thanks,
> Prathamesh
Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 218664)
+++ gcc/genmatch.c	(working copy)
@@ -508,12 +508,15 @@
 
 struct capture : public operand
 {
-  capture (unsigned where_, operand *what_)
-  : operand (OP_CAPTURE), where (where_), what (what_) {}
+  capture (unsigned where_, operand *what_, const char *name_ = 0)
+  : operand (OP_CAPTURE), where (where_), what (what_), name (name_)  {}
   /* Identifier index for the value.  */
   unsigned where;
   /* The captured value.  */
   operand *what;
+  /* The original capture name */
+  const char *name;
+  
   virtual void gen_transform (FILE *f, const char *, bool, int,
 			  const char *, capture_info *,
 			  dt_operand ** = 0, bool = true);
@@ -605,6 +608,8 @@
   if (capture *c = dyn_cast (o))
 {
   fprintf (f, "@%u", c->where);
+  if (c->name)
+	fprintf (f, "(%s)", c->name); 
   if (c->what && flattened == false)
 	{
 	  putc (':', f);
@@ -2940,7 +2945,7 @@
   unsigned &num = capture_ids->get_or_insert (id, &existed);
   if (!existed)
 num = next_id;
-  return new capture (num, op);
+  return new capture (num, op, id);
 }
 
 /* Parse an expression


[match-and-simplify] set simplify::capture_max to 0 if pattern contains no captures

2014-12-14 Thread Prathamesh Kulkarni
Caused segfault for pattern containing no captures at:
info.safe_grow_cleared(capture_max + 1); in capture_info::capture_info

artificial test-case:
(define_predicates integer_zerop)
(simplify
  (bit_not integer_zerop)
  { build_zero_cst (type); })

* genmatch.c
  (simplify::simplify): Set simplify::capture_max to 0 if pattern
contains no captures.

Thanks,
Prathamesh
Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 218664)
+++ gcc/genmatch.c	(working copy)
@@ -576,7 +576,7 @@
   : match (match_), match_location (match_location_),
   result (result_), result_location (result_location_),
   ifexpr_vec (ifexpr_vec_), for_vec (for_vec_),
-  capture_ids (capture_ids_), capture_max (capture_ids_->elements () - 1) {}
+  capture_ids (capture_ids_), capture_max (capture_ids_->elements () ? capture_ids_->elements () - 1 : 0) {}
 
   /* The expression that is matched against the GENERIC or GIMPLE IL.  */
   operand *match;


flattening cfgloop.h

2014-12-14 Thread Prathamesh Kulkarni
Hi,
The attached patch flattens cfgloop.h.
Created new file cfgloopanal.h which exports function prototypes
from cfgloopanal.c. Rest of the patch involves restructuring includes.

Boostrapped and tested on x86_64-unknown-linux-gnu with ISL enabled.
Built on all targets in config-list.mk with languages c, c++ enabled.

Thank you,
Prathamesh
2014-12-14  Prathamesh Kulkarni  

* cfgloopanal.h: New header file containing function prototypes from 
cfgloopanal.c

* cfgloop.h: Remove includes.
(mark_irreducible_loops): Move prototype to cfgloopanal.h
(num_loop_insns): Likewise.
(average_num_loop_insns): Likewise.
(get_loop_level): Likewise.
(mark_loop_exit_edges): Likewise.
(just_once_each_iteration_p): Likewise.
(expected_loop_iterations_unbounded): Likewise.
(estimate_reg_pressure_cost): Likewise.
(init_set_costs): Likewise.

* asan.c: Include double-int.h, wide-int.h, bitmap.h, sbitmap.h, 
cfgloopmanip.h, cfgloopanal.h
* auto-profile.c: Likewise.
* bt-load.c: Likewise.
* cfg.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgloop.c: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraphunit.c: Likewise.
* config/aarch64/aarch64.c: Likewise.
* config/mn10300/mn10300.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c: Likewise.
* config/sh/sh.c: Likewise.
* config/spu/spu.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/i386/i386.c: Include double-int.h, bitmap.h, cfgloopmanip.h, 
cfgloopanal.h.
* cprop.c: Likewise.
* except.c: Likewise.
* ggc-page.c: Likewise.
* gimple-ssa-isolate-paths.c: Likewise.
* graphite-blocking.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-isl-ast-to-gimple.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* ifcvt.c: Likewise.
* ipa-icf-gimple.c: Likewise.
* ipa-icf.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-split.c: Likewise.
* ira-costs.c: Likewise.
* loop-doloop.c: Likewise.
* loop-init.c: Likewise.
* loop-iv.c: Likewise.
* loop-unroll.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* profile.c: Likewise.
* sese.c: Likewise.
* target-globals.c: Likewise.
* toplev.c: Likewise.
* tracer.c: Likewise.
* trans-mem.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-eh.c: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-into-ssa.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-parloops.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-ssa-copy.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-loop-ch.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-loop-unswitch.c: Likewise.
* tree-ssa-loop.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sink.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-tailcall.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vrp.c: Likewise.
* ubsan.c: Likewise.
* vtable-verify.c: Likewise.
* cfgexpand.c: Include double-int.h, wide-int.h, cfgloopmanip.h, 
cfgloopanal.h

Re: [off-list] A fixincludes warning-removal patch

2014-12-14 Thread Bruce Korb

On 12/14/14 14:07, Uros Bizjak wrote:

Hello Bruce!

I have posted a small fixincludes patch [1] that fixes a warning
during the fixincludes build,


Please apply.  However, I'm sure it is not "the last remaining warning"
since new warnings get invented. :)

Thank you - Bruce

2014-12-09  Uros Bizjak  

* server.c (server_setup): Check return value of
getcwd and in case of error set buff[0] to 0.

Bootstrapped on x86_64-linux-gnu.

OK for mainline?

Index: server.c
===
--- server.c(revision 218525)
+++ server.c(working copy)
@@ -192,7 +192,8 @@ server_setup (void)

   fputs ("trap : 1\n", server_pair.pf_write);
   fflush (server_pair.pf_write);
-  getcwd (buff, MAXPATHLEN + 1);
+  if (getcwd (buff, MAXPATHLEN + 1) == NULL)
+buff[0] = 0;
   p_cur_dir = xstrdup (buff);
 }



Do not build callgraph for external functions when inlining

2014-12-14 Thread Jan Hubicka
Hi,
this patch implements analogous change I did to ipa.c reachability to remove
extern functions early when not optimizing.  These are common in C++ code and
it is not effective to process them until after inliner.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

Honza

* cgraphunit.c (analyze_functions): Do not analyze extern inline
funtions when not optimizing; skip comdat locals.
Index: cgraphunit.c
===
--- cgraphunit.c(revision 218701)
+++ cgraphunit.c(working copy)
@@ -263,7 +264,7 @@ symtab_node::needed_p (void)
   if (forced_by_abi && TREE_PUBLIC (decl))
 return true;
 
- /* Keep constructors, destructors and virtual functions.  */
+  /* Keep constructors, destructors and virtual functions.  */
if (TREE_CODE (decl) == FUNCTION_DECL
&& (DECL_STATIC_CONSTRUCTOR (decl) || DECL_STATIC_DESTRUCTOR (decl)))
 return true;
@@ -1000,7 +1001,20 @@ analyze_functions (void)
cnode->analyze ();
 
  for (edge = cnode->callees; edge; edge = edge->next_callee)
-   if (edge->callee->definition)
+   if (edge->callee->definition
+   && (!DECL_EXTERNAL (edge->callee->decl)
+   /* When not optimizing, do not try to analyze extern
+  inline functions.  Doing so is pointless.  */
+   || opt_for_fn (edge->callee->decl, optimize)
+   /* Weakrefs needs to be preserved.  */
+   || edge->callee->alias
+   /* always_inline functions are inlined aven at -O0.  */
+   || lookup_attribute
+("always_inline",
+ DECL_ATTRIBUTES (edge->callee->decl))
+   /* Multiversioned functions needs the dispatcher to
+  be produced locally even for extern functions.  */
+   || edge->callee->function_version ()))
   enqueue_node (edge->callee);
  if (opt_for_fn (cnode->decl, optimize)
  && opt_for_fn (cnode->decl, flag_devirtualize))
@@ -1040,10 +1054,17 @@ analyze_functions (void)
  for (next = node->same_comdat_group;
   next != node;
   next = next->same_comdat_group)
-   enqueue_node (next);
+   if (!next->comdat_local_p ())
+ enqueue_node (next);
}
  for (i = 0; node->iterate_reference (i, ref); i++)
-   if (ref->referred->definition)
+   if (ref->referred->definition
+   && (!DECL_EXTERNAL (ref->referred->decl)
+   || ((TREE_CODE (ref->referred->decl) != FUNCTION_DECL
+&& optimize)
+   || (TREE_CODE (ref->referred->decl) == FUNCTION_DECL
+   && opt_for_fn (ref->referred->decl, optimize))
+   || ref->referred->alias)))
  enqueue_node (ref->referred);
  symtab->process_new_functions ();
}


[C++ patch] do not make extern inlines as needed when not optimizing

2014-12-14 Thread Jan Hubicka
Hi,
while looking into PR ipa/61324 I noticed that extern inline functions are
produced by C++ FE even at -O0.  This seems like considerable waste especially
because these may trigger instantiations.

Bootstrepped/regtested x86_64-linux, OK?

Honza

* decl2.c (decl_needed_p): When not optimizing, extern decls are not
needed.
Index: cp/decl2.c
===
--- cp/decl2.c  (revision 218701)
+++ cp/decl2.c  (working copy)
@@ -1996,19 +1996,31 @@ decl_needed_p (tree decl)
  COMDAT until that point.  */
   gcc_assert (at_eof);
 
-  /* All entities with external linkage that are not COMDAT should be
+  /* All entities with external linkage that are not COMDAT/EXTERN should be
  emitted; they may be referred to from other object files.  */
-  if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
+  if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl)
+  && (!DECL_EXTERNAL (decl) || DECL_NOT_REALLY_EXTERN (decl)))
 return true;
-  /* If this entity was used, let the back end see it; it will decide
- whether or not to emit it into the object file.  */
-  if (TREE_USED (decl))
-  return true;
   /* Functions marked "dllexport" must be emitted so that they are
  visible to other DLLs.  */
   if (flag_keep_inline_dllexport
   && lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))
 return true;
+
+  /* When not optimizing, do not bother to produce definitions for extern
+ symbols.  */
+  if (DECL_EXTERNAL (decl) && !DECL_NOT_REALLY_EXTERN (decl)
+  && ((TREE_CODE (decl) != FUNCTION_DECL
+  && !optimize)
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && !opt_for_fn (decl, optimize)))
+  && !lookup_attribute ("always_inline", decl))
+return false;
+
+  /* If this entity was used, let the back end see it; it will decide
+ whether or not to emit it into the object file.  */
+  if (TREE_USED (decl))
+  return true;
   /* Virtual functions might be needed for devirtualization.  */
   if (flag_devirtualize
   && TREE_CODE (decl) == FUNCTION_DECL


[Patch, libstdc++/64302, libstdc++/64303] Fix match_results iterators and regex_token_iterator

2014-12-14 Thread Tim Shen
Bootstraped and tested :)

I'm not sure if it's safe to directly backport it to 4.9, since one
inline function (_M_normalize_result) is added; but at least we can
manually inline them by copy & paste.


-- 
Regards,
Tim Shen
commit 6be0eb9cfb66c0229c7121890371f9d45189321d
Author: timshen 
Date:   Sun Dec 14 14:00:08 2014 -0800

PR libstdc++/64302
PR libstdc++/64303
* include/bits/regex.h (match_results::cbegin, match_results::cend,
regex_token_iterator::regex_token_iterator,
regex_token_iterator::_M_normalize_result): Fix match_results cbegin
and cend and regex_token_iterator::_M_result invariant.
* include/bits/regex.tcc: Fix regex_token_iterator::_M_result invariant.
* testsuite/28_regex/iterators/regex_token_iterator/64303.cc: Testcase.

diff --git a/libstdc++-v3/include/bits/regex.h 
b/libstdc++-v3/include/bits/regex.h
index 3afec37..80b1de8 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1756,7 +1756,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
   const_iterator
   cbegin() const
-  { return _Base_type::cbegin() + 2; }
+  { return this->begin(); }
 
   /**
* @brief Gets an iterator to one-past-the-end of the collection.
@@ -1770,7 +1770,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
   const_iterator
   cend() const
-  { return _Base_type::cend(); }
+  { return this->end(); }
 
   //@}
 
@@ -2632,7 +2632,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 regex_constants::match_flag_type __m
 = regex_constants::match_default)
   : _M_position(__a, __b, __re, __m),
-  _M_subs(__submatches, *(&__submatches+1)), _M_n(0)
+  _M_subs(__submatches, __submatches + _Nm), _M_n(0)
   { _M_init(__a, __b); }
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
@@ -2660,12 +2660,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
   regex_token_iterator(const regex_token_iterator& __rhs)
   : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
-  _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_result(__rhs._M_result),
-  _M_has_m1(__rhs._M_has_m1)
-  {
-   if (__rhs._M_result == &__rhs._M_suffix)
- _M_result = &_M_suffix;
-  }
+  _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1)
+  { _M_normalize_result(); }
 
   /**
* @brief Assigns a %regex_token_iterator to another.
@@ -2737,6 +2733,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _M_end_of_seq() const
   { return _M_result == nullptr; }
 
+  // [28.12.2.2.4]
+  void
+  _M_normalize_result()
+  {
+   if (_M_position != _Position())
+ _M_result = &_M_current_match();
+   else if (_M_has_m1)
+ _M_result = &_M_suffix;
+   else
+ _M_result = nullptr;
+  }
+
   _Position _M_position;
   std::vector  _M_subs;
   value_type_M_suffix;
diff --git a/libstdc++-v3/include/bits/regex.tcc 
b/libstdc++-v3/include/bits/regex.tcc
index b676428..0206a6c 100644
--- a/libstdc++-v3/include/bits/regex.tcc
+++ b/libstdc++-v3/include/bits/regex.tcc
@@ -607,11 +607,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _M_position = __rhs._M_position;
   _M_subs = __rhs._M_subs;
   _M_n = __rhs._M_n;
-  _M_result = __rhs._M_result;
   _M_suffix = __rhs._M_suffix;
   _M_has_m1 = __rhs._M_has_m1;
-  if (__rhs._M_result == &__rhs._M_suffix)
-   _M_result = &_M_suffix;
+  _M_normalize_result();
   return *this;
 }
 
diff --git 
a/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc 
b/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc
new file mode 100644
index 000..f09bbe1
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/64303.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=gnu++11" }
+
+//
+// Copyright (C) 2014 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
+// .
+
+// 28.12.2 Class template regex_token_iterator
+
+#include 
+#include 
+
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  const std::string s("  111  222  ");
+  const std::regex re("\\w+");
+
+  std::sregex_token_iterator it1(s.beg

Fix ICE on missing binfo

2014-12-14 Thread Jan Hubicka
Hi,
this patch fixes more of PR64043: when we have OBJ_TYPE_REF without a BINFO, we 
should
not try to devirtualize.  This is most conveniently done by modifying
virtual_method_call_p.  I still need to figure out why -O0 / -O2 combination 
with LTO
leads to -fdevirtualize being set.  It should not.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 218726)
+++ ChangeLog   (working copy)
@@ -1,5 +1,11 @@
 2014-12-14  Jan HUbicka  
 
+   PR lto/64043
+   * tree.c (virtual_method_call_p): Return false when OTR type has
+   no BINFO.
+
+2014-12-14  Jan HUbicka  
+
* cgraphunit.c (analyze_functions): Do not analyze extern inline
funtions when not optimizing; skip comdat locals.
 
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog (revision 218701)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2014-12-14  Jan HUbicka  
+
+   PR lto/64043
+   * g++.dg/lto/pr64043_0.C: New testcase.
+
 2014-12-13  Tobias Burnus  
 
* gfortran.dg/realloc_on_assign_21.f90: Update dg-error.
Index: tree.c
===
--- tree.c  (revision 218701)
+++ tree.c  (working copy)
@@ -11864,12 +11864,17 @@ virtual_method_call_p (tree target)
 {
   if (TREE_CODE (target) != OBJ_TYPE_REF)
 return false;
-  target = TREE_TYPE (target);
-  gcc_checking_assert (TREE_CODE (target) == POINTER_TYPE);
-  target = TREE_TYPE (target);
-  if (TREE_CODE (target) == FUNCTION_TYPE)
+  tree t = TREE_TYPE (target);
+  gcc_checking_assert (TREE_CODE (t) == POINTER_TYPE);
+  t = TREE_TYPE (t);
+  if (TREE_CODE (t) == FUNCTION_TYPE)
+return false;
+  gcc_checking_assert (TREE_CODE (t) == METHOD_TYPE);
+  /* If we do not have BINFO associated, it means that type was built
+ without devirtualization enabled.  Do not consider this a virtual
+ call.  */
+  if (!TYPE_BINFO (obj_type_ref_class (target)))
 return false;
-  gcc_checking_assert (TREE_CODE (target) == METHOD_TYPE);
   return true;
 }
 
Index: testsuite/g++.dg/lto/pr64043_0.C
===
--- testsuite/g++.dg/lto/pr64043_0.C(revision 0)
+++ testsuite/g++.dg/lto/pr64043_0.C(revision 0)
@@ -0,0 +1,14 @@
+// { dg-lto-do link }
+// { dg-lto-options { { -flto -std=c++11 } } }
+// { dg-extra-ld-options "-r -nostdlib -O2" }
+class Validator
+{
+public:
+  virtual ~Validator ();
+};
+class FooWriter
+{
+  Validator *validator;
+  ~FooWriter ();
+};
+FooWriter::~FooWriter () { delete validator; }


Fix ICE in insert_to_assembler_name_hash

2014-12-14 Thread Jan Hubicka
Hi,
this patch fixes ICE in symbol_table::insert_to_assembler_name_hash in cases
where C++ FE produces a symbol but refuses to give it an assembler name (because
it is abstract but w/o abstract flag set).

Bootstrapped/regtested x86_64-linux, comitted.

Index: ChangeLog
===
--- ChangeLog   (revision 218727)
+++ ChangeLog   (working copy)
@@ -1,5 +1,11 @@
 2014-12-14  Jan Hubicka  
 
+   PR ipa/61558
+   * symtab.c (symbol_table::insert_to_assembler_name_hash
+   symbol_table::unlink_from_assembler_name_hash): Do not ICE when 
+   DECL_ASSEMBLER_NAME is NULL.
+
+2014-12-14  Jan Hubicka  
+
* cgraphunit.c (analyze_functions): Always analyze targets of aliases.
 
 2014-12-14  Jan Hubicka  
Index: testsuite/g++.dg/torture/pr61558.C
===
--- testsuite/g++.dg/torture/pr61558.C  (revision 0)
+++ testsuite/g++.dg/torture/pr61558.C  (revision 0)
@@ -0,0 +1,6 @@
+// { dg-do compile }
+static __typeof 0 a __attribute__ ((__weakref__ ("")));
+template  class A
+{
+  static __thread int b;
+};
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog (revision 218727)
+++ testsuite/ChangeLog (working copy)
@@ -1,4 +1,9 @@
-2014-12-14  Jan HUbicka  
+2014-12-14  Jan Hubicka
+   
+   PR ipa/61558
+   * g++.dg/torture/pr61558.C: New testcase.
+
+2014-12-14  Jan Hubicka  
 
PR lto/64043
* g++.dg/lto/pr64043_0.C: New testcase.
Index: symtab.c
===
--- symtab.c(revision 218726)
+++ symtab.c(working copy)
@@ -168,6 +168,11 @@ symbol_table::insert_to_assembler_name_h
 
   tree name = DECL_ASSEMBLER_NAME (node->decl);
 
+  /* C++ FE can produce decls without associated assembler name and insert
+them to symtab to hold section or TLS information.  */
+  if (!name)
+   return;
+
   hashval_t hash = decl_assembler_name_hash (name);
   aslot = assembler_name_hash->find_slot_with_hash (name, hash, INSERT);
   gcc_assert (*aslot != node);
@@ -209,6 +214,10 @@ symbol_table::unlink_from_assembler_name
{
  tree name = DECL_ASSEMBLER_NAME (node->decl);
   symtab_node **slot;
+
+ if (!name)
+   return;
+
  hashval_t hash = decl_assembler_name_hash (name);
  slot = assembler_name_hash->find_slot_with_hash (name, hash,
   NO_INSERT);


PR ipa/61602 (ICE in single_use propagation)

2014-12-14 Thread Jan Hubicka
Hi,
this testcase is another place where we leave dead symbols in the symtab and 
thus
ipa-single-use propagation fails.  Bootstrapped/regtested x86_64-linux, 
comitted.
PR ipa/61602
* gcc.dg/torture/pr61602.c: New testcase.

* cgraph.h (ipa_discover_readonly_nonaddressable_vars): Return bool.
* ipa.c (set_writeonly_bit): Track if reference was removed.
(ipa_discover_readonly_nonaddressable_vars): Return true if any
references was removed.
* ipa-reference.c (propagate): Return TODO_remove_functions if
reference was removed.
Index: testsuite/gcc.dg/torture/pr61602.c
===
--- testsuite/gcc.dg/torture/pr61602.c  (revision 0)
+++ testsuite/gcc.dg/torture/pr61602.c  (revision 0)
@@ -0,0 +1,8 @@
+int a;
+int *b = &a, **c = &b;
+int
+main ()
+{
+  int **d = &b;
+  *d = 0;
+}
Index: cgraph.h
===
--- cgraph.h(revision 218726)
+++ cgraph.h(working copy)
@@ -2188,7 +2188,7 @@ void record_references_in_initializer (t
 
 /* In ipa.c  */
 void cgraph_build_static_cdtor (char which, tree body, int priority);
-void ipa_discover_readonly_nonaddressable_vars (void);
+bool ipa_discover_readonly_nonaddressable_vars (void);
 
 /* In varpool.c  */
 tree ctor_for_folding (tree);
Index: ipa.c
===
--- ipa.c   (revision 218730)
+++ ipa.c   (working copy)
@@ -714,14 +714,18 @@ set_readonly_bit (varpool_node *vnode, v
 /* Set writeonly bit and clear the initalizer, since it will not be needed.  */
 
 bool
-set_writeonly_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED)
+set_writeonly_bit (varpool_node *vnode, void *data)
 {
   vnode->writeonly = true;
   if (optimize)
 {
   DECL_INITIAL (vnode->decl) = NULL;
   if (!vnode->alias)
-   vnode->remove_all_references ();
+   {
+ if (vnode->num_references ())
+   *(bool *)data = true;
+ vnode->remove_all_references ();
+   }
 }
   return false;
 }
@@ -739,15 +743,18 @@ clear_addressable_bit (varpool_node *vno
 /* Discover variables that have no longer address taken or that are read only
and update their flags.
 
+   Return true when unreachable symbol removan should be done.
+
FIXME: This can not be done in between gimplify and omp_expand since
readonly flag plays role on what is shared and what is not.  Currently we do
this transformation as part of whole program visibility and re-do at
ipa-reference pass (to take into account clonning), but it would
make sense to do it before early optimizations.  */
 
-void
+bool
 ipa_discover_readonly_nonaddressable_vars (void)
 {
+  bool remove_p = false;
   varpool_node *vnode;
   if (dump_file)
 fprintf (dump_file, "Clearing variable flags:");
@@ -762,14 +769,16 @@ ipa_discover_readonly_nonaddressable_var
bool read = false;
bool explicit_refs = true;
 
-   process_references (vnode, &written, &address_taken, &read, 
&explicit_refs);
+   process_references (vnode, &written, &address_taken, &read,
+   &explicit_refs);
if (!explicit_refs)
  continue;
if (!address_taken)
  {
if (TREE_ADDRESSABLE (vnode->decl) && dump_file)
  fprintf (dump_file, " %s (non-addressable)", vnode->name ());
-   vnode->call_for_node_and_aliases (clear_addressable_bit, NULL, 
true);
+   vnode->call_for_node_and_aliases (clear_addressable_bit, NULL,
+ true);
  }
if (!address_taken && !written
/* Making variable in explicit section readonly can cause section
@@ -785,11 +794,13 @@ ipa_discover_readonly_nonaddressable_var
  {
if (dump_file)
  fprintf (dump_file, " %s (write-only)", vnode->name ());
-   vnode->call_for_node_and_aliases (set_writeonly_bit, NULL, true);
+   vnode->call_for_node_and_aliases (set_writeonly_bit, &remove_p, 
+true);
  }
   }
   if (dump_file)
 fprintf (dump_file, "\n");
+  return remove_p;
 }
 
 /* Free inline summary.  */
Index: ipa-reference.c
===
--- ipa-reference.c (revision 218726)
+++ ipa-reference.c (working copy)
@@ -676,11 +676,12 @@ propagate (void)
 XCNEWVEC (struct cgraph_node *, symtab->cgraph_count);
   int order_pos;
   int i;
+  bool remove_p;
 
   if (dump_file)
 cgraph_node::dump_cgraph (dump_file);
 
-  ipa_discover_readonly_nonaddressable_vars ();
+  remove_p = ipa_discover_readonly_nonaddressable_vars ();
   generate_summary ();
 
   /* Propagate the local information through the call graph to produce
@@ -867,7 +868,7 @@ propagate (void)
   if (dump_file)
 splay_tree_delete (reference_vars_to_consider);
   r

Fix streaming of target optimization/option nodes

2014-12-14 Thread Jan Hubicka
Hi,
the testcase in PR ipa/61324 fails because it is compiled with -O0 and linked 
with -O2.
This should not matter anymore if there wasn't the following problem in 
streamer that
makes us to merge all default nodes across units.

Bootstrapped/regtested x86_64-linux, plan to commit it after more testing 
finishes (Firefox)

Honza

PR ipa/61324
* tree-streamer.c (preload_common_nodes): Do not ocnsider optimizatoin
nad target_option nodes as common nodes; they depend on flags.

Index: tree-streamer.c
===
--- tree-streamer.c (revision 218726)
+++ tree-streamer.c (working copy)
@@ -324,7 +324,14 @@ preload_common_nodes (struct streamer_tr
 /* Skip boolean type and constants, they are frontend dependent.  */
 if (i != TI_BOOLEAN_TYPE
&& i != TI_BOOLEAN_FALSE
-   && i != TI_BOOLEAN_TRUE)
+   && i != TI_BOOLEAN_TRUE
+   /* Skip optimization and target option nodes; they depend on flags.  */
+   && i != TI_OPTIMIZATION_DEFAULT
+   && i != TI_OPTIMIZATION_CURRENT
+   && i != TI_TARGET_OPTION_DEFAULT
+   && i != TI_TARGET_OPTION_CURRENT
+   && i != TI_CURRENT_TARGET_PRAGMA
+   && i != TI_CURRENT_OPTIMIZE_PRAGMA)
   record_common_node (cache, global_trees[i]);
 }
 


Re: [Patch, Fortran] PR 63674: procedure pointer and non/pure procedure

2014-12-14 Thread Tobias Burnus

Janus Weil wrote:

2014-12-14 12:00 GMT+01:00 FX :

Good point, thank you. Updated patch attached.
I guess I still new formal approval by someone with reviewer status …

OK

Thanks, committed as r218717.


Can you change "non-pure" to "impure"? That would better match the 
Fortran naming, where "impure" is the default unless "pure" or 
"elemental" is used. (It was added to permit "impure elemental" procedures.)


Tobias


PR 62053

2014-12-14 Thread Jan Hubicka

Hi,
this patch fixes type inconsistency in between main variant and its variant.
This is caused by build_cplus_array_type first laying down the type and only 
then
linking it into vairant chain.

Bootstrapped/regtested x86_64-linux, OK?

Honza

PR tree-optimization/62053
* tree.c (build_cplus_array_type): Layout type after variants are set.
Index: tree.c
===
--- tree.c  (revision 216141)
+++ tree.c  (working copy)
@@ -863,12 +863,12 @@ build_cplus_array_type (tree elt_type, t
{
  t = build_min_array_type (elt_type, index_type);
  set_array_type_canon (t, elt_type, index_type);
- if (!dependent)
-   layout_type (t);
 
  TYPE_MAIN_VARIANT (t) = m;
  TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
  TYPE_NEXT_VARIANT (m) = t;
+ if (!dependent)
+   layout_type (t);
}
 }
 



PING for gcc/flag-types.h (was: Re: [Patch, gcc/flag-types.h + Fortran] PR54687 - Fortran options cleanup)

2014-12-14 Thread Tobias Burnus
The Fortran part of the .opt changes has been approved, but for Enum(), 
some bits had to be moved to gcc/flag-types.h – and review for that file 
is still missing.


https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01068.html

Tobias


Tobias Burnus wrote:
This patch cleans up Fortran's option handling and moves it closer to 
the common way of option handling. That's a nice cleanup and 
additionally, as Manuel points out in the PR, there are a couple of 
reasons why this makes sense in addition. I have not yet touched all 
options but one has to start somewhere.


Built and currently regtesting on x86-64-gnu-linux.
OK for the trunk?

Tobias




[PATCH] gcc/testsuite/gcc.dg/typeof-2.c

2014-12-14 Thread Sebastian Huber
gcc/testsuite/ChangeLog
2014-12-15  Sebastian Huber  

* gcc.dg/typeof-2.c: Add checks for non-atomic types.
---
 gcc/testsuite/gcc.dg/typeof-2.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/typeof-2.c b/gcc/testsuite/gcc.dg/typeof-2.c
index e916900..21ef5b0 100644
--- a/gcc/testsuite/gcc.dg/typeof-2.c
+++ b/gcc/testsuite/gcc.dg/typeof-2.c
@@ -2,6 +2,8 @@
 /* { dg-do compile } */
 /* { dg-options "-std=c11" } */
 
+/* Check that the qualifiers are discarded for atomic types. */
+
 extern int i;
 
 extern int * p;
@@ -26,3 +28,32 @@ void f(void)
   __auto_type ari = ri;
   int **pari = &ari;
 }
+
+/* Check that the qualifiers are preserved for non-atomic types. */
+
+extern int const j;
+
+extern int volatile k;
+
+extern int * restrict q;
+
+extern int const nci;
+extern __typeof (nci) j;
+
+extern int volatile nvi;
+extern __typeof (nvi) k;
+
+extern int * restrict nri;
+extern __typeof (nri) q;
+
+void g(void)
+{
+  __auto_type aci = nci;
+  int const *paci = &aci;
+
+  __auto_type avi = nvi;
+  int volatile *pavi = &avi;
+
+  __auto_type ari = nri;
+  int * restrict *pari = &ari;
+}
-- 
1.8.4.5



Re: Fix streaming of target optimization/option nodes

2014-12-14 Thread Jan Hubicka
Hi,
actually this patch break fortran, I get streaming error in:
lto1: internal compiler error: in streamer_get_pickled_tree
apparently picking error_mark_node for variable constructor results in reading 
integer_type...

Honza
> Hi,
> the testcase in PR ipa/61324 fails because it is compiled with -O0 and linked 
> with -O2.
> This should not matter anymore if there wasn't the following problem in 
> streamer that
> makes us to merge all default nodes across units.
> 
> Bootstrapped/regtested x86_64-linux, plan to commit it after more testing 
> finishes (Firefox)
> 
> Honza
> 
>   PR ipa/61324
>   * tree-streamer.c (preload_common_nodes): Do not ocnsider optimizatoin
>   nad target_option nodes as common nodes; they depend on flags.
> 
> Index: tree-streamer.c
> ===
> --- tree-streamer.c   (revision 218726)
> +++ tree-streamer.c   (working copy)
> @@ -324,7 +324,14 @@ preload_common_nodes (struct streamer_tr
>  /* Skip boolean type and constants, they are frontend dependent.  */
>  if (i != TI_BOOLEAN_TYPE
>   && i != TI_BOOLEAN_FALSE
> - && i != TI_BOOLEAN_TRUE)
> + && i != TI_BOOLEAN_TRUE
> + /* Skip optimization and target option nodes; they depend on flags.  */
> + && i != TI_OPTIMIZATION_DEFAULT
> + && i != TI_OPTIMIZATION_CURRENT
> + && i != TI_TARGET_OPTION_DEFAULT
> + && i != TI_TARGET_OPTION_CURRENT
> + && i != TI_CURRENT_TARGET_PRAGMA
> + && i != TI_CURRENT_OPTIMIZE_PRAGMA)
>record_common_node (cache, global_trees[i]);
>  }
>