Handle OBJ_TYPE_REF in operand_equal_p

2015-10-24 Thread Jan Hubicka
Hello,
this patch adds OBJ_TYPE_REF that is the only code handled by ipa-icf-gimple
but not bu operand_equal_p.  I tried to make the following testcase:

/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre" } */
struct foo {
  virtual int test ();
};

int ret (struct foo *f, int v)
{
   return v ? f->test() : f->test();
}
/* { dg-final { scan-tree-dump-not "if " "pre"} } */

But we fail to tailmerge the code:
  :
  if (v_3(D) != 0)
goto ;
  else
goto ;

  :
  _6 = f_5(D)->_vptr.foo;
  _7 = *_6;
  _9 = OBJ_TYPE_REF(_7;(struct foo)f_5(D)->0) (f_5(D)); [tail call]
  goto ;

  :
  _10 = f_5(D)->_vptr.foo;
  _11 = *_10;
  _13 = OBJ_TYPE_REF(_11;(struct foo)f_5(D)->0) (f_5(D)); [tail call]

This is because the OBJ_TYPE_REF are not equal without unifing _7 with _11
and _6 with _10 that we don't do, because we don't have head merging.

We ought to be able to do so once tail merge is witched to ipa-icf-gimple
and ipa-icf-gimple to operand_equal_p.  Otherwsie i think we are hitting to 
limitation of tree-ssa-sccvn that may want similar matching somewhere.

Once I have bit of time I will work on removing of OBJ_TYPE_REF wrappers
produced by objective-C in gimplification and then all the
virtual_method_call_p calls can go. The naive approach of simply not building
them does not work, perhaps we want to have separate OBJC tree code, since they
do not really represent virtual calls after all, but I got stuck on adding new
tree codes to objc becuase handling of tree.def between C/C++/obj-C/obj-C++
FEs is very convoluted.

Bootstrapped/regtested x86_64-linx, OK?

Honza


* fold-const.c (operand_equal_p): Handle OBJ_TYPE_REF

Index: fold-const.c
===
--- fold-const.c(revision 229278)
+++ fold-const.c(working copy)
@@ -3085,6 +3082,27 @@ operand_equal_p (const_tree arg0, const_
case DOT_PROD_EXPR:
  return OP_SAME (0) && OP_SAME (1) && OP_SAME (2);
 
+   case OBJ_TYPE_REF:
+ /* OBJ_TYPE_REF is just a wrapper around OBJ_TYP_REF_EXPR.  */
+ if (!operand_equal_p (OBJ_TYPE_REF_EXPR (arg0),
+   OBJ_TYPE_REF_EXPR (arg1), flags))
+   return false;
+
+ /* Objective-C frontend produce ill formed OBJ_TYPE_REF which
+probably should be dropped before reaching middle-end.  */
+ if (!virtual_method_call_p (arg0) || !virtual_method_call_p (arg1))
+   return false;
+
+ /* Match the type information stored in the wrapper.  */
+
+ flags &= ~(OEP_CONSTANT_ADDRESS_OF|OEP_ADDRESS_OF);
+ return (tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg0))
+ == tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg1))
+ && types_same_for_odr (obj_type_ref_class (arg0),
+obj_type_ref_class (arg1))
+ && operand_equal_p (OBJ_TYPE_REF_OBJECT (arg0),
+ OBJ_TYPE_REF_OBJECT (arg1),
+ flags));
default:
  return 0;
}


[gomp4] Merge trunk r229177 (2015-10-22) into gomp-4_0-branch

2015-10-24 Thread Thomas Schwinge
Hi!

Committed to gomp-4_0-branch in r229286:

commit 1f455fe59102d51011da2ef885731830c3c24368
Merge: 1bc39c0 ecebe44
Author: tschwinge 
Date:   Sat Oct 24 14:34:38 2015 +

svn merge -r 228777:229177 svn+ssh://gcc.gnu.org/svn/gcc/trunk


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@229286 
138bc75d-0d04-0410-961f-82ee72b054a4


Grüße
 Thomas


signature.asc
Description: PGP signature


Re; [Patch, fortran] PR67171 - [6 regression] sourced allocation

2015-10-24 Thread Dominique d'Humières
Dear Paul,

AFAICT no patch!

Dominique



Re: [Patch, fortran] PR67171 - [6 regression] sourced allocation

2015-10-24 Thread Paul Richard Thomas
Shucks! Here it is

On 24 October 2015 at 15:08, Paul Richard Thomas
 wrote:
> Dear All,
>
> This patch does four things:
> (i) On deallocating class components, the vptr is set to point to the
> vtable of the declared type;
> (ii) When digging out the last class reference, a NULL is returned if
> the allocatable component is to the right of a part reference with
> non-zero rank, so that the resulting ICE is removed. The previous
> modification takes care of these cases for gfc_reset_vptr and
> gfc_reset_len;
> (iii) gfc_reset_vptr has been simplified by the use of
> gfc_get_vptr_from_expr; and
> (iv) All variable expressions for the source are passed to
> gfc_trans-assignment, so that array sections work correctly.
>
> I see that Andre has already reserved the testcase
> allocate_with_source_10, for the pending patch that I undertook to
> review, so I will change this to #12 on submission
>
> OK for trunk?
>
> Cheers
>
> Paul
>
> 2015-01-24  Paul Thomas  
>
> PR fortran/67171
> * trans-array.c (structure_alloc_comps): On deallocation of
> class components, reset the vptr to the declared type vtable
> and reset the _len field of unlimited polymorphic components.
> *trans-expr.c (gfc_find_and_cut_at_last_class_ref): Bail out on
> allocatable component references to the right of part reference
> with non-zero rank and return NULL.
> (gfc_reset_vptr): Simplify this function by using the function
> gfc_get_vptr_from_expr. Return if the vptr is NULL_TREE.
> (gfc_reset_len): If gfc_find_and_cut_at_last_class_ref returns
> NULL return.
> * trans-stmt.c (gfc_trans_allocate): Rely on the use of
> gfc_trans_assignment if expr3 is a variable expression since
> this deals correctly with array sections.
>
> 2015-01-24  Paul Thomas  
>
> PR fortran/67171
> * gfortran.dg/allocate_with_source_10.f03: New test



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx
Index: gcc/fortran/trans-array.c
===
*** gcc/fortran/trans-array.c   (revision 229283)
--- gcc/fortran/trans-array.c   (working copy)
*** structure_alloc_comps (gfc_symbol * der_
*** 8012,8017 
--- 8012,8043 
 build_int_cst (TREE_TYPE (comp), 0));
}
  gfc_add_expr_to_block (, tmp);
+ 
+ /* Finally, reset the vptr to the declared type vtable and, if
+necessary reset the _len field.  */
+ comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
+decl, cdecl, NULL_TREE);
+ tmp = gfc_class_vptr_get (comp);
+ if (UNLIMITED_POLY (c))
+   {
+ gfc_add_modify (, tmp,
+ build_int_cst (TREE_TYPE (tmp), 0));
+ tmp = gfc_class_len_get (comp);
+ gfc_add_modify (, tmp,
+ build_int_cst (TREE_TYPE (tmp), 0));
+   }
+ else
+   {
+ tree vtab;
+ gfc_symbol *vtable;
+ vtable = gfc_find_derived_vtab (c->ts.u.derived);
+ vtab = vtable->backend_decl;
+ if (vtab == NULL_TREE)
+   vtab = gfc_get_symbol_decl(vtable);
+ vtab = gfc_build_addr_expr (NULL, vtab);
+ vtab = fold_convert (TREE_TYPE (tmp), vtab);
+ gfc_add_modify (, tmp, vtab);
+   }
}
  
  if (cmp_has_alloc_comps
Index: gcc/fortran/trans-expr.c
===
*** gcc/fortran/trans-expr.c(revision 229283)
--- gcc/fortran/trans-expr.c(working copy)
*** gfc_expr *
*** 271,285 
  gfc_find_and_cut_at_last_class_ref (gfc_expr *e)
  {
gfc_expr *base_expr;
!   gfc_ref *ref, *class_ref, *tail;
  
/* Find the last class reference.  */
class_ref = NULL;
for (ref = e->ref; ref; ref = ref->next)
  {
if (ref->type == REF_COMPONENT
  && ref->u.c.component->ts.type == BT_CLASS)
class_ref = ref;
  
if (ref->next == NULL)
break;
--- 271,297 
  gfc_find_and_cut_at_last_class_ref (gfc_expr *e)
  {
gfc_expr *base_expr;
!   gfc_ref *ref, *class_ref, *tail, *array_ref;
  
/* Find the last class reference.  */
class_ref = NULL;
+   array_ref = NULL;
for (ref = e->ref; ref; ref = ref->next)
  {
+   if (ref->type == REF_ARRAY
+ && ref->u.ar.type != AR_ELEMENT)
+   array_ref = ref;
+ 
if (ref->type == REF_COMPONENT
  && ref->u.c.component->ts.type == BT_CLASS)
+   {
+ /* Component to the right of a part reference with nonzero rank
+must not have the ALLOCATABLE attribute.  

Re: [PATCH] PR28901 -Wunused-variable ignores unused const initialised variables

2015-10-24 Thread Gerald Pfeifer
On Wed, 7 Oct 2015, Bernd Schmidt wrote:
> I think not using -Wall -Werror is the right fix.

Of course there is a fair chance (and I'll likely end up proposing
this for Wine) is that people will use -Wnounused-variable instead.

Which will disable _all_ such warnings, not only those coming from
  const ... ... = ...;
in C header files.

Gerald


Re: [PATCH] PR28901 -Wunused-variable ignores unused const initialised variables

2015-10-24 Thread Mark Wielaard
On Sat, 2015-10-24 at 15:47 +0200, Gerald Pfeifer wrote:
> On Wed, 7 Oct 2015, Bernd Schmidt wrote:
> > I think not using -Wall -Werror is the right fix.
> 
> Of course there is a fair chance (and I'll likely end up proposing
> this for Wine) is that people will use -Wnounused-variable instead.
> 
> Which will disable _all_ such warnings, not only those coming from
>   const ... ... = ...;

Then use -Wno-unused-const-variable, not -Wno-unused-variable, if you
only want to suppress the new warning.

Cheers,

Mark


Re: [PATCH] gcc/fold-const.c: Correct the report warning position.

2015-10-24 Thread Chen Gang
Hello all:

After have a test, "gcc version 6.0.0 20151023 (experimental) (GCC)" has
no this issue. And bug63510 can be closed. :-)

So for me, we need not spend additional time resources on it. I shall
continue to other issues in gcc or qemu. Now, I guess, my 1st priority
is to rewrite tilegx qemu floating point insns within 2015-10-31.

Welcome additional ideas, suggestions, and completions.

Thanks.

On 10/24/15 08:15, Chen Gang wrote:
> 
> On 10/23/15 16:56, Richard Biener wrote:
>> On Thu, Oct 22, 2015 at 9:46 PM, Jeff Law  wrote:
>>>
>>> Note that the call to fold_binary from tree-ssa-sccvn.c has been removed.
>>> So that hunk either needs to be removed or the change applied elsewhere.
>>>
> 
> Oh, really, it uses gimple_simplify instead of.
> 
>>> I think passing around the location through fold-const.c is OK.
>>>
> 
> OK, thanks.
> 
>>> I'd like to see a testcase in a form ready for inclusion into the testsuite.
> 
> OK, thanks, I shall try.
> 
>>
>> As an additional remark - I'd like to see us not use input_location
>> but always loc,
> 
> For me, it sounds reasonable.
> 
>> even if UNKNOWN_LOCATION.  The diagnostic machinery should handle this
>> correctly(?).  That is, if bootstrap/testign doesn't show testsuite
>> regressions because
>> of this.
>>
> 
> I will try.
> 
> 
> Hope I can finish trying above all within 2 days (2015-10-25).
> 
> 
> Thanks.
> 

-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed


[Patch, fortran] PR67171 - [6 regression] sourced allocation

2015-10-24 Thread Paul Richard Thomas
Dear All,

This patch does four things:
(i) On deallocating class components, the vptr is set to point to the
vtable of the declared type;
(ii) When digging out the last class reference, a NULL is returned if
the allocatable component is to the right of a part reference with
non-zero rank, so that the resulting ICE is removed. The previous
modification takes care of these cases for gfc_reset_vptr and
gfc_reset_len;
(iii) gfc_reset_vptr has been simplified by the use of
gfc_get_vptr_from_expr; and
(iv) All variable expressions for the source are passed to
gfc_trans-assignment, so that array sections work correctly.

I see that Andre has already reserved the testcase
allocate_with_source_10, for the pending patch that I undertook to
review, so I will change this to #12 on submission

OK for trunk?

Cheers

Paul

2015-01-24  Paul Thomas  

PR fortran/67171
* trans-array.c (structure_alloc_comps): On deallocation of
class components, reset the vptr to the declared type vtable
and reset the _len field of unlimited polymorphic components.
*trans-expr.c (gfc_find_and_cut_at_last_class_ref): Bail out on
allocatable component references to the right of part reference
with non-zero rank and return NULL.
(gfc_reset_vptr): Simplify this function by using the function
gfc_get_vptr_from_expr. Return if the vptr is NULL_TREE.
(gfc_reset_len): If gfc_find_and_cut_at_last_class_ref returns
NULL return.
* trans-stmt.c (gfc_trans_allocate): Rely on the use of
gfc_trans_assignment if expr3 is a variable expression since
this deals correctly with array sections.

2015-01-24  Paul Thomas  

PR fortran/67171
* gfortran.dg/allocate_with_source_10.f03: New test


[PATCH] PR fortran/68054 -- PROTECTED in modules only

2015-10-24 Thread Steve Kargl
The attached patch fixes an ICE that occurs when gfortran 
is not expecting a PROTECTED attribute.  Built and tested
on x86_64-*-freebsd.  OK to commit?


2015-10-24  Steven G. Kargl  

PR fortran/68054
* decl.c (match_attr_spec): PROTECTED can only be a module.

2015-10-24  Steven G. Kargl  

PR fortran/68054
* gfortran.dg/pr68054.f90: New test.

-- 
Steve
Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c	(revision 229288)
+++ gcc/fortran/decl.c	(working copy)
@@ -3957,7 +3957,9 @@ match_attr_spec (void)
 	  break;
 
 	case DECL_PROTECTED:
-	  if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
+	  if (gfc_current_state () != COMP_MODULE
+	  || (gfc_current_ns->proc_name
+		  && gfc_current_ns->proc_name->attr.flavor != FL_MODULE))
 	{
 	   gfc_error ("PROTECTED at %C only allowed in specification "
 			  "part of a module");
Index: gcc/testsuite/gfortran.dg/pr68054.f90
===
--- gcc/testsuite/gfortran.dg/pr68054.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr68054.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/68054
+! Original code contributed by Gerhard Steinmetz
+! gerhard dot steinmetz dot fortran at t-online dot de
+!
+!program p
+   real, protected :: x   ! { dg-error "only allowed in specification" }
+end


Re: [PATCH] PR fortran/67805 -- Check for invalid charlength

2015-10-24 Thread Mikael Morin

Le 24/10/2015 21:29, Dominique d'Humières a écrit :

At revision r229288 compiling the following test


[...]


while it compiles without error at r229261.

I believe the accesses to ref->u.ar should be guarded with ref->type == 
REF_ARRAY.

Steve, a patch doing that is preapproved.

Mikael


Re: r229279 - in /trunk/gcc: ChangeLog ipa-polymorp...

2015-10-24 Thread Andreas Schwab
FAIL: g++.dg/torture/pr67600.C   -O0  (test for excess errors)
Excess errors:
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_algobase.h:61:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/char_traits.h:39,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:40,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/cpp_type_traits.h:259:40: 
error: template argument 1 is invalid
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/cpp_type_traits.h:259:145: 
error: template argument 1 is invalid
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/move.h:57:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_pair.h:59,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_algobase.h:64,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/char_traits.h:39,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:40,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:258:41: error: 
template argument 1 is invalid
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:262:50: error: 
template argument 1 is invalid
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/move.h:57:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_pair.h:59,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_algobase.h:64,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/char_traits.h:39,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:40,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:317:39: error: 
'__float128' was not declared in this scope
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:317:49: error: 
template argument 1 is invalid
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/move.h:57:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_pair.h:59,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_algobase.h:64,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/char_traits.h:39,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:40,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:1704:36: error: 
template argument 1 is invalid
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/move.h:57:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_pair.h:59,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/stl_algobase.h:64,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/char_traits.h:39,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:40,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/type_traits:1823:43: error: 
template argument 1 is invalid
In file included from 
/aux/hubicka/trunk-install/include/c++/6.0.0/ext/new_allocator.h:33:0,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/allocator.h:46,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/string:41,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/locale_classes.h:40,
 from 
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/ios_base.h:41,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ios:42,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/ostream:38,
 from /aux/hubicka/trunk-install/include/c++/6.0.0/iostream:39,
 from t.C:1:
/aux/hubicka/trunk-install/include/c++/6.0.0/new:112:41: error: 'operator new' 
takes type 'size_t' ('unsigned int') as first parameter [-fpermissive]
/aux/hubicka/trunk-install/include/c++/6.0.0/new:114:41: error: 'operator new' 
takes type 'size_t' ('unsigned int') as first parameter [-fpermissive]

[patch] Define std::invoke()

2015-10-24 Thread Jonathan Wakely

This implements C++17's std::invoke(), as a call to std::__invoke() so
we can also use it in C++11 and C++14.

This includes the resolution of LWG 2219 which was just passed in
Kona.

Tested powerpc64le-linux, committed to trunk.


commit 9eb38ac574c84c515c98db57abc73581d50a45dd
Author: Jonathan Wakely 
Date:   Thu Oct 22 22:08:01 2015 +0100

Implement C++17 std::invoke and LWG DR 2219

	* include/std/functional (__invoke_impl): New overloads.
	(__invoke): Replace with a single function calling __invoke_impl.
	(invoke): Add C++17 std::invoke.
	(reference_wrapper::operator()): Qualify call to __invoke.
	(_Mem_fn_traits_base, _Mem_fn_traits): Remove unused typedefs.
	(_Mem_fn_base): Remove unused typedefs and implement call operator in
	terms of __invoke.
	* include/std/future (__future_base::_Async_state_commonV2): Do not
	pass reference_wrapper as object argument to call_once.
	* include/std/type_traits (result_of): Define nested __invoke_type.
	Handle reference_wrapper as per LWG 2219.
	* testsuite/20_util/bind/ref_neg.cc: Adjust dg-error directives.
	* testsuite/20_util/function_objects/mem_fn/55463.cc: Remove tests
	using member functions of reference_wrapper.

diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 7dd149a..f1dc839 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -184,48 +184,77 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : _Weak_result_type_impl::type>
 { };
 
-  /**
-   * Invoke a function object, which may be either a member pointer or a
-   * function object. The first parameter will tell which.
-   */
-  template
-inline
-typename enable_if<
-	 (!is_member_pointer<_Functor>::value
-	  && !is_function<_Functor>::value
-	  && !is_function::type>::value),
-	 typename result_of<_Functor&(_Args&&...)>::type
-	   >::type
-__invoke(_Functor& __f, _Args&&... __args)
+  template
+inline _Res
+__invoke_impl(__invoke_other, _Fn&& __f, _Args&&... __args)
+noexcept(noexcept(std::forward<_Fn>(__f)(std::forward<_Args>(__args)...)))
+{ return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memfun_ref, _MemFun&& __f, _Tp&& __t,
+		  _Args&&... __args)
+noexcept(noexcept((forward<_Tp>(__t).*__f)(forward<_Args>(__args)...)))
+{ return (forward<_Tp>(__t).*__f)(forward<_Args>(__args)...); }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memfun_ref, _MemFun&& __f,
+		  reference_wrapper<_Tp> __t, _Args&&... __args)
+noexcept(noexcept((__t.get().*__f)(forward<_Args>(__args)...)))
+{ return (__t.get().*__f)(forward<_Args>(__args)...); }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t,
+		  _Args&&... __args)
+noexcept(noexcept(((*forward<_Tp>(__t)).*__f)(forward<_Args>(__args)...)))
+{ return ((*forward<_Tp>(__t)).*__f)(forward<_Args>(__args)...); }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memobj_ref, _MemFun&& __f, _Tp&& __t)
+noexcept(noexcept(forward<_Tp>(__t).*__f))
+{ return forward<_Tp>(__t).*__f; }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memobj_ref, _MemFun&& __f,
+		  reference_wrapper<_Tp> __t)
+noexcept(noexcept(__t.get().*__f))
+{ return __t.get().*__f; }
+
+  template
+inline _Res
+__invoke_impl(__invoke_memobj_deref, _MemFun&& __f, _Tp&& __t,
+		  _Args&&... __args)
+noexcept(noexcept((*forward<_Tp>(__t)).*__f))
+{ return (*forward<_Tp>(__t)).*__f; }
+
+  /// Invoke a callable object.
+  template
+inline typename result_of<_Callable&&(_Args&&...)>::type
+__invoke(_Callable&& __fn, _Args&&... __args)
 {
-  return __f(std::forward<_Args>(__args)...);
+  using __result_of = result_of<_Callable&&(_Args&&...)>;
+  using __type = typename __result_of::type;
+  using __tag = typename __result_of::__invoke_type;
+  return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
+	std::forward<_Args>(__args)...);
 }
 
-  template
-inline
-typename enable_if<
- (is_member_pointer<_Functor>::value
-  && !is_function<_Functor>::value
-  && !is_function::type>::value),
- typename result_of<_Functor(_Args&&...)>::type
-   >::type
-__invoke(_Functor& __f, _Args&&... __args)
-{
-  return std::mem_fn(__f)(std::forward<_Args>(__args)...);
-}
+#if __cplusplus > 201402L
+# define __cpp_lib_invoke 201411
 
-  // To pick up function references (that will become function pointers)
-  template
-inline
-typename enable_if<
-	 (is_pointer<_Functor>::value
-	  && is_function::type>::value),
-	 typename result_of<_Functor(_Args&&...)>::type
-	   >::type
-__invoke(_Functor __f, _Args&&... __args)
+  /// Invoke a callable object.
+  template

Re: Re; [Patch, fortran] PR67171 - [6 regression] sourced allocation

2015-10-24 Thread Dominique d'Humières

> Le 24 oct. 2015 à 15:46, Dominique d'Humières  a écrit :
> 
> Dear Paul,
> 
> AFAICT no patch!
> 
> Dominique
> 

If I am not mistaken, your patch fixes pr67528 also.

Dominique



[patch] Make std::async return deferred if thread creation fails

2015-10-24 Thread Jonathan Wakely

This implements a suggestion from Nico that if the user requested
launch::async|launch::deferred and trying to create a new thread fails
then we should return a deferred function instead.

Tested powerp64le-linux, committed to trunk.

commit ce92109967225ed196cdca5afb185702e1fabc5e
Author: Jonathan Wakely 
Date:   Sat Oct 24 21:47:43 2015 +0100

Return deferred future if thread cannot be run

	* include/std/future (async): Use deferred function on exception.
	* testsuite/30_threads/async/except.cc: New.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 216a921..93889cd 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -1711,10 +1711,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   std::shared_ptr<__future_base::_State_base> __state;
   if ((__policy & launch::async) == launch::async)
 	{
-	  __state = __future_base::_S_make_async_state(std::__bind_simple(
-  std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
+	  __try
+	{
+	  __state = __future_base::_S_make_async_state(std::__bind_simple(
+		  std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
+	}
+#if __cpp_exceptions
+	  catch(const system_error& __e)
+	{
+	  if (__e.code() != errc::resource_unavailable_try_again
+		  || (__policy & launch::deferred) != launch::deferred)
+		throw;
+	}
+#endif
 	}
-  else
+  if (!__state)
 	{
 	  __state = __future_base::_S_make_deferred_state(std::__bind_simple(
   std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
diff --git a/libstdc++-v3/testsuite/30_threads/async/except.cc b/libstdc++-v3/testsuite/30_threads/async/except.cc
new file mode 100644
index 000..fda08dc
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/async/except.cc
@@ -0,0 +1,70 @@
+// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-rtems* *-*-darwin* powerpc-ibm-aix* } }
+// { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } }
+// { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-rtems* *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2010-2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+
+#include 
+#include 
+
+struct Chucky
+{
+  Chucky() : copied(false) { }
+
+  Chucky(const Chucky& other) : copied(true)
+  {
+if (other.copied)
+  return;
+other.copied = true;
+using namespace std;
+// Throw on first DECAY_COPY to simulate inability to start a new thread.
+throw system_error(make_error_code(errc::resource_unavailable_try_again));
+  }
+
+  void operator()() const { }
+
+  mutable bool copied;
+};
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  using namespace std;
+
+  future f = async(Chucky{});
+  VERIFY( f.wait_for(chrono::seconds(100)) == future_status::deferred );
+
+  bool caught = false;
+  try {
+f = async(launch::async, Chucky{});
+  } catch (const system_error&) {
+caught = true;
+  }
+  VERIFY( caught );
+}
+
+int main()
+{
+  test01();
+}


Re: [PATCH] PR fortran/67805 -- Check for invalid charlength

2015-10-24 Thread Dominique d'Humières
At revision r229288 compiling the following test

  implicit none

  type :: template_t
 integer :: type
 character(256) :: charset1, charset2
 integer :: len1, len2
  end type template_t

contains

  subroutine match_quoted (tt, s, n, range)
type(template_t), intent(in) :: tt
character(*), intent(in) :: s
integer, intent(out) :: n
integer, dimension(2), intent(out) :: range
character(tt%len1) :: ch1
character(tt%len2) :: ch2
integer :: i
ch1 = tt%charset1
if (s(1:tt%len1) == ch1) then
   ch2 = tt%charset2
   do i = tt%len1 + 1, len (s) - tt%len2 + 1
  if (s(i:i+tt%len2-1) == ch2) then
 n = i + tt%len2 - 1
 range(1) = tt%len1 + 1
 range(2) = i - 1
 return
  end if
   end do
   n = -1
   range = 0
else
   n = 0
   range = 0
end if
  end subroutine match_quoted

end

gives the following errors

pr40440_red_1.f90:16:14:

 character(tt%len1) :: ch1
  1
Error: Scalar INTEGER expression expected at (1)
pr40440_red_1.f90:17:14:

 character(tt%len2) :: ch2
  1
Error: Scalar INTEGER expression expected at (1)
pr40440_red_1.f90:19:7:

 ch1 = tt%charset1
   1
Error: Symbol 'ch1' at (1) has no IMPLICIT type
pr40440_red_1.f90:21:10:

ch2 = tt%charset2
  1
Error: Symbol 'ch2' at (1) has no IMPLICIT type

while it compiles without error at r229261.

TIA

Dominique



Re: Move some bit and binary optimizations in simplify and match

2015-10-24 Thread Marc Glisse

On Fri, 23 Oct 2015, Hurugalawadi, Naveen wrote:

+ (minus (bit_and:cs @0 (bit_not @1)) (bit_and:s @0 @1))

I am not sure why we have :c on one bit_and but not the other.

+ (bit_ior:c (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1))

Here on the other hand, I believe the :c on bit_ior is redundant.

--
Marc Glisse


[wwwdocs] PATCH for Re: GCC Mirror

2015-10-24 Thread Gerald Pfeifer
On Sat, 24 Oct 2015, Scott Haiden wrote:
> The US, Saint Louis mirror (http://gcc.petsads.us) seems to host only 
> ads. I am not sure if this is a mistake on their part or if they're 
> aware of it or not, but I figured I'd let somebody know just in case.

I do hope it's just a mistake and wasn't the original plan to begin
with, but this is now the second (or third?9 such mirror site this
year, which is a little disappointing, if not annoying.

Fixed with the patch below, and let me copy Sergey who originally
nominated this mirror.

Gerald

Index: mirrors.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/mirrors.html,v
retrieving revision 1.232
diff -r1.232 mirrors.html
50d49
< US, Saint Louis: http://gcc.petsads.us;>http://gcc.petsads.us, thanks to Sergey 
Kutserey (s.kutserey at gmail.com)


Re: [PATCH] PR fortran/68054 -- PROTECTED in modules only

2015-10-24 Thread Mikael Morin

Le 24/10/2015 19:50, Steve Kargl a écrit :

The attached patch fixes an ICE that occurs when gfortran
is not expecting a PROTECTED attribute.  Built and tested
on x86_64-*-freebsd.  OK to commit?


OK. Thanks.

Mikael


Re: [OpenACC 5/11] C++ FE changes

2015-10-24 Thread Cesar Philippidis
On 10/23/2015 07:37 PM, Cesar Philippidis wrote:
> On 10/23/2015 01:25 PM, Cesar Philippidis wrote:
>> On 10/22/2015 01:52 AM, Jakub Jelinek wrote:
>>> On Wed, Oct 21, 2015 at 03:18:55PM -0400, Nathan Sidwell wrote:
 This patch is the C++ changes matching the C ones of patch 4.  In
 finish_omp_clauses, the gang, worker, & vector clauses are handled the same
 as OpenMP's 'num_threads' clause.  One change to num_threads is the
 augmentation of a diagnostic to add %<...%>  markers to the clause name.
>>>
>>> Indeed, lots of older OpenMP diagnostics is missing %<...%> markers around
>>> keywords.  Something to fix eventually.
>>
>> I updated omp tasks and teams in semantics.c.
>>
 2015-10-20  Cesar Philippidis  
Thomas Schwinge  
James Norris  
Joseph Myers  
Julian Brown  
Nathan Sidwell 

* parser.c (cp_parser_omp_clause_name): Add auto, gang, seq,
vector, worker.
(cp_parser_oacc_simple_clause): New.
(cp_parser_oacc_shape_clause): New.
>>>
>>> What I've said for the C FE patch, plus:
>>>
 +if (cp_lexer_next_token_is (lexer, CPP_NAME)
 +|| cp_lexer_next_token_is (lexer, CPP_KEYWORD))
 +  {
 +tree name_kind = cp_lexer_peek_token (lexer)->u.value;
 +const char *p = IDENTIFIER_POINTER (name_kind);
 +if (kind == OMP_CLAUSE_GANG && strcmp ("static", p) == 0)
>>>
>>> As static is a keyword, wouldn't it be better to just handle that case
>>> using cp_lexer_next_token_is_keyword (lexer, RID_STATIC)?
>>>
>>> Also, what is the exact grammar of the shape arguments?
>>> Would be nice to describe the grammar, in the grammar you just say
>>> expression, at least for vector/worker, which is clearly not accurate.
>>>
>>> It seems the intent is that num: or length: or static: is optional, right?
>>> But if that is the case, you should treat those as parsed only if followed
>>> by :.  While static is a keyword, so you can't have a variable called like
>>> that, having vector(length) or vector(num) should not be rejected.
>>> So, I would have expected that it should test if it is RID_STATIC
>>> followed by CPP_COLON (and only in that case consume those tokens),
>>> or CPP_NAME of id followed by CPP_COLON (and only in that case consume those
>>> tokens), otherwise parse it as assignment expression.
>>
>> That function now peeks ahead to look for a colon, so now it can handle
>> variables with the name of clause keywords.
>>
>>> The C FE may have similar issue.  Plus of course there should be testsuite
>>> coverage for all the weird cases.
>>
>> I included a new test in a different patch because it's common to both c
>> and c++.
>>
 +  case OMP_CLAUSE_GANG:
 +  case OMP_CLAUSE_VECTOR:
 +  case OMP_CLAUSE_WORKER:
 +/* Operand 0 is the num: or length: argument.  */
 +t = OMP_CLAUSE_OPERAND (c, 0);
 +if (t == NULL_TREE)
 +  break;
 +
 +t = maybe_convert_cond (t);
>>>
>>> Can you explain the maybe_convert_cond calls (in both cases here,
>>> plus the preexisting in OMP_CLAUSE_VECTOR_LENGTH)?
>>> The reason why it is used for OpenMP if and final clauses is that those have
>>> a condition argument, either the condition is zero or non-zero (so
>>> effectively it is turned into a bool).
>>> But aren't the gang/vector/worker/vector_length arguments integers rather
>>> than conditions?  I'd expect that finish_omp_clauses should verify
>>> those operands are indeed integral expressions (if that is the requirement
>>> in the standard), as it is something that for C++ can't be verified during
>>> parsing, if arbitrary expressions are parsed there.
>>
>> It's probably a copy-and-paste error. This functionality was added
>> incrementally. I removed that check.
>>
 @@ -5959,32 +5990,58 @@ finish_omp_clauses (tree clauses, bool a
  break;
  
case OMP_CLAUSE_NUM_THREADS:
 -t = OMP_CLAUSE_NUM_THREADS_EXPR (c);
 -if (t == error_mark_node)
 -  remove = true;
 -else if (!type_dependent_expression_p (t)
 - && !INTEGRAL_TYPE_P (TREE_TYPE (t)))
 -  {
 -error ("num_threads expression must be integral");
 -remove = true;
 -  }
 -else
 -  {
 -t = mark_rvalue_use (t);
 -if (!processing_template_decl)
 -  {
 -t = maybe_constant_value (t);
 -if (TREE_CODE (t) == INTEGER_CST
 -&& tree_int_cst_sgn (t) != 1)
 -  {
 -warning_at (OMP_CLAUSE_LOCATION (c), 0,
 -"% value must be positive");
 -t = integer_one_node;
 -  }
 -t = 

Re: [OpenACC 4/11] C FE changes

2015-10-24 Thread Cesar Philippidis
On 10/24/2015 01:03 AM, Jakub Jelinek wrote:
> On Fri, Oct 23, 2015 at 07:31:51PM -0700, Cesar Philippidis wrote:
> 
>> +static tree
>> +c_parser_oacc_shape_clause (c_parser *parser, omp_clause_code kind,
>> +const char *str, tree list)
>> +{
>> +  const char *id = "num";
>> +  tree op0 = NULL_TREE, op1 = NULL_TREE, c;
>> +  location_t loc = c_parser_peek_token (parser)->location;
>> +
>> +  if (kind == OMP_CLAUSE_VECTOR)
>> +id = "length";
>> +
>> +  if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
>> +{
>> +  tree *op_to_parse = 
>> +  c_token *next;
>> +
>> +  c_parser_consume_token (parser);
>> +
>> +  do
>> +{
>> +  op_to_parse = 
>> +
>> +  /* Consume a comma if present.  */
>> +  if (c_parser_next_token_is (parser, CPP_COMMA))
>> +{
>> +  if (op0 == NULL && op1 == NULL)
>> +{
>> +  c_parser_error (parser, "unexpected argument");
>> +  goto cleanup_error;
>> +}
>> +
>> +  c_parser_consume_token (parser);
>> +}
> 
> This means you parse
> gang (, static: *)
> vector (, 5)
> etc., even when you error on it afterwards with unexpected argument,
> it is still different diagnostics from other invalid tokens immediately
> after the opening (.

So you didn't like how the error messages are inconsistent? It was
catching those errors.

I've added those new test cases. Unfortunately, c and c++ report
different error messages, so I had the make dg-error generic to that
line containing those types of errors.

> Also, loc and next are wrong if there is a valid comma.

Yeah, I don't think it needs to be adjusted in the loop. c_parser_error
already knows where to report the error at anyway.

> So I'm really wondering why
> gang (static: *, num: 5)
> works, because next is the CPP_COMMA token, so while
> c_parser_next_token_is (parser, CPP_NAME) matches the actual name,
> what exactly next->value contains is unclear.
> 
> I think it would be better to:
> 
>   tree ops[2] = { NULL_TREE, NULL_TREE };
> 
>   do
>   {
> // Note, declare these here
> c_token *next = c_parser_peek_token (parser);
> location_t loc = next->location;
> // Just use ops[idx] instead of *op_to_parse etc., though if you strongly
> // prefer *op_to_parse, I won't object.
> int idx = 0;
> // Note it seems generally the C parser doesn't check for CPP_KEYWORD
> // before calling c_parser_next_token_is_keyword.  And I'd just do it
> // for OMP_CLAUSE_GANG, which has it in the grammar.
> if (kind == OMP_CLAUSE_GANG
> && c_parser_next_token_is_keyword (parser, RID_STATIC))
>   {
> // ...
> // Your current code, except that for 
> if (c_parser_next_token_is (parser, CPP_MULT))
>   {
> c_parser_consume_token (parser);
> if (c_parser_next_token_is (parser, CPP_COMMA))
>   {
> c_parser_consume_token (parser);
> continue;
>   }
> break;
>   }
>   }
> else if (... num: / length: )
>   {
> // ...
>   }
> // ...
> mark_exp_read (expr);
> ops[idx] = expr;
> 
> if (kind == OMP_CLAUSE_GANG
> && c_parser_next_token_is (parser, CPP_COMMA))
>   {
> c_parser_consume_token (parser);
> continue;
>   }
> break;
>   }
>   while (1);
> 
>   if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
>   goto cleanup_error;
> 
> That way you don't parse something that is not in the grammar.

I did that. It turned out to be a little more compact than what I had
before. Is this OK for trunk?

Cesar

2015-10-24  Cesar Philippidis  
	Thomas Schwinge  
	James Norris  
	Joseph Myers  
	Julian Brown  
	Bernd Schmidt  

	gcc/c/
	* c-parser.c (c_parser_oacc_shape_clause): New.
	(c_parser_oacc_simple_clause): New.
	(c_parser_oacc_all_clauses): Add auto, gang, seq, vector, worker.
	(OACC_LOOP_CLAUSE_MASK): Add gang, worker, vector, auto, seq.

2015-10-24  Cesar Philippidis  

	gcc/testsuite/
	* c-c++-common/goacc/loop-shape.c: New test.

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index c8c6a2d..2ad3825 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11188,6 +11188,144 @@ c_parser_omp_clause_num_workers (c_parser *parser, tree list)
 }
 
 /* OpenACC:
+
+gang [( gang-arg-list )]
+worker [( [num:] int-expr )]
+vector [( [length:] int-expr )]
+
+  where gang-arg is one of:
+
+[num:] int-expr
+static: size-expr
+
+  and size-expr may be:
+
+*
+int-expr
+*/
+
+static tree
+c_parser_oacc_shape_clause (c_parser *parser, omp_clause_code kind,
+			const 

Re: TR1 Special Math

2015-10-24 Thread Jonathan Wakely
On 8 May 2015 at 15:05, Ed Smith-Rowland <3dw...@verizon.net> wrote:
> On 05/07/2015 12:06 PM, Jonathan Wakely wrote:
>>
>> Hi Ed,
>>
>> The C++ committee is considering the
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4437.pdf
>> proposal to make C++17 include the contents of ISO 29124:2010 (the
>> special math functions from TR1 that went into a separate standard,
>> not into C++11).
>>
>> What is the status of our TR1 implementation? Is it complete? Good
>> enough quality to move out of the tr1 sub-dir?
>>
>> Even if N4437 isn't accepted for C++17 we could move things around to
>> turn the TR1 code into an iso29124 implementation, do you think that
>> would make sense?
>>
> That would make absolute sense.
> I actually have a tree where I've done that.
> All the functions are in there (29124 removed the hypergeometric functions.
> I'd like to keep those as extensions.
> I have some bugfixes also.
>
> I have a better version of the Carlson elliptic functions (which are used in
> the 29124 elliptic functions).
>
> Ed
>

Hi Ed, Florian,

Here's a patch to re-use the TR1 math functions to implement IS 29124,
what do you think of this approach? Ed, were you just going to copy
the files and have duplicated code?

We should probably uglify the names of the hypergeometric functions if
they are not in the final standard.

This doesn't include Florian's patch, which should be applied.

(I want to get this done before stage 1 ends in a couple of weeks, so
am posting this for review now, but I'll be unavailable for the next
week or two and might not be able to actually commit anything until
stage 3).
commit 3274f846b6c57fc975da1695731c6c2f2a41c196
Author: Jonathan Wakely 
Date:   Sun Oct 18 13:49:04 2015 +0100

implement IS 29124

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 2dc0d01..cd9b4c6 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -120,6 +120,7 @@ bits_headers = \
${bits_srcdir}/locale_facets_nonio.tcc \
${bits_srcdir}/localefwd.h \
${bits_srcdir}/mask_array.h \
+   ${bits_srcdir}/math_sf.h \
${bits_srcdir}/memoryfwd.h \
${bits_srcdir}/move.h \
${bits_srcdir}/mutex.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index d545484..cf654ce 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -410,6 +410,7 @@ bits_headers = \
${bits_srcdir}/locale_facets_nonio.tcc \
${bits_srcdir}/localefwd.h \
${bits_srcdir}/mask_array.h \
+   ${bits_srcdir}/math_sf.h \
${bits_srcdir}/memoryfwd.h \
${bits_srcdir}/move.h \
${bits_srcdir}/mutex.h \
diff --git a/libstdc++-v3/include/bits/math_sf.h 
b/libstdc++-v3/include/bits/math_sf.h
new file mode 100644
index 000..344e4b7
--- /dev/null
+++ b/libstdc++-v3/include/bits/math_sf.h
@@ -0,0 +1,472 @@
+// Mathematical Special Functions for -*- C++ -*-
+
+// Copyright (C) 2006-2015 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file bits/math_sf.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{cmath}
+ */
+
+#ifndef _GLIBCXX_MATH_SF_H
+#define _GLIBCXX_MATH_SF_H 1
+
+#pragma GCC visibility push(default)
+
+#include 
+
+#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0
+# error include  and define __STDCPP_WANT_MATH_SPEC_FUNCS__
+#endif
+
+#define __STDCPP_MATH_SPEC_FUNCS__ 201003L
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  /**
+   * @defgroup mathsf Mathematical Special Functions
+   * @ingroup numerics
+   *
+   * A collection of advanced mathematical special functions,
+   * defined by ISO/IEC IS 29124.
+   * @{
+   */
+
+  inline float
+  

Re: [OpenACC 4/11] C FE changes

2015-10-24 Thread Jakub Jelinek
On Fri, Oct 23, 2015 at 07:31:51PM -0700, Cesar Philippidis wrote:

> +static tree
> +c_parser_oacc_shape_clause (c_parser *parser, omp_clause_code kind,
> + const char *str, tree list)
> +{
> +  const char *id = "num";
> +  tree op0 = NULL_TREE, op1 = NULL_TREE, c;
> +  location_t loc = c_parser_peek_token (parser)->location;
> +
> +  if (kind == OMP_CLAUSE_VECTOR)
> +id = "length";
> +
> +  if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
> +{
> +  tree *op_to_parse = 
> +  c_token *next;
> +
> +  c_parser_consume_token (parser);
> +
> +  do
> + {
> +   op_to_parse = 
> +
> +   /* Consume a comma if present.  */
> +   if (c_parser_next_token_is (parser, CPP_COMMA))
> + {
> +   if (op0 == NULL && op1 == NULL)
> + {
> +   c_parser_error (parser, "unexpected argument");
> +   goto cleanup_error;
> + }
> +
> +   c_parser_consume_token (parser);
> + }

This means you parse
gang (, static: *)
vector (, 5)
etc., even when you error on it afterwards with unexpected argument,
it is still different diagnostics from other invalid tokens immediately
after the opening (.
Also, loc and next are wrong if there is a valid comma.
So I'm really wondering why
gang (static: *, num: 5)
works, because next is the CPP_COMMA token, so while
c_parser_next_token_is (parser, CPP_NAME) matches the actual name,
what exactly next->value contains is unclear.

I think it would be better to:

  tree ops[2] = { NULL_TREE, NULL_TREE };

  do
{
// Note, declare these here
  c_token *next = c_parser_peek_token (parser);
  location_t loc = next->location;
// Just use ops[idx] instead of *op_to_parse etc., though if you strongly
// prefer *op_to_parse, I won't object.
  int idx = 0;
// Note it seems generally the C parser doesn't check for CPP_KEYWORD
// before calling c_parser_next_token_is_keyword.  And I'd just do it
// for OMP_CLAUSE_GANG, which has it in the grammar.
  if (kind == OMP_CLAUSE_GANG
  && c_parser_next_token_is_keyword (parser, RID_STATIC))
{
// ...
  // Your current code, except that for 
  if (c_parser_next_token_is (parser, CPP_MULT))
{
  c_parser_consume_token (parser);
  if (c_parser_next_token_is (parser, CPP_COMMA))
{
  c_parser_consume_token (parser);
  continue;
}
  break;
}
}
  else if (... num: / length: )
{
// ...
}
// ...
  mark_exp_read (expr);
  ops[idx] = expr;

  if (kind == OMP_CLAUSE_GANG
  && c_parser_next_token_is (parser, CPP_COMMA))
{
  c_parser_consume_token (parser);
  continue;
}
  break;
}
  while (1);

  if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
goto cleanup_error;

That way you don't parse something that is not in the grammar.

Jakub


Re: [PATCH] PR fortran/68055 -- Check for valid kind in old-style declaration

2015-10-24 Thread Paul Richard Thomas
Dear Steve,

This is also OK to commit.

Thanks

Paul

On 24 October 2015 at 01:52, Steve Kargl
 wrote:
> The attached patch has been built and tested on x86_64-*-freebsd.
> It implements a check for validate kinds in type declarations
> of the form REAL*42.
>
> OK to commit?
>
> 2015-10-23  Steven G. Kargl  
>
> PR fortran/68055
> * decl.c (gfc_match_decl_type_spec): Check for valid kind in old-style
> declarations.
>
> 2015-10-23  Steven G. Kargl  
>
> PR fortran/68055
> * gfortran.dg/pr68055.f90: New case.
> --
> Steve



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx


Re: [AArch64][dejagnu][PATCH 5/7] Dejagnu support for ARMv8.1 Adv.SIMD.

2015-10-24 Thread Bernhard Reutner-Fischer
On October 23, 2015 2:24:26 PM GMT+02:00, Matthew Wahab 
 wrote:
>The ARMv8.1 architecture extension adds two Adv.SIMD instructions,.
>This
>patch adds support in Dejagnu for ARMv8.1 Adv.SIMD specifiers and
>checks.
>
>The new test options are
>- { dg-add-options arm_v8_1a_neon }: Add compiler options needed to
>   enable ARMv8.1 Adv.SIMD.
>- { dg-require-effective-target arm_v8_1a_neon_hw }: Require a target
>   capable of executing ARMv8.1 Adv.SIMD instructions.
>
>The new options support AArch64 only.
>
>Tested the series for aarch64-none-linux-gnu with native bootstrap and
>make check on an ARMv8 architecture. Also tested aarch64-none-elf with
>cross-compiled check-gcc on an ARMv8.1 emulator.


 
+# Return 1 if the target supports the ARMv8.1 Adv.SIMD extension, 0
+# otherwise.  The test is valid for AArch64.
+
+proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
+return [check_no_compiler_messages_nocache arm_v8_1a_neon_ok assembly {
+   #if !defined (__ARM_FEATURE_QRDMX)
+   #error FOO
+   #endif
+} [add_options_for_arm_v8_1a_neon ""]]
+}

Please error with something more meaningful than FOO, !__ARM_FEATURE_QRDMX 
comes to mind.

TIA,