[SPARC] Fix pasto in config/sparc/sparc-c.c

2016-10-23 Thread Eric Botcazou
Tested on SPARC/Solaris, applied on the mainline and 6 branch.


2016-10-23  Eric Botcazou  

* config/sparc/sparc-c.c (sparc_target_macros): Replace TARGET_64BIT
with TARGET_ARCH64.  Define __VIS to 0x400 if TARGET_VIS4.

-- 
Eric BotcazouIndex: config/sparc/sparc-c.c
===
--- config/sparc/sparc-c.c	(revision 241437)
+++ config/sparc/sparc-c.c	(working copy)
@@ -29,7 +29,7 @@ sparc_target_macros (void)
 {
   builtin_define_std ("sparc");
 
-  if (TARGET_64BIT)
+  if (TARGET_ARCH64)
 {
   cpp_assert (parse_in, "cpu=sparc64");
   cpp_assert (parse_in, "machine=sparc64");
@@ -43,7 +43,7 @@ sparc_target_macros (void)
   if (TARGET_VIS4)
 {
   cpp_define (parse_in, "__VIS__=0x400");
-  cpp_define (parse_in, "__VIS__=0x400");
+  cpp_define (parse_in, "__VIS=0x400");
 }
   else if (TARGET_VIS3)
 {


Re: [PATCH] Extend -Wint-in-bool-context to warn for multiplications

2016-10-23 Thread Bernd Edlinger
On 10/22/16 08:52, Bernd Edlinger wrote:
> On 10/22/16 04:17, Martin Sebor wrote:
>> On 10/21/2016 04:37 PM, Joseph Myers wrote:
>>> The quoting in the diagnostic should be %<&&%>, not '&&'.
>>
>> Presumably same for '*' (i.e., %<*%>).
>>
>> But I would actually suggest a somewhat more formal phrasing than
>> "better use xxx here" such as "suggest %<&&%> instead" or something
>> akin to what's already in place elsewhere in gcc.pot.
>>
>
> Aehm, yes.  That would be better then:
>
>
> Index: c-common.c
> ===
> --- c-common.c(revision 241400)
> +++ c-common.c(working copy)
> @@ -3327,6 +3327,11 @@
>  return c_common_truthvalue_conversion (location,
> TREE_OPERAND (expr, 0));
>
> +case MULT_EXPR:
> +  warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
> +  "%<*%> in boolean context, suggest %<&&%> instead");
> +  break;
> +
>  case LSHIFT_EXPR:
>/* We will only warn on signed shifts here, because the majority of
>   false positive warnings happen in code where unsigned arithmetic
>
>
> I assume then I should adjust the warning a few lines below as well:
>
> warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
> "<< in boolean context, did you mean '<' ?");
>
>

Attached is the updated patch with those quotes fixed.

I have now put the << and < in correct quotes, but left the ?: in
the next two warnings unquoted:

  "?: using integer constants in boolean context, "
  "the expression will always evaluate to %"

I copied that style from the warning about omitted middle operand of
conditional expressions:

"the omitted middle operand in ?: will always be %, suggest 
explicit "
"middle operand"

I think that could be explained because ?: is not really a keyword
like <<, and is just a shorter phrase than "conditional expression".


Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.
c-family:
2016-10-23  Bernd Edlinger  

	* c-common.c (c_common_truthvalue_conversion): Warn for
	multiplications in boolean context.  Fix the quoting of '<<' and '<'
	in the shift warning.

gcc:
2016-10-23  Bernd Edlinger  

	* doc/invoke.text (Wint-in-bool-context): Update documentation.
	* value-prof.c (stringop_block_profile): Fix a warning.

testsuite:
2016-10-23  Bernd Edlinger  

	* c-c++-common/Wint-in-bool-context-3.c: New test.

Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c	(revision 241437)
+++ gcc/c-family/c-common.c	(working copy)
@@ -3327,6 +3327,11 @@ c_common_truthvalue_conversion (location_t locatio
 	return c_common_truthvalue_conversion (location,
 	   TREE_OPERAND (expr, 0));
 
+case MULT_EXPR:
+  warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
+		  "%<*%> in boolean context, suggest %<&&%> instead");
+  break;
+
 case LSHIFT_EXPR:
   /* We will only warn on signed shifts here, because the majority of
 	 false positive warnings happen in code where unsigned arithmetic
@@ -3336,7 +3341,7 @@ c_common_truthvalue_conversion (location_t locatio
   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
 	  && !TYPE_UNSIGNED (TREE_TYPE (expr)))
 	warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
-		"<< in boolean context, did you mean '<' ?");
+		"%<<<%> in boolean context, did you mean %<<%> ?");
   break;
 
 case COND_EXPR:
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 241437)
+++ gcc/doc/invoke.texi	(working copy)
@@ -6169,8 +6169,9 @@ of the C++ standard.
 @opindex Wno-int-in-bool-context
 Warn for suspicious use of integer values where boolean values are expected,
 such as conditional expressions (?:) using non-boolean integer constants in
-boolean context, like @code{if (a <= b ? 2 : 3)}.  Or left shifting in
-boolean context, like @code{for (a = 0; 1 << a; a++);}.
+boolean context, like @code{if (a <= b ? 2 : 3)}.  Or left shifting of signed
+integers in boolean context, like @code{for (a = 0; 1 << a; a++);}.  Likewise
+for all kinds of multiplications regardless of the data type.
 This warning is enabled by @option{-Wall}.
 
 @item -Wno-int-to-pointer-cast
Index: gcc/value-prof.c
===
--- gcc/value-prof.c	(revision 241437)
+++ gcc/value-prof.c	(working copy)
@@ -1878,12 +1878,12 @@ stringop_block_profile (gimple *stmt, unsigned int
   else
 {
   gcov_type count;
-  int alignment;
+  unsigned int alignment;
 
   count = histogram->hvalue.counters[0];
   alignment = 1;
   while (!(count & alignment)
-	 && (alignment * 2 * BITS_PER_UNIT))
+	 && (alignment <= UINT_MAX / 2 / BITS_PER_UNIT))
 	alignment <<= 1;
   *expected_align = alignment * BITS_PER_UNIT;
   gimple_remove_hist

Re: PING! [Fortran, Patch, PR72832, v1] [6/7 Regression] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions

2016-10-23 Thread Andre Vehreschild
Hi all,

due to no complains about the trunk version, backported to gcc-6 as r241448.

Regards,
Andre

On Thu, 13 Oct 2016 10:52:59 +0200
Andre Vehreschild  wrote:

> Hi Steve,
> 
> thanks for the review. Committed as r241088 on trunk.
> 
> Letting it mature for one week in trunk before backporting to gcc-6.
> 
> Regards,
>   Andre
> 
> On Wed, 12 Oct 2016 10:18:29 -0700
> Steve Kargl  wrote:
> 
> > On Wed, Oct 12, 2016 at 11:50:10AM +0200, Andre Vehreschild wrote:  
> > > Ping!
> > > 
> > > Updated patch with the comments gotten so far.
> > > 
> > > Ok for trunk?
> > > 
> > 
> > Looks good to me.
> >   
> 
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 241447)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,14 @@
+2016-10-23  Andre Vehreschild  
+
+	Backported from trunk
+	PR fortran/72832
+	* trans-expr.c (gfc_copy_class_to_class): Add generation of
+	runtime array bounds check.
+	* trans-intrinsic.c (gfc_conv_intrinsic_size): Add a crutch to
+	get the descriptor of a function returning a class object.
+	* trans-stmt.c (gfc_trans_allocate): Use the array spec on the
+	array to allocate instead of the array spec from source=.
+
 2016-10-17  Steven G. Kargl  
 
 	Backport from trunk
Index: gcc/fortran/trans-expr.c
===
--- gcc/fortran/trans-expr.c	(Revision 241447)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -1166,6 +1166,7 @@
   stmtblock_t body;
   stmtblock_t ifbody;
   gfc_loopinfo loop;
+  tree orig_nelems = nelems; /* Needed for bounds check.  */
 
   gfc_init_block (&body);
   tmp = fold_build2_loc (input_location, MINUS_EXPR,
@@ -1193,6 +1194,31 @@
 	}
   vec_safe_push (args, to_ref);
 
+  /* Add bounds check.  */
+  if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) > 0 && is_from_desc)
+	{
+	  char *msg;
+	  const char *name = "<>";
+	  tree from_len;
+
+	  if (DECL_P (to))
+	name = (const char *)(DECL_NAME (to)->identifier.id.str);
+
+	  from_len = gfc_conv_descriptor_size (from_data, 1);
+	  tmp = fold_build2_loc (input_location, NE_EXPR,
+  boolean_type_node, from_len, orig_nelems);
+	  msg = xasprintf ("Array bound mismatch for dimension %d "
+			   "of array '%s' (%%ld/%%ld)",
+			   1, name);
+
+	  gfc_trans_runtime_check (true, false, tmp, &body,
+   &gfc_current_locus, msg,
+			 fold_convert (long_integer_type_node, orig_nelems),
+			   fold_convert (long_integer_type_node, from_len));
+
+	  free (msg);
+	}
+
   tmp = build_call_vec (fcn_type, fcn, args);
 
   /* Build the body of the loop.  */
Index: gcc/fortran/trans-intrinsic.c
===
--- gcc/fortran/trans-intrinsic.c	(Revision 241447)
+++ gcc/fortran/trans-intrinsic.c	(Arbeitskopie)
@@ -5815,9 +5815,20 @@
   if (actual->expr->ts.type == BT_CLASS)
 gfc_add_class_array_ref (actual->expr);
 
-  argse.want_pointer = 1;
   argse.data_not_needed = 1;
-  gfc_conv_expr_descriptor (&argse, actual->expr);
+  if (gfc_is_alloc_class_array_function (actual->expr))
+{
+  /* For functions that return a class array conv_expr_descriptor is not
+	 able to get the descriptor right.  Therefore this special case.  */
+  gfc_conv_expr_reference (&argse, actual->expr);
+  argse.expr = gfc_build_addr_expr (NULL_TREE,
+	gfc_class_data_get (argse.expr));
+}
+  else
+{
+  argse.want_pointer = 1;
+  gfc_conv_expr_descriptor (&argse, actual->expr);
+}
   gfc_add_block_to_block (&se->pre, &argse.pre);
   gfc_add_block_to_block (&se->post, &argse.post);
   arg1 = gfc_evaluate_now (argse.expr, &se->pre);
Index: gcc/fortran/trans-stmt.c
===
--- gcc/fortran/trans-stmt.c	(Revision 241447)
+++ gcc/fortran/trans-stmt.c	(Arbeitskopie)
@@ -5476,7 +5476,8 @@
 		  desc = tmp;
 		  tmp = gfc_class_data_get (tmp);
 		}
-	  e3_is = E3_DESC;
+	  if (code->ext.alloc.arr_spec_from_expr3)
+		e3_is = E3_DESC;
 	}
 	  else
 	desc = !is_coarray ? se.expr
Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 241447)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,11 @@
+2016-10-23  Andre Vehreschild  
+
+	Backported from trunk
+	PR fortran/72832
+	* gfortran.dg/allocate_with_source_22.f03: New test.
+	* gfortran.dg/allocate_with_source_23.f03: New test.  Expected to
+	fail.
+
 2016-10-19  Uros Bizjak  
 
 	PR target/77991
Index: gcc/testsuite/gfortran.dg/allocate_with_source_22.f03
===
--- gcc/testsuite/gfortran.dg/allocate_with_source_22.f03	(nicht existent)
+++ gcc/testsuite/gfortran.dg/allocate_with_source_22.f03	(Arbeitskopie)
@@ -0,0 +1,48 @@
+! { dg-do run }
+!
+! T

Re: [Patch, fortran] PR69834 - Collision in derived type hashes

2016-10-23 Thread Andre Vehreschild
Hi Paul,

here are my comments to your patch:

> Index: gcc/fortran/class.c
> ===
> *** gcc/fortran/class.c (revision 241439)
> --- gcc/fortran/class.c (working copy)
> *** add_procs_to_declared_vtab (gfc_symbol *
> --- 2187,2219 
>   gfc_symbol *
>   gfc_find_derived_vtab (gfc_symbol *derived)
>   {
> !   gfc_namespace *ns = NULL;

Setting this to NULL for consistency?

> Index: gcc/fortran/dump-parse-tree.c
> ===
> *** gcc/fortran/dump-parse-tree.c   (revision 241439)
> --- gcc/fortran/dump-parse-tree.c   (working copy)
> *** show_code_node (int level, gfc_code *c)
> *** 1843,1848 
> --- 1843,1877 

Well, the code in this chunk is identical to the one of EXEC_SELECT, besides
two lines where the statement's name is printed. I propose to do something like:

case EXEC_SELECT:
case EXEC_SELECT_TYPE:
  d= ..
  fputs ("SELECT", dumpfile);
  if (c->op == EXEC_SELECT_TYPE)
fputs (" TYPE", dumpfile);
 ...
  // and the same for "END SELECT..."

This would reduce the amount of copied code. An improvement in one
EXEC_SELECT-dump-handler would then automagically available in the other, too.

> Index: gcc/fortran/resolve.c
> ===
> *** gcc/fortran/resolve.c   (revision 241439)
> --- gcc/fortran/resolve.c   (working copy)

> *** resolve_select_type (gfc_code *code, gfc

> --- 8595,8641 
> else
>   ns->code->next = new_st;
> code = new_st;
> !   code->op = EXEC_SELECT_TYPE;
> 
> +   /* Use the intrinsic LOC function to generate the an integer expression
> +  for the vtable of the selector.  Note that the rank of the selector
> +  expression has to be set to zero.  */

double article:_the an_  !!!

> Index: gcc/fortran/trans-stmt.c
> ===
> *** gcc/fortran/trans-stmt.c(revision 241439)
> --- gcc/fortran/trans-stmt.c(working copy)
> *** gfc_trans_do_while (gfc_code * code)
> *** 2331,2336 
> --- 2331,2455 

> +
> +   /* Translate an assignment to a CLASS object
> +  (pointer or ordinary assignment).  */
> +
> +

Here is no routine the above comment could document. Left over from prior
version?

>   /* End of prototype trans-class.c  */


> Index: gcc/fortran/trans-stmt.c
> ===
> *** gcc/fortran/trans-stmt.c(revision 241439)
> --- gcc/fortran/trans-stmt.c(working copy)
> *** gfc_trans_do_while (gfc_code * code)
> *** 2331,2336 
> --- 2331,2455 

Can one optimize this by using the "old style" for intrinsic types, i.e. a
computed goto (switch-case) for them? And in the default case the if-chain on
the derived types/classes? Would we gain any speed by this? What is your
opinion on this?

> Please find attached a revised version of the patch that corrects one
> or two tiny wrinkles. I have removed the tidy up of vtable retrieval

I haven't understood yet, what you need to do for this. Looking forward to that
patch.

With the above small changes the patch is ok for trunk given that Dominique
doesn't find any issues.

Beware, that my big patch on polymorphic assignment will *not* be backported
to gcc-6. I.e., this version of your patch will most probably not be applyable.
You rather will need to apply the old version.

Thanks for the work.

Regards,
Andre

> Functionally, the patch is as described in the original submission.
> 
> As attached, it bootstraps and regtests on FC21/x86_64.  OK for trunk
> and, after a decent interval for 6-branch?
> 
> Cheers
> 
> Paul
> 
> 2016-10-22  Paul Thomas  
> 
> PR fortran/69834
> * class.c (gfc_find_derived_vtab): Obtain the gsymbol for the
> derived type's module. If the gsymbol is present and the top
> level namespace corresponds to a module, use the gsymbol name
> space. In the search to see if the vtable exists, try the gsym
> namespace first.
> * dump-parse-tree (show_code_node): Add explicit dump for the
> select type construct.
> * resolve.c (build_loc_call): New function.
> (resolve_select_type): Add check for repeated type is cases.
> Retain selector expression and use it later instead of expr1.
> Exclude deferred length TYPE IS cases and emit error message.
> Store the address for the vtable in the 'low' expression and
> the hash value in the 'high' expression, for each case. Do not
> call resolve_select.
> * trans.c(trans_code) : Call gfc_trans_select_type.
> * trans-stmt.c (gfc_trans_select_type_cases): New function.
> (gfc_trans_select_type): New function.
> * trans-stmt.h : Add prototype for gfc_trans_select_type.
> 
> 2016-10-22  Paul Thomas  
> 
> PR fortran/69834
> * gfortran.dg/select_t

Re: [PATCH] 77864 Fix noexcept conditions for map/set default constructors

2016-10-23 Thread François Dumont

Hi

I have run all tests with success. Even if it doesn't get rid of 
_GLIBCXX_NOEXCEPT_IF it still limits it to one place.


So is it ok to commit ?

François


On 12/10/2016 22:36, François Dumont wrote:

On 10/10/2016 23:01, Tim Song wrote:

Trying again...with a few edits.


On Mon, Oct 10, 2016 at 3:24 PM, François Dumont 
wrote:

@@ -602,24 +612,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  struct _Rb_tree_impl : public _Node_allocator
  {
_Key_compare _M_key_compare;
-  _Rb_tree_node_base _M_header;
+  _Rb_header_node _M_header;
+#if __cplusplus < 201103L
size_type _M_node_count; // Keeps track of size of tree.
+#else
+  size_type _M_node_count = 0; // Keeps track of size of tree.
+#endif

+#if __cplusplus < 201103L
_Rb_tree_impl()
-  : _Node_allocator(), _M_key_compare(), _M_header(),
-_M_node_count(0)
-  { _M_initialize(); }
+  : _M_node_count(0)
+  { }
+#else
+  _Rb_tree_impl() = default;
+#endif


The default constructor of the associative containers is required to
value-initialize the comparator (see their synopses in
[map/set/multimap/multiset.overview]).
I don't have latest Standard version so can't see the exact word but I 
find quite annoying that the Standard doesn't allow this simple 
implementation.


I don't know if unodered containers have same kind of requirements for 
equal or hash functors but if so current implementation doesn't do 
this value initialization.


So here is another attempt. This time it simply allows to have 
noexcept condition in one place and closer to where operations are 
being invoked.


Ok to commit after tests ?

François


  _Rb_tree_impl() = default; doesn't do that; it default-initializes the
  comparator instead.

Tim







Re: [PATCH v3] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount

2016-10-23 Thread Bernd Edlinger
Hi,

I don't know much about tilegx, but
I think the patch should work as is.

This is because the
Save r10 code is a bundle

  {
  addi sp, sp, -8
  st sp, r10
  }

which stores r10 at [sp] and subtracts 8 from sp.

The restore r10 code is actually two bundles:

  addi sp, sp, 8
  ld r10, sp

This just adds 8 to sp, and loads r10 from there.

I don't know how __mcount is implemented, it must
be some asm code, almost all functions save the
lr at [sp] when invoked, but I don't know if __mcount
does that at all, if it doesn't do that, then the
adjusting of sp might be unnecessary.

The only thing that might be a problem is that
the stack is always adjusted in multiples of 16
on the tilegx platform, see tilegx.h:

#define STACK_BOUNDARY 128

That is counted in bits, and means 16 bytes.
But your patch adjusts the stack only by 8.

Furthermore, I don't see how the stack unwinding will work
with this stack adjustment when no .cfi directives
are emitted, but that is probably not a big problem.

You might see a difference, when single-stepping
over the function entry.

Maybe a test case would be good as well.


Bernd.


Re: [PATCH] PR fortran/78033 -- This was a REAL pain

2016-10-23 Thread Steve Kargl
On Sat, Oct 22, 2016 at 08:55:46AM +0200, Paul Richard Thomas wrote:
> 
> Thanks for persevering with this. The patch looks good to me. If it
> has regtested OK, please feel free to commit.
> 

The attached patch is the final version, which I just committed.

2016-10-23  Steven G. Kargl  

PR fortran/54730
PR fortran/78033
* array.c (gfc_match_array_constructor): Remove checkpointing
introduced in r196416 (original fix for PR fortran/54730).  Move
initialization to top of function.
* match.c (gfc_match_type_spec): Special case matching for REAL.

2016-10-23  Steven G. Kargl  

PR fortran/54730
PR fortran/78033
* gfortran.dg/pr78033.f90: New test.

-- 
Steve
Index: gcc/fortran/array.c
===
--- gcc/fortran/array.c	(revision 241448)
+++ gcc/fortran/array.c	(working copy)
@@ -1091,7 +1091,6 @@ gfc_match_array_constructor (gfc_expr **
 {
   gfc_constructor *c;
   gfc_constructor_base head;
-  gfc_undo_change_set changed_syms;
   gfc_expr *expr;
   gfc_typespec ts;
   locus where;
@@ -1099,6 +1098,9 @@ gfc_match_array_constructor (gfc_expr **
   const char *end_delim;
   bool seen_ts;
 
+  head = NULL;
+  seen_ts = false;
+
   if (gfc_match (" (/") == MATCH_NO)
 {
   if (gfc_match (" [") == MATCH_NO)
@@ -1115,12 +1117,9 @@ gfc_match_array_constructor (gfc_expr **
 end_delim = " /)";
 
   where = gfc_current_locus;
-  head = NULL;
-  seen_ts = false;
 
   /* Try to match an optional "type-spec ::"  */
   gfc_clear_ts (&ts);
-  gfc_new_undo_checkpoint (changed_syms);
   m = gfc_match_type_spec (&ts);
   if (m == MATCH_YES)
 {
@@ -1130,16 +1129,12 @@ gfc_match_array_constructor (gfc_expr **
 	{
 	  if (!gfc_notify_std (GFC_STD_F2003, "Array constructor "
 			   "including type specification at %C"))
-	{
-	  gfc_restore_last_undo_checkpoint ();
-	  goto cleanup;
-	}
+	goto cleanup;
 
 	  if (ts.deferred)
 	{
 	  gfc_error ("Type-spec at %L cannot contain a deferred "
 			 "type parameter", &where);
-	  gfc_restore_last_undo_checkpoint ();
 	  goto cleanup;
 	}
 
@@ -1148,24 +1143,15 @@ gfc_match_array_constructor (gfc_expr **
 	{
 	  gfc_error ("Type-spec at %L cannot contain an asterisk for a "
 			 "type parameter", &where);
-	  gfc_restore_last_undo_checkpoint ();
 	  goto cleanup;
 	}
 	}
 }
   else if (m == MATCH_ERROR)
-{
-  gfc_restore_last_undo_checkpoint ();
-  goto cleanup;
-}
+goto cleanup;
 
-  if (seen_ts)
-gfc_drop_last_undo_checkpoint ();
-  else
-{
-  gfc_restore_last_undo_checkpoint ();
-  gfc_current_locus = where;
-}
+  if (!seen_ts)
+gfc_current_locus = where;
 
   if (gfc_match (end_delim) == MATCH_YES)
 {
Index: gcc/fortran/match.c
===
--- gcc/fortran/match.c	(revision 241448)
+++ gcc/fortran/match.c	(working copy)
@@ -1989,6 +1989,7 @@ gfc_match_type_spec (gfc_typespec *ts)
 {
   match m;
   locus old_locus;
+  char name[GFC_MAX_SYMBOL_LEN + 1];
 
   gfc_clear_ts (ts);
   gfc_gobble_whitespace ();
@@ -2013,13 +2014,6 @@ gfc_match_type_spec (gfc_typespec *ts)
   goto kind_selector;
 }
 
-  if (gfc_match ("real") == MATCH_YES)
-{
-  ts->type = BT_REAL;
-  ts->kind = gfc_default_real_kind;
-  goto kind_selector;
-}
-
   if (gfc_match ("double precision") == MATCH_YES)
 {
   ts->type = BT_REAL;
@@ -2053,6 +2047,103 @@ gfc_match_type_spec (gfc_typespec *ts)
   goto kind_selector;
 }
 
+  /* REAL is a real pain because it can be a type, intrinsic subprogram,
+ or list item in a type-list of an OpenMP reduction clause.  Need to
+ differentiate REAL([KIND]=scalar-int-initialization-expr) from
+ REAL(A,[KIND]) and REAL(KIND,A).  */
+
+  m = gfc_match (" %n", name);
+  if (m == MATCH_YES && strcmp (name, "real") == 0)
+{
+  char c;
+  gfc_expr *e;
+  locus where;
+
+  ts->type = BT_REAL;
+  ts->kind = gfc_default_real_kind;
+
+  gfc_gobble_whitespace ();
+
+  /* Prevent REAL*4, etc.  */
+  c = gfc_peek_ascii_char ();
+  if (c == '*')
+	{
+	  gfc_error ("Invalid type-spec at %C");
+	  return MATCH_ERROR;
+	}
+
+  /* Found leading colon in REAL::, a trailing ')' in for example
+	 TYPE IS (REAL), or REAL, for an OpenMP list-item.  */
+  if (c == ':' || c == ')' || (flag_openmp && c == ','))
+	return MATCH_YES;
+
+  /* Found something other than the opening '(' in REAL(...  */
+  if (c != '(')
+	return MATCH_NO;
+  else
+	gfc_next_char (); /* Burn the '('. */
+
+  /* Look for the optional KIND=. */
+  where = gfc_current_locus;
+  m = gfc_match ("%n", name);
+  if (m == MATCH_YES)
+	{
+	  gfc_gobble_whitespace ();
+	  c = gfc_next_char ();
+	  if (c == '=')
+	{
+	  if (strcmp(name, "a") == 0)
+		return MATCH_NO;
+	  else if (strcmp(name, "ki

Re: [Patch, fortran] PR69834 - Collision in derived type hashes

2016-10-23 Thread Paul Richard Thomas
Hi Andre,

Thanks for the review.  I have partially responded to your comments - see below.

Committed as revision 241450.

Cheers

Paul

On 23 October 2016 at 14:45, Andre Vehreschild  wrote:
> Hi Paul,
>
> here are my comments to your patch:
>
>> Index: gcc/fortran/class.c
>> ===
>> *** gcc/fortran/class.c (revision 241439)
>> --- gcc/fortran/class.c (working copy)
>> *** add_procs_to_declared_vtab (gfc_symbol *
>> --- 2187,2219 
>>   gfc_symbol *
>>   gfc_find_derived_vtab (gfc_symbol *derived)
>>   {
>> !   gfc_namespace *ns = NULL;
>
> Setting this to NULL for consistency?

Indeed - =NULL eliminated. It was needed in one incarnation of the patch.


>
>> Index: gcc/fortran/dump-parse-tree.c
>> ===
>> *** gcc/fortran/dump-parse-tree.c   (revision 241439)
>> --- gcc/fortran/dump-parse-tree.c   (working copy)
>> *** show_code_node (int level, gfc_code *c)
>> *** 1843,1848 
>> --- 1843,1877 
>
> Well, the code in this chunk is identical to the one of EXEC_SELECT, besides
> two lines where the statement's name is printed. I propose to do something 
> like:
>
> case EXEC_SELECT:
> case EXEC_SELECT_TYPE:
>   d= ..
>   fputs ("SELECT", dumpfile);
>   if (c->op == EXEC_SELECT_TYPE)
> fputs (" TYPE", dumpfile);
>  ...
>   // and the same for "END SELECT..."
>
> This would reduce the amount of copied code. An improvement in one
> EXEC_SELECT-dump-handler would then automagically available in the other, too.

Have done this, except for the end, where I have retained "END SELECT" for both.

>
>> Index: gcc/fortran/resolve.c
>> ===
>> *** gcc/fortran/resolve.c   (revision 241439)
>> --- gcc/fortran/resolve.c   (working copy)
> 
>> *** resolve_select_type (gfc_code *code, gfc
> 
>> --- 8595,8641 
>> else
>>   ns->code->next = new_st;
>> code = new_st;
>> !   code->op = EXEC_SELECT_TYPE;
>>
>> +   /* Use the intrinsic LOC function to generate the an integer expression
>> +  for the vtable of the selector.  Note that the rank of the selector
>> +  expression has to be set to zero.  */
>
> double article:_the an_  !!!

Corrected - thanks.

>
>> Index: gcc/fortran/trans-stmt.c
>> ===
>> *** gcc/fortran/trans-stmt.c(revision 241439)
>> --- gcc/fortran/trans-stmt.c(working copy)
>> *** gfc_trans_do_while (gfc_code * code)
>> *** 2331,2336 
>> --- 2331,2455 
> 
>> +
>> +   /* Translate an assignment to a CLASS object
>> +  (pointer or ordinary assignment).  */
>> +
>> +
>
> Here is no routine the above comment could document. Left over from prior
> version?

This is in your tree, not mine :-)

>
>>   /* End of prototype trans-class.c  */
>
>
>> Index: gcc/fortran/trans-stmt.c
>> ===
>> *** gcc/fortran/trans-stmt.c(revision 241439)
>> --- gcc/fortran/trans-stmt.c(working copy)
>> *** gfc_trans_do_while (gfc_code * code)
>> *** 2331,2336 
>> --- 2331,2455 
>
> Can one optimize this by using the "old style" for intrinsic types, i.e. a
> computed goto (switch-case) for them? And in the default case the if-chain on
> the derived types/classes? Would we gain any speed by this? What is your
> opinion on this?

Maybe this would gain something but I suspect that it would not amount to much.

>
>> Please find attached a revised version of the patch that corrects one
>> or two tiny wrinkles. I have removed the tidy up of vtable retrieval
>
> I haven't understood yet, what you need to do for this. Looking forward to 
> that
> patch.

OK will submit this separately.

>
> With the above small changes the patch is ok for trunk given that Dominique
> doesn't find any issues.
>
> Beware, that my big patch on polymorphic assignment will *not* be backported
> to gcc-6. I.e., this version of your patch will most probably not be 
> applyable.
> You rather will need to apply the old version.
>
> Thanks for the work.
>
> Regards,
> Andre
>
>> Functionally, the patch is as described in the original submission.
>>
>> As attached, it bootstraps and regtests on FC21/x86_64.  OK for trunk
>> and, after a decent interval for 6-branch?
>>
>> Cheers
>>
>> Paul
>>
>> 2016-10-22  Paul Thomas  
>>
>> PR fortran/69834
>> * class.c (gfc_find_derived_vtab): Obtain the gsymbol for the
>> derived type's module. If the gsymbol is present and the top
>> level namespace corresponds to a module, use the gsymbol name
>> space. In the search to see if the vtable exists, try the gsym
>> namespace first.
>> * dump-parse-tree (show_code_node): Add explicit dump for the
>> select type construct.
>> * resolve.c (build_loc_call): Ne

[SPARC] Cosmetic fixes for v3pipe attribute

2016-10-23 Thread Eric Botcazou
Tested on SPARC/Solaris, applied on the mainline and 6 branch.


2016-10-23  Eric Botcazou  

* config/sparc/sparc.md (cpu_feature): Minor tweak.
(enabled): Likewise.
(movsi_insn, movdi_insn_sp32, movdi_insn_sp64, movsf_insn,
movdf_insn_sp32, movdf_insn_sp64, zero_extendsidi2_insn_sp64,
sign_extendsidi2_insn, mov_insn, mov_insn_sp64,
mov_insn_sp32, not_, nand_vis,
_not1_vi, _not2_vis, one_cmpl2,
fcmp, pdistn_vis): Likewise.

-- 
Eric BotcazouIndex: config/sparc/sparc.md
===
--- config/sparc/sparc.md	(revision 241437)
+++ config/sparc/sparc.md	(working copy)
@@ -253,12 +253,13 @@ (define_attr "isa" "v7,v8,v9,sparclet"
 	 (symbol_ref "TARGET_SPARCLET") (const_string "sparclet")]
 	(const_string "v7"
 
-(define_attr "cpu_feature" "none,fpu,fpunotv9,v9,vis,vis3,vis4" (const_string "none"))
+(define_attr "cpu_feature" "none,fpu,fpunotv9,v9,vis,vis3,vis4"
+  (const_string "none"))
 
 (define_attr "enabled" ""
   (cond [(eq_attr "cpu_feature" "none") (const_int 1)
  (eq_attr "cpu_feature" "fpu") (symbol_ref "TARGET_FPU")
-	 (eq_attr "cpu_feature" "fpunotv9") (symbol_ref "TARGET_FPU && ! TARGET_V9")
+ (eq_attr "cpu_feature" "fpunotv9") (symbol_ref "TARGET_FPU && !TARGET_V9")
  (eq_attr "cpu_feature" "v9") (symbol_ref "TARGET_V9")
  (eq_attr "cpu_feature" "vis") (symbol_ref "TARGET_VIS")
  (eq_attr "cpu_feature" "vis3") (symbol_ref "TARGET_VIS3")
@@ -483,8 +484,7 @@ (define_attr "in_branch_delay" "false,tr
 	   (const_string "true")
 	] (const_string "false")))
 
-;; True if the instruction executes in the V3 pipeline, in M7 and
-;; later processors.
+;; True if the instruction executes in the V3 pipeline, in M7 and later processors.
 (define_attr "v3pipe" "false,true" (const_string "false"))
 
 (define_delay (eq_attr "type" "call")
@@ -1559,8 +1559,8 @@ (define_insn "*movsi_insn"
fzeros\t%0
fones\t%0"
   [(set_attr "type" "*,*,load,store,vismv,vismv,fpmove,fpload,fpstore,visl,visl")
-   (set_attr "v3pipe" "*,*,*,*,true,true,*,*,*,true,true")
-   (set_attr "cpu_feature" "*,*,*,*,vis3,vis3,*,*,*,vis,vis")])
+   (set_attr "cpu_feature" "*,*,*,*,vis3,vis3,*,*,*,vis,vis")
+   (set_attr "v3pipe" "*,*,*,*,true,true,*,*,*,true,true")])
 
 (define_insn "*movsi_lo_sum"
   [(set (match_operand:SI 0 "register_operand" "=r")
@@ -1725,10 +1725,10 @@ (define_insn "*movdi_insn_sp32"
fzero\t%0
fone\t%0"
   [(set_attr "type" "store,store,store,load,*,*,*,*,fpstore,fpload,*,*,fpmove,*,*,*,fpload,fpstore,visl,visl")
-   (set_attr "v3pipe" "false, false, false, false,false,false,false,false,false,false,false,false,false,false,false,false,false,false, true, true")
(set_attr "length" "*,2,*,*,2,2,2,2,*,*,2,2,*,2,2,2,*,*,*,*")
(set_attr "fptype" "*,*,*,*,*,*,*,*,*,*,*,*,double,*,*,*,*,*,double,double")
-   (set_attr "cpu_feature" "v9,*,*,*,*,*,*,*,fpu,fpu,fpu,fpu,v9,fpunotv9,vis3,vis3,fpu,fpu,vis,vis")])
+   (set_attr "cpu_feature" "v9,*,*,*,*,*,*,*,fpu,fpu,fpu,fpu,v9,fpunotv9,vis3,vis3,fpu,fpu,vis,vis")
+   (set_attr "v3pipe" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,true,true")])
 
 (define_insn "*movdi_insn_sp64"
   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r, m, r,*e,?*e,?*e,?W,b,b")
@@ -1749,9 +1749,9 @@ (define_insn "*movdi_insn_sp64"
fzero\t%0
fone\t%0"
   [(set_attr "type" "*,*,load,store,vismv,vismv,fpmove,fpload,fpstore,visl,visl")
-   (set_attr "v3pipe" "*, *, *, *, *, *, *, *, *, true, true")
(set_attr "fptype" "*,*,*,*,*,*,double,*,*,double,double")
-   (set_attr "cpu_feature" "*,*,*,*,vis3,vis3,*,*,*,vis,vis")])
+   (set_attr "cpu_feature" "*,*,*,*,vis3,vis3,*,*,*,vis,vis")
+   (set_attr "v3pipe" "*,*,*,*,*,*,*,*,*,true,true")])
 
 (define_expand "movdi_pic_label_ref"
   [(set (match_dup 3) (high:DI
@@ -2313,8 +2313,8 @@ (define_insn "*movsf_insn"
 }
 }
   [(set_attr "type" "visl,visl,fpmove,*,*,*,vismv,vismv,fpload,load,fpstore,store")
-   (set_attr "v3pipe" "true, true, *, *, *, *, true, true, *, *, *, *")
-   (set_attr "cpu_feature" "vis,vis,fpu,*,*,*,vis3,vis3,fpu,*,fpu,*")])
+   (set_attr "cpu_feature" "vis,vis,fpu,*,*,*,vis3,vis3,fpu,*,fpu,*")
+   (set_attr "v3pipe" "true,true,*,*,*,*,true,true,*,*,*,*")])
 
 ;; The following 3 patterns build SFmode constants in integer registers.
 
@@ -2382,10 +2382,10 @@ (define_insn "*movdf_insn_sp32"
   #
   #"
   [(set_attr "type" "visl,visl,fpmove,*,*,*,fpload,store,fpstore,load,store,*,*,*,*")
-   (set_attr "v3pipe" "true, true, *, *, *, *, *, *, *, *, *, *, *, *, *")
(set_attr "length" "*,*,*,2,2,2,*,*,*,*,*,2,2,2,2")
(set_attr "fptype" "double,double,double,*,*,*,*,*,*,*,*,*,*,*,*")
-   (set_attr "cpu_feature" "vis,vis,v9,fpunotv9,vis3,vis3,fpu,v9,fpu,*,*,fpu,*,*,fpu")])
+   (set_attr "cpu_feature" "vis,vis,v9,fpunotv9,vis3,vis3,fpu,v9,fpu,*,*,fpu,*,*,fpu")
+   (set_attr "v3pipe" "true,true,*,*,*,*,*,*,*,*,*,*,*,*,*")])
 
 (define_insn "*movdf_insn_sp6

[Committed] PR fortran/77763 -- STRUCTURE in BLOCK DATA

2016-10-23 Thread Steve Kargl
I've committed the following patch.  Both Oracle's manual
and DVF's manual indicate that STRUCTURE can appear in a
BLOCK DATA statement.  While I was here, I sorted the
case labels.

2016-10-23  Steven G. Kargl  

PR fortran/77763
* parse.c (parse_spec): Allow STRUCTURE in BLOCK DATA.  Sort
case labels.

2016-10-23  Steven G. Kargl  

PR fortran/77763
* gfortran.dg/pr77763.f90

Index: gcc/fortran/parse.c
===
--- gcc/fortran/parse.c (revision 241451)
+++ gcc/fortran/parse.c (working copy)
@@ -3588,17 +3588,18 @@ loop:
 /* Fortran 2008, C1116.  */
 switch (st)
   {
-case ST_DATA_DECL:
+   case ST_ATTR_DECL:
case ST_COMMON:
case ST_DATA:
-   case ST_TYPE:
+   case ST_DATA_DECL:
+   case ST_DERIVED_DECL:
case ST_END_BLOCK_DATA:
-   case ST_ATTR_DECL:
case ST_EQUIVALENCE:
-   case ST_PARAMETER:
case ST_IMPLICIT:
case ST_IMPLICIT_NONE:
-   case ST_DERIVED_DECL:
+   case ST_PARAMETER:
+   case ST_STRUCTURE_DECL:
+   case ST_TYPE:
case ST_USE:
  break;
 
Index: gcc/testsuite/gfortran.dg/pr77763.f90
===
--- gcc/testsuite/gfortran.dg/pr77763.f90   (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr77763.f90   (working copy)
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-options "-fdec" }
+block data
+   structure /s1/
+   end structure
+end block data

-- 
Steve


Re: [PATCH 3/5] [AARCH64] Fix part num and implement dependency

2016-10-23 Thread Andrew Pinski
On Tue, Nov 17, 2015 at 2:10 PM, Andrew Pinski  wrote:
>
> The way the current code was written assumes all cores have an unique part
> num which is not true.  What they have is an unique pair of implementer and
> part num.  This changes the code to look up that pair after the parsing
> of the two is done.
>
> Someone should test this on a big.little target too just to make sure
> the parsing is done correctly as I don't have access to one off hand.
>
> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.


Here is an updated version of this patch after the other patches have
now gone in.
OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions
and -mcpu=native still works.

Thanks,
Andrew Pinski

>
> Thanks,
> Andrew Pinski
>
>
> * config/aarch64/driver-aarch64.c (host_detect_local_cpu):
> Rewrite handling of part num to handle the case where
> multiple implementers share the same part num.
> ---
>  gcc/config/aarch64/driver-aarch64.c | 46 
> ++---
>  1 file changed, 28 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/config/aarch64/driver-aarch64.c 
> b/gcc/config/aarch64/driver-aarch64.c
> index 92388a9..ea1e856 100644
> --- a/gcc/config/aarch64/driver-aarch64.c
> +++ b/gcc/config/aarch64/driver-aarch64.c
> @@ -158,7 +158,7 @@ host_detect_local_cpu (int argc, const char **argv)
>bool tune = false;
>bool cpu = false;
>unsigned int i = 0;
> -  unsigned int core_idx = 0;
> +  int core_idx = -1;
>unsigned char imp = INVALID_IMP;
>unsigned int cores[2] = { INVALID_CORE, INVALID_CORE };
>unsigned int n_cores = 0;
> @@ -206,18 +206,13 @@ host_detect_local_cpu (int argc, const char **argv)
>if (strstr (buf, "part") != NULL)
> {
>   unsigned ccore = parse_field (buf);
> - for (i = 0; cpu_data[i].name != NULL; i++)
> -   if (ccore == cpu_data[i].part_no
> -&& !contains_core_p (cores, ccore))
> - {
> -if (n_cores == 2)
> -  goto not_found;
> -
> -cores[n_cores++] = ccore;
> -   core_idx = i;
> -   arch_id = cpu_data[i].arch;
> -   break;
> - }
> + if (!contains_core_p (cores, ccore))
> +   {
> +  if (n_cores == 2)
> +goto not_found;
> +
> +  cores[n_cores++] = ccore;
> +   }
>continue;
>  }
>if (!tune && !processed_exts && strstr (buf, "Features") != NULL)
> @@ -253,11 +248,19 @@ host_detect_local_cpu (int argc, const char **argv)
>if (n_cores == 0 || n_cores > 2 || imp == INVALID_IMP)
>  goto not_found;
>
> -  if (arch && !arch_id)
> -goto not_found;
> -
>if (arch)
>  {
> +  /* Search for one of the cores in the list. */
> +  for (i = 0; cpu_data[i].name != NULL; i++)
> +   if (cpu_data[i].implementer_id == imp
> +   && contains_core_p (cores, cpu_data[i].part_no))
> + {
> +   arch_id = cpu_data[i].arch;
> +   break;
> + }
> +  if (!arch_id)
> +   goto not_found;
> +
>const char* arch_name = get_arch_name_from_id (arch_id);
>
>/* We got some arch indentifier that's not in aarch64-arches.def?  */
> @@ -284,8 +287,15 @@ host_detect_local_cpu (int argc, const char **argv)
>/* The simple, non-big.LITTLE case.  */
>else
>  {
> -  if (cpu_data[core_idx].implementer_id != imp)
> -goto not_found;
> +  for (i = 0; cpu_data[i].name != NULL; i++)
> +   if (cores[0] == cpu_data[i].part_no
> +   && cpu_data[i].implementer_id == imp)
> + {
> +   core_idx = i;
> +   break;
> + }
> +  if (core_idx == -1)
> +   goto not_found;
>
>res = concat ("-m", cpu ? "cpu" : "tune", "=",
>cpu_data[core_idx].name, NULL);
> --
> 1.9.1
>
Index: config/aarch64/driver-aarch64.c
===
--- config/aarch64/driver-aarch64.c (revision 241437)
+++ config/aarch64/driver-aarch64.c (working copy)
@@ -169,7 +169,6 @@ host_detect_local_cpu (int argc, const c
   bool tune = false;
   bool cpu = false;
   unsigned int i = 0;
-  unsigned int core_idx = 0;
   unsigned char imp = INVALID_IMP;
   unsigned int cores[2] = { INVALID_CORE, INVALID_CORE };
   unsigned int n_cores = 0;
@@ -219,18 +218,13 @@ host_detect_local_cpu (int argc, const c
   if (strstr (buf, "part") != NULL)
{
  unsigned ccore = parse_field (buf);
- for (i = 0; aarch64_cpu_data[i].name != NULL; i++)
-   if (ccore == aarch64_cpu_data[i].part_no
-   && !contains_core_p (cores, ccore))
- {
-   if (n_cores == 2)
- goto not_found;
-
-   cores[n_cores++] = ccore;
-   core_idx = i;
-   arch_id = aarch64_cpu_data[i].arch;
-   break;
- }
+

[v3 PATCH] Cross-port exception-safety and move fixes of std::any to std::experimental::any.

2016-10-23 Thread Ville Voutilainen
Tested on Linux-x64. Ok for trunk?

I don't plan to backport this unless somebody shouts.

2016-10-24  Ville Voutilainen  

Cross-port exception-safety and move fixes of std::any to
std::experimental::any.
* include/std/any (operator=(const any&)):
Make strongly exception-safe.
(operator=(any&&)): clear() unconditionally in the case where
rhs has a value.
(_Manager_internal<_Tp>::_S_manage): Move in _Op_xfer, don't copy.
* testsuite/experimental/any/assign/2.cc: Adjust.
* testsuite/experimental/any/assign/exception.cc: New.
* testsuite/experimental/any/cons/2.cc: Adjust.
* testsuite/experimental/any/misc/any_cast_neg.cc: Ajust.
diff --git a/libstdc++-v3/include/experimental/any 
b/libstdc++-v3/include/experimental/any
index 5e091a4..8fd66e2 100644
--- a/libstdc++-v3/include/experimental/any
+++ b/libstdc++-v3/include/experimental/any
@@ -191,16 +191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Copy the state of another object.
 any& operator=(const any& __rhs)
 {
-  if (__rhs.empty())
-   clear();
-  else if (this != &__rhs)
-   {
- if (!empty())
-   _M_manager(_Op_destroy, this, nullptr);
- _Arg __arg;
- __arg._M_any = this;
- __rhs._M_manager(_Op_clone, &__rhs, &__arg);
-   }
+  *this = any(__rhs);
   return *this;
 }
 
@@ -215,8 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
clear();
   else if (this != &__rhs)
{
- if (!empty())
-   _M_manager(_Op_destroy, this, nullptr);
+ clear();
  _Arg __arg;
  __arg._M_any = this;
  __rhs._M_manager(_Op_xfer, &__rhs, &__arg);
@@ -485,7 +475,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__ptr->~_Tp();
break;
   case _Op_xfer:
-   ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp(*__ptr);
+   ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp
+ (std::move(*const_cast<_Tp*>(__ptr)));
__ptr->~_Tp();
__arg->_M_any->_M_manager = __any->_M_manager;
const_cast(__any)->_M_manager = nullptr;
diff --git a/libstdc++-v3/testsuite/experimental/any/assign/2.cc 
b/libstdc++-v3/testsuite/experimental/any/assign/2.cc
index 7022878..0232af6 100644
--- a/libstdc++-v3/testsuite/experimental/any/assign/2.cc
+++ b/libstdc++-v3/testsuite/experimental/any/assign/2.cc
@@ -23,28 +23,70 @@
 using std::experimental::any;
 using std::experimental::any_cast;
 
+bool moved = false;
+bool copied = false;
+
+
 struct X
 {
-  bool moved = false;
-  bool moved_from = false;
   X() = default;
-  X(const X&) = default;
-  X(X&& x) : moved(true) { x.moved_from = true; }
+  X(const X&) { copied = true; }
+  X(X&& x) { moved = true; }
+};
+
+struct X2
+{
+  X2() = default;
+  X2(const X2&) { copied = true; }
+  X2(X2&& x) noexcept { moved = true; }
 };
 
 void test01()
 {
+  moved = false;
   X x;
   any a1;
   a1 = x;
-  VERIFY(x.moved_from == false);
+  VERIFY(moved == false);
   any a2;
+  copied = false;
   a2 = std::move(x);
-  VERIFY(x.moved_from == true);
-  VERIFY(any_cast(a2).moved == true );
+  VERIFY(moved == true);
+  VERIFY(copied == false);
 }
 
+void test02()
+{
+  moved = false;
+  X x;
+  any a1;
+  a1 = x;
+  VERIFY(moved == false);
+  any a2;
+  copied = false;
+  a2 = std::move(a1);
+  VERIFY(moved == false);
+  VERIFY(copied == false);
+}
+
+void test03()
+{
+  moved = false;
+  X2 x;
+  any a1;
+  a1 = x;
+  VERIFY(copied && moved);
+  any a2;
+  moved = false;
+  copied = false;
+  a2 = std::move(a1);
+  VERIFY(moved == true);
+  VERIFY(copied == false);
+ }
+
 int main()
 {
   test01();
+  test02();
+  test03();
 }
diff --git a/libstdc++-v3/testsuite/experimental/any/assign/exception.cc 
b/libstdc++-v3/testsuite/experimental/any/assign/exception.cc
new file mode 100644
index 000..f125213
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/any/assign/exception.cc
@@ -0,0 +1,77 @@
+// { dg-do run { target c++14 } }
+
+// Copyright (C) 2016 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 
+
+using std::experimental::any;
+using std::experimental::any_cast;
+
+bool should_throw = false;
+struct Bad
+{
+  Bad() = default;
+  Bad(const Bad&) {if (should_throw) throw 666;}
+};
+
+struct Bad2
+{
+  Bad2() = default;
+  Bad2(const Bad2&) 

Re: [v3 PATCH] Cross-port exception-safety and move fixes of std::any to std::experimental::any.

2016-10-23 Thread Ville Voutilainen
On 24 October 2016 at 02:33, Ville Voutilainen
 wrote:
> * include/std/any (operator=(const any&)):

No sir, that's not what the patch modifies:

2016-10-24  Ville Voutilainen  

Cross-port exception-safety and move fixes of std::any to
std::experimental::any.
* include/experimental/any (operator=(const any&)):
Make strongly exception-safe.
(operator=(any&&)): clear() unconditionally in the case where
rhs has a value.
(_Manager_internal<_Tp>::_S_manage): Move in _Op_xfer, don't copy.
* testsuite/experimental/any/assign/2.cc: Adjust.
* testsuite/experimental/any/assign/exception.cc: New.
* testsuite/experimental/any/cons/2.cc: Adjust.
* testsuite/experimental/any/misc/any_cast_neg.cc: Ajust.