[libstdc++-v3] PR 60308: leak in deque constructor

2014-02-22 Thread Marc Glisse

Hello,

this fixes a bug I introduced when adding noexcept all over the place by 
reverting the guilty bit.


Tested with no regression on x86_64-linux-gnu, and checked that the leak 
has disappeared in the PR.


2014-02-22  Marc Glisse  

PR libstdc++/60308
* include/bits/stl_deque.h (_Deque_base::_Deque_base(const
allocator_type&)): Remove redundant call to _M_initialize_map.
(deque::deque(const allocator_type&)): Initialize _Base with a
constructor that calls _M_initialize_map.

Partial revert:

2013-09-20  Marc Glisse  
PR libstdc++/58338
(_Deque_base) [_Deque_base(const allocator_type&)]: Add missing call to
_M_initialize_map.


--
Marc GlisseIndex: include/bits/stl_deque.h
===
--- include/bits/stl_deque.h(revision 208040)
+++ include/bits/stl_deque.h(working copy)
@@ -460,21 +460,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   _Deque_base(size_t __num_elements)
   : _M_impl()
   { _M_initialize_map(__num_elements); }
 
   _Deque_base(const allocator_type& __a, size_t __num_elements)
   : _M_impl(__a)
   { _M_initialize_map(__num_elements); }
 
   _Deque_base(const allocator_type& __a)
   : _M_impl(__a)
-  { _M_initialize_map(0); }
+  { }
 
 #if __cplusplus >= 201103L
   _Deque_base(_Deque_base&& __x)
   : _M_impl(std::move(__x._M_get_Tp_allocator()))
   {
_M_initialize_map(0);
if (__x._M_impl._M_map)
  {
std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
@@ -786,21 +786,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  Creates a %deque with no elements.
*/
   deque() : _Base() { }
 
   /**
*  @brief  Creates a %deque with no elements.
*  @param  __a  An allocator object.
*/
   explicit
   deque(const allocator_type& __a)
-  : _Base(__a) { }
+  : _Base(__a, 0) { }
 
 #if __cplusplus >= 201103L
   /**
*  @brief  Creates a %deque with default constructed elements.
*  @param  __n  The number of elements to initially create.
*
*  This constructor fills the %deque with @a n default
*  constructed elements.
*/
   explicit


PR60147: fix ICE with DECL_NAMELIST and tree-pretty-printer.c

2014-02-22 Thread Tobias Burnus
Since GCC 4.9, gfortran generates a DECL_NAMELIST (for DWARF's 
DW_TAG_namelist) - they are stored in the BIND_EXPR. Namelists are a bit 
boring: They only group variable names and the namelist name is only 
used in I/O statements (READ, WRITE) to permit a fancy data input [and 
output] - and for the debugger.


Due to DW_TAG_namelist, namelists are now exposed to the middle end - 
and I forgot to handle them also in the tree pretty printer - hence 
-fdump-tree-original now ICEs.


For the pretty printer one has two options: Ignoring (or "NYI;") the 
decl or dumping it. The attached patch does the latter.


Bootstrapped (C/C++/Fortran) and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
2014-02-22  Tobias Burnus  

	PR middle-end/60147
	* tree-pretty-print.c (dump_generic_node): Handle
	NAMELIST_DECL.

diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 0595499..80c59a6 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1386,20 +1386,40 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
   break;
 
 case VAR_DECL:
 case PARM_DECL:
 case FIELD_DECL:
 case DEBUG_EXPR_DECL:
 case NAMESPACE_DECL:
   dump_decl_name (buffer, node, flags);
   break;
 
+case NAMELIST_DECL:
+  {
+	unsigned i;
+	tree value;
+INDENT (spc);
+	pp_string (buffer, "namelist /");
+	dump_decl_name (buffer, node, flags);
+	pp_string (buffer, "/ ");
+	op0 = NAMELIST_DECL_ASSOCIATED_DECL(node);
+	FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (op0), i, value)
+	  {
+	if (i != 0)
+	  pp_string (buffer, ", ");
+	if (value)
+	  dump_decl_name (buffer, value, flags);
+	  }
+	pp_semicolon (buffer);
+	break;
+  }
+
 case RESULT_DECL:
   pp_string (buffer, "");
   break;
 
 case COMPONENT_REF:
   op0 = TREE_OPERAND (node, 0);
   str = ".";
   if (op0
 	  && (TREE_CODE (op0) == INDIRECT_REF
 	  || (TREE_CODE (op0) == MEM_REF
@@ -1713,21 +1733,24 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
 case BIND_EXPR:
   pp_left_brace (buffer);
   if (!(flags & TDF_SLIM))
 	{
 	  if (BIND_EXPR_VARS (node))
 	{
 	  pp_newline (buffer);
 
 	  for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
 		{
-		  print_declaration (buffer, op0, spc+2, flags);
+		  if (TREE_CODE(op0) == NAMELIST_DECL)
+		dump_generic_node (buffer, op0, spc+2, flags, false);
+		  else
+		print_declaration (buffer, op0, spc+2, flags);
 		  pp_newline (buffer);
 		}
 	}
 
 	  newline_and_indent (buffer, spc+2);
 	  dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
 	  newline_and_indent (buffer, spc);
 	  pp_right_brace (buffer);
 	}
   is_expr = false;


Re: [libstdc++-v3] PR 60308: leak in deque constructor

2014-02-22 Thread Jonathan Wakely
On 22 February 2014 08:53, Marc Glisse wrote:
> Hello,
>
> this fixes a bug I introduced when adding noexcept all over the place by
> reverting the guilty bit.
>
> Tested with no regression on x86_64-linux-gnu, and checked that the leak has
> disappeared in the PR.
>

This is OK, thanks for the quick fix.


Option on gcc.c, Comment Correction and License addition.

2014-02-22 Thread Alangi Derick

Index: gcc/gcc.c
===
--- gcc/gcc.c	(revision 208009)
+++ gcc/gcc.c	(working copy)
@@ -3108,8 +3108,21 @@
   fputs (_("  -specs=Override built-in specs with the contents of \n"), stdout);
   fputs (_("  -std=  Assume that the input sources are for \n"), stdout);
   fputs (_("\
+  -combineCompiling multiple source files telling the driver to pass\n\
+     all the source files to the compiler at once (allowing IMA).\n\
+     Currently, the only language supported is C.\n"), stdout);
+  fputs (_("  -ansi   In C mode, support all ISO C90 programs. In C++ mode, \n\
+  			  remove GNU extensions that conflict with ISO C++. Turns \n\
+  			  off certain features of GCC that are incompatible with ISO C90 \n\
+  			  of standard C++ such as 'asm' and 'typeof' keyword and predefined\n\
+  			   macros such as 'unix' and 'var' that identify the type of system you are using.\n"), stdout);
+  fputs (_("\
   --sysroot=Use  as the root directory for headers\n\
and libraries\n"), stdout);
+  fputs (_("  -w Inhibit all warning messages.\n"), stdout);
+  fputs (_("\
+  -Q   Makes the compiler print out each function name as it is compiled,\n\
+  			 and print some statistics about each pass when it finishes.\n"), stdout);
   fputs (_("  -BAdd  to the compiler's search paths\n"), stdout);
   fputs (_("  -v   Display the programs invoked by the compiler\n"), stdout);
   fputs (_("  -### Like -v but options quoted and commands not executed\n"), stdout);
   

Index: gcc/version.h
===
--- gcc/version.h	(revision 208009)
+++ gcc/version.h	(working copy)
@@ -1,3 +1,24 @@
+/* Version of GCC compiler.
+	Copyright (C) 2004-2014 Free Software Foundation, Inc.
+   Contributed by Nathan Sidwell 
+   Re-implemented in C++ by Diego Novillo 
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
 #ifndef GCC_VERSION_H
 #define GCC_VERSION_H
 extern const char version_string[];
 

Index: gcc/calls.h
===
--- gcc/calls.h	(revision 208009)
+++ gcc/calls.h	(working copy)
@@ -1,4 +1,4 @@
-/* Declarations anda data types for RTL call insn generation.
+/* Declarations and data types for RTL call insn generation.
Copyright (C) 2013-2014 Free Software Foundation, Inc.
 
 This file is part of GCC.


Re: [Patch, fortran] PR51976 - [F2003] Support deferred-length character components of derived types (allocatable string length)

2014-02-22 Thread Mikael Morin
Le 19/02/2014 16:51, Janus Weil a écrit :
> The patch was not applying cleanly any more, so here is a re-diffed
> version for current trunk. It works nicely on the included test case
> as well as the one provided by Walter Spector in comment 12 of the PR.
> 
> Since, also in the current state, "character(:)" works only in a
> subset of all cases, I think it cannot hurt to add more cases that
> work for 4.9 (even if still not all possible cases work).
> 
> Please let me know what you think ...
> 
> Cheers,
> Janus
> 

Review:

> PR fortran/51976
> * gfortran.h : Add deferred_parameter attribute.
Add the name of the struct before ':'
like "(struct symbol_attribute)" or maybe just "(symbol_attribute)"

> * trans.c (gfc_deferred_strlen): New function.
> * trans.h : Prototype for the new function.
This is really nitpicking but "(gfc_deferred_strlen)" should be in front
of trans.h as well.


Now regarding the patch itself, I don't know character handling very
well, but it seems to me that the patch makes the (wrong) assumption
that characters are of default kind, so that string length is the same
as memory size.
Namely:

> Index: gcc/fortran/trans-array.c
> ===
> --- gcc/fortran/trans-array.c (revision 207896)
> +++ gcc/fortran/trans-array.c (working copy)
> @@ -7365,7 +7365,7 @@ get_full_array_size (stmtblock_t *block, tree decl
>  
>  static tree
>  duplicate_allocatable (tree dest, tree src, tree type, int rank,
> -bool no_malloc)
> +bool no_malloc, tree strlen)
>  {
>tree tmp;
>tree size;
> @@ -7386,7 +7386,11 @@ duplicate_allocatable (tree dest, tree src, tree t
>null_data = gfc_finish_block (&block);
>  
>gfc_init_block (&block);
> -  size = TYPE_SIZE_UNIT (TREE_TYPE (type));
> +  if (strlen != NULL_TREE)
> + size = strlen;
> +  else
> + size = TYPE_SIZE_UNIT (TREE_TYPE (type));
> +
here...

>if (!no_malloc)
>   {
> tmp = gfc_call_malloc (&block, type, size);
> @@ -7410,8 +7414,11 @@ duplicate_allocatable (tree dest, tree src, tree t
>else
>   nelems = gfc_index_one_node;
>  
> -  tmp = fold_convert (gfc_array_index_type,
> -   TYPE_SIZE_UNIT (gfc_get_element_type (type)));
> +  if (strlen != NULL_TREE)
> + tmp = fold_convert (gfc_array_index_type, strlen);
> +  else
> + tmp = fold_convert (gfc_array_index_type,
> + TYPE_SIZE_UNIT (gfc_get_element_type (type)));
... and/or here,

>size = fold_build2_loc (input_location, MULT_EXPR, 
> gfc_array_index_type,
> nelems, tmp);
>if (!no_malloc)
> Index: gcc/fortran/trans-expr.c
> ===
> --- gcc/fortran/trans-expr.c  (revision 207896)
> +++ gcc/fortran/trans-expr.c  (working copy)
> @@ -6043,9 +6051,40 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp
> gfc_add_expr_to_block (&block, tmp);
>   }
>  }
> -  else
> +  else if (gfc_deferred_strlen (cm, &tmp))
>  {
> -  /* Scalar component.  */
> +  tree strlen;
> +  strlen = tmp;
> +  gcc_assert (strlen);
> +  strlen = fold_build3_loc (input_location, COMPONENT_REF,
> + TREE_TYPE (strlen),
> + TREE_OPERAND (dest, 0),
> + strlen, NULL_TREE);
> +
> +  if (expr->expr_type == EXPR_NULL)
> + {
> +   tmp = build_int_cst (TREE_TYPE (cm->backend_decl), 0);
> +   gfc_add_modify (&block, dest, tmp);
> +   tmp = build_int_cst (TREE_TYPE (strlen), 0);
> +   gfc_add_modify (&block, strlen, tmp);
> + }
> +  else
> + {
> +   gfc_init_se (&se, NULL);
> +   gfc_conv_expr (&se, expr);
> +   tmp = build_call_expr_loc (input_location,
> +  builtin_decl_explicit (BUILT_IN_MALLOC),
> +  1, se.string_length);
here,

> +   gfc_add_modify (&block, dest,
> +   fold_convert (TREE_TYPE (dest), tmp));
> +   gfc_add_modify (&block, strlen, se.string_length);
> +   tmp = gfc_build_memcpy_call (dest, se.expr, se.string_length);
> +   gfc_add_expr_to_block (&block, tmp);
> + }
> +}
> +  else if (!cm->attr.deferred_parameter)
> +{
> +  /* Scalar component (excluding deferred parameters).  */
>gfc_init_se (&se, NULL);
>gfc_init_se (&lse, NULL);
>  
> Index: gcc/fortran/trans-stmt.c
> ===
> --- gcc/fortran/trans-stmt.c  (revision 207896)
> +++ gcc/fortran/trans-stmt.c  (working copy)
> @@ -5028,6 +5028,11 @@ gfc_trans_allocate (gfc_code * code)
> if (tmp && TREE_CODE (tmp) == VAR_DECL)
>   gfc_add_modify (&se.pre, tmp, fold_convert (TREE_TYPE (tmp),
>   memsz));
> +   e

Re: [Patch, fortran] PR51976 - [F2003] Support deferred-length character components of derived types (allocatable string length)

2014-02-22 Thread Steve Kargl
On Sat, Feb 22, 2014 at 04:38:52PM +0100, Mikael Morin wrote:
> > +
> > +bool
> > +gfc_deferred_strlen (gfc_component *c, tree *decl)
> > +{
> > +  char name[GFC_MAX_SYMBOL_LEN+1];

Shouldn't this be +2?

> > +  gfc_component *strlen;
> > +  if (!(c->ts.type == BT_CHARACTER && c->ts.deferred))
> > +return false;
> > +  sprintf (name, "_%s", c->name);

One for NULL termination and one for '_' character.

> > +  for (strlen = c; strlen; strlen = strlen->next)
> > +if (strcmp (strlen->name, name) == 0)
> > +  break;
> maybe gfc_find_component could be used here.
> 
> > +  *decl = strlen ? strlen->backend_decl : NULL_TREE;
> > +  return strlen != NULL;
> > +}

-- 
Steve


Committed: Add CRIS to logical_op_short_circuit

2014-02-22 Thread Hans-Peter Nilsson
There was a new effective-target predicate (thanks, Richard S),
but the droplet that broke the camel's back or something, wasn't
added to its target-list.  Committed after brief testing
(checking that tests fail before, checking that tests pass after
patch).

Other observations:
- LOGICAL_OP_NON_SHORT_CIRCUIT should move into defaults.h
instead of the identical copies in fold-const.c and
tree-ssa-ifcombine.c (both default to BRANCH_COST >= 2).
- There seem to be more targets to add to that list (requires
grep and test) and more tests that should use the predicate
(requires at least brief analysis).

gcc/testsuite:
PR testsuite/60173
* lib/target-supports.exp
(check_effective_target_logical_op_short_circuit): Add cris-*-*
and crisv32-*-* to list.

Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   (revision 208041)
+++ gcc/testsuite/lib/target-supports.exp   (working copy)
@@ -5696,6 +5696,7 @@ proc check_effective_target_logical_op_s
 if { [istarget mips*-*-*]
 || [istarget arc*-*-*]
 || [istarget avr*-*-*]
+|| [istarget crisv32-*-*] || [istarget cris-*-*]
 || [check_effective_target_arm_cortex_m] } {
return 1
 }

brgds, H-P


[C PATCH] remove goto in c_parser_sizeof_expression

2014-02-22 Thread Prathamesh Kulkarni
Not sure if this a good idea, but it seemed to me that goto sizeof_expr; wasn't
really required in c_parser_sizeof_expression.
Bootstrapped and regression tested on x8_64-unknown-linux-gnu
Ok for trunk ?

* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;

Thanks and Regards,
Prathamesh
Index: gcc/c/c-parser.c
===
--- gcc/c/c-parser.c	(revision 207916)
+++ gcc/c/c-parser.c	(working copy)
@@ -6518,26 +6518,27 @@ c_parser_sizeof_expression (c_parser *pa
 	  expr = c_parser_postfix_expression_after_paren_type (parser,
 			   type_name,
 			   expr_loc);
-	  goto sizeof_expr;
 	}
+  else
+  {
   /* sizeof ( type-name ).  */
   c_inhibit_evaluation_warnings--;
   in_sizeof--;
   return c_expr_sizeof_type (expr_loc, type_name);
+  }
 }
   else
 {
   expr_loc = c_parser_peek_token (parser)->location;
   expr = c_parser_unary_expression (parser);
-sizeof_expr:
-  c_inhibit_evaluation_warnings--;
-  in_sizeof--;
-  mark_exp_read (expr.value);
-  if (TREE_CODE (expr.value) == COMPONENT_REF
+}
+c_inhibit_evaluation_warnings--;
+in_sizeof--;
+mark_exp_read (expr.value);
+if (TREE_CODE (expr.value) == COMPONENT_REF
 	  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
 	error_at (expr_loc, "% applied to a bit-field");
   return c_expr_sizeof_expr (expr_loc, expr);
-}
 }
 
 /* Parse an alignof expression.  */


Re: [C PATCH] remove goto in c_parser_sizeof_expression

2014-02-22 Thread Prathamesh Kulkarni
On Sat, Feb 22, 2014 at 10:34 PM, Prathamesh Kulkarni
 wrote:
> Not sure if this a good idea, but it seemed to me that goto sizeof_expr; 
> wasn't
> really required in c_parser_sizeof_expression.
> Bootstrapped and regression tested on x8_64-unknown-linux-gnu
> Ok for trunk ?
>
> * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;
* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr.
>
> Thanks and Regards,
> Prathamesh


Re: [C PATCH] remove goto in c_parser_sizeof_expression

2014-02-22 Thread Marek Polacek
On Sat, Feb 22, 2014 at 10:34:13PM +0530, Prathamesh Kulkarni wrote:
> Not sure if this a good idea, but it seemed to me that goto sizeof_expr; 
> wasn't
> really required in c_parser_sizeof_expression.
> Bootstrapped and regression tested on x8_64-unknown-linux-gnu
> Ok for trunk ?
> 
> * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;
> 
> Thanks and Regards,
> Prathamesh

I'm not against it, but...

> Index: gcc/c/c-parser.c
> ===
> --- gcc/c/c-parser.c  (revision 207916)
> +++ gcc/c/c-parser.c  (working copy)
> @@ -6518,26 +6518,27 @@ c_parser_sizeof_expression (c_parser *pa
> expr = c_parser_postfix_expression_after_paren_type (parser,
>  type_name,
>  expr_loc);
> -   goto sizeof_expr;
>   }

Remove { } around expr = c_parser_...

> +  else
> +  {
>/* sizeof ( type-name ).  */
>c_inhibit_evaluation_warnings--;
>in_sizeof--;
>return c_expr_sizeof_type (expr_loc, type_name);
> +  }

Tab before { and }.

> +c_inhibit_evaluation_warnings--;
> +in_sizeof--;
> +mark_exp_read (expr.value);
> +if (TREE_CODE (expr.value) == COMPONENT_REF
> && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
>   error_at (expr_loc, "% applied to a bit-field");
>return c_expr_sizeof_expr (expr_loc, expr);

This hunk of code is wrongly indented.

Marek


Re: RFA: fix compile/pr17906.c / compile/pr35432.c -O3 -g ICEs

2014-02-22 Thread Denis Chertykov
2014-02-19 19:15 GMT+04:00 Joern Rennecke :
> When compiling compile/pr17906.c, compute_frame_pointer_to_fb_displacement
> passes the argument pointer to eliminate_regs.  This eliminates it to
> the frame pointer,
> which later causes and ICE because frame_pointer_needed is not set.
>
> The problem is that ELIMINABLE_REGS in avr.h does not specify a direct
> elimination
> from the argument pointer to the stack pointer; the attached patch
> rectifies that.
> Regression tested with the avr simulator.
>
> OK to apply?

Sorry for delay.
I have tried to remember why the AVR port don't have this elimination.
(No luck ;)
Please, apply the patch.

Denis.


Re: [C PATCH] remove goto in c_parser_sizeof_expression

2014-02-22 Thread Prathamesh Kulkarni
On Sat, Feb 22, 2014 at 11:44 PM, Marek Polacek  wrote:
> On Sat, Feb 22, 2014 at 10:34:13PM +0530, Prathamesh Kulkarni wrote:
>> Not sure if this a good idea, but it seemed to me that goto sizeof_expr; 
>> wasn't
>> really required in c_parser_sizeof_expression.
>> Bootstrapped and regression tested on x8_64-unknown-linux-gnu
>> Ok for trunk ?
>>
>> * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;
>>
>> Thanks and Regards,
>> Prathamesh
>
> I'm not against it, but...
>
>> Index: gcc/c/c-parser.c
>> ===
>> --- gcc/c/c-parser.c  (revision 207916)
>> +++ gcc/c/c-parser.c  (working copy)
>> @@ -6518,26 +6518,27 @@ c_parser_sizeof_expression (c_parser *pa
>> expr = c_parser_postfix_expression_after_paren_type (parser,
>>  type_name,
>>  expr_loc);
>> -   goto sizeof_expr;
>>   }
>
> Remove { } around expr = c_parser_...
>
>> +  else
>> +  {
>>/* sizeof ( type-name ).  */
>>c_inhibit_evaluation_warnings--;
>>in_sizeof--;
>>return c_expr_sizeof_type (expr_loc, type_name);
>> +  }
>
> Tab before { and }.
>
>> +c_inhibit_evaluation_warnings--;
>> +in_sizeof--;
>> +mark_exp_read (expr.value);
>> +if (TREE_CODE (expr.value) == COMPONENT_REF
>> && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
>>   error_at (expr_loc, "% applied to a bit-field");
>>return c_expr_sizeof_expr (expr_loc, expr);
>
> This hunk of code is wrongly indented.
>
Is this fine ?
* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr.

> Marek
Index: gcc/c/c-parser.c
===
--- gcc/c/c-parser.c	(revision 207916)
+++ gcc/c/c-parser.c	(working copy)
@@ -6514,30 +6514,29 @@ c_parser_sizeof_expression (c_parser *pa
 	  return ret;
 	}
   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
-	{
-	  expr = c_parser_postfix_expression_after_paren_type (parser,
-			   type_name,
-			   expr_loc);
-	  goto sizeof_expr;
-	}
-  /* sizeof ( type-name ).  */
-  c_inhibit_evaluation_warnings--;
-  in_sizeof--;
-  return c_expr_sizeof_type (expr_loc, type_name);
+	expr = c_parser_postfix_expression_after_paren_type (parser,
+			type_name,
+			expr_loc);
+  else
+{
+  /* sizeof ( type-name ).  */
+  c_inhibit_evaluation_warnings--;
+  in_sizeof--;
+  return c_expr_sizeof_type (expr_loc, type_name);
+}
 }
   else
 {
   expr_loc = c_parser_peek_token (parser)->location;
   expr = c_parser_unary_expression (parser);
-sizeof_expr:
-  c_inhibit_evaluation_warnings--;
-  in_sizeof--;
-  mark_exp_read (expr.value);
-  if (TREE_CODE (expr.value) == COMPONENT_REF
-	  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
-	error_at (expr_loc, "% applied to a bit-field");
-  return c_expr_sizeof_expr (expr_loc, expr);
 }
+c_inhibit_evaluation_warnings--;
+in_sizeof--;
+mark_exp_read (expr.value);
+if (TREE_CODE (expr.value) == COMPONENT_REF
+	  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
+	error_at (expr_loc, "% applied to a bit-field");
+return c_expr_sizeof_expr (expr_loc, expr);
 }
 
 /* Parse an alignof expression.  */


Re: [C PATCH] remove goto in c_parser_sizeof_expression

2014-02-22 Thread Marek Polacek
On Sun, Feb 23, 2014 at 12:19:49AM +0530, Prathamesh Kulkarni wrote:
> Is this fine ?

No, there still are some formatting issues.

> Index: gcc/c/c-parser.c
> ===
> --- gcc/c/c-parser.c  (revision 207916)
> +++ gcc/c/c-parser.c  (working copy)
> @@ -6514,30 +6514,29 @@ c_parser_sizeof_expression (c_parser *pa
> return ret;
>   }
>if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
> - {
> -   expr = c_parser_postfix_expression_after_paren_type (parser,
> -type_name,
> -expr_loc);
> -   goto sizeof_expr;
> - }
> -  /* sizeof ( type-name ).  */
> -  c_inhibit_evaluation_warnings--;
> -  in_sizeof--;
> -  return c_expr_sizeof_type (expr_loc, type_name);
> + expr = c_parser_postfix_expression_after_paren_type (parser,
> + type_name,
> + expr_loc);

This should be
  if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
expr = c_parser_postfix_expression_after_paren_type (parser,
 type_name,
 expr_loc);

> +  else
> +{
> +  /* sizeof ( type-name ).  */
> +  c_inhibit_evaluation_warnings--;
> +  in_sizeof--;
> +  return c_expr_sizeof_type (expr_loc, type_name);
> +}

Replace 8 spaces in indentation with a tab.

>else
>  {
>expr_loc = c_parser_peek_token (parser)->location;
>expr = c_parser_unary_expression (parser);
> -sizeof_expr:
> -  c_inhibit_evaluation_warnings--;
> -  in_sizeof--;
> -  mark_exp_read (expr.value);
> -  if (TREE_CODE (expr.value) == COMPONENT_REF
> -   && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
> - error_at (expr_loc, "% applied to a bit-field");
> -  return c_expr_sizeof_expr (expr_loc, expr);
>  }
> +c_inhibit_evaluation_warnings--;
> +in_sizeof--;
> +mark_exp_read (expr.value);

Two spaces here, not four.

> +if (TREE_CODE (expr.value) == COMPONENT_REF
> +   && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
> + error_at (expr_loc, "% applied to a bit-field");
> +return c_expr_sizeof_expr (expr_loc, expr);

And this should be
  if (TREE_CODE (expr.value) == COMPONENT_REF
  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
error_at (expr_loc, "% applied to a bit-field");
  return c_expr_sizeof_expr (expr_loc, expr);

Marek


Re: configure check for flex

2014-02-22 Thread Bruce Korb

On 01/27/14 18:20, Hans-Peter Nilsson wrote:

You'd need some additional conditions.  There might be the
additional issue that any "lex" is expected to work too, not
just "flex".


It isn't committed 'cuz nobody said, "Okay."
I do wish either someone would say, "Okay." or come up with something
that works.
I went to the effort to figure out where things got off the rails and
did something that
worked for me.  Just saying, "That won't work" without a workable alternative
is a bit irritating.


There are surely plenty of opportunities around for
irritatation! :)  Dropped patches surely; I thought I was
helpful there.  Ungraceful errors from easily identifiable
common gotchas definitely, so what you're trying to achieve is
IMHO desirable.  Patches hacking in something that just happened
to work for someone too; I tried to stop that from happening.


I spend my programming life either hacking at a startup or maintaining
a few GNU tools I'm responsible for (e.g. "fixincludes").  This is
outside of that realm, so I'm trying to produce enough of a patch
that someone who knows how better than I do can finish it.

I put my patch into the top level configure.ac file, not the
gcc or libcpp ones.  I suppose I could hack out the logic for
setting is_release from those files, but really the crucial part
is just having an intelligible error message that leads someone
with a removed "flex" tool to a resolution of the issue.
Someday maybe important tools won't disappear on you when
you update your distribution, but barring that, the silent
requirement for flex combined with an uninformative error
message yields a booby trap.  I hate booby traps.:)

Cheers - Bruce



$ svn diff configure.ac
Index: configure.ac
===
--- configure.ac(revision 208044)
+++ configure.ac(working copy)
@@ -1319,10 +1319,17 @@
 # Used for setting $lt_cv_objdir
 _LT_CHECK_OBJDIR

-# Check for GMP, MPFR and MPC
+# Check for flex, GMP, MPFR and MPC
+[for p in flex
+do
+  c=`command -v $p`
+  test -x "$c" || \
+]AC_MSG_ERROR([the $c command is required to build GCC])[
+done
+
 gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
-have_gmp=no
+have_gmp=no]

 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.



Re: configure check for flex

2014-02-22 Thread Bruce Korb
In retrospect, it occurs to me that a "am-i-ready-to-build.sh" script
in the contrib directory might be useful, too.


Unreviewed Patch

2014-02-22 Thread rbmj

Hi all,

Just a ping, I haven't gotten anything back on this patch:
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00621.html

Thanks!


[PATCH,rs6000] Add -maltivec=be support for vec_lde and vec_ste

2014-02-22 Thread Bill Schmidt
Hi,

This patch adds -maltivec=be support for vec_lde and vec_ste, similarly
to what was done for vec_ld, vec_st, vec_ldl, and vec_stl.  Much of the
same infrastructure is used.  Because the insn pattern for vec_ste is
formed slightly differently than the ones for vec_st and vec_stl, we
can't reuse altivec_expand_stvx_be in this case (but
altivec_expand_lvx_be works fine for vec_lde).  There are four new test
cases, covering correct behavior for all appropriate vector types for
BE, LE, and LE with -maltivec=be.

Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
regressions.  Is this ok for trunk?

Thanks,
Bill


gcc:

2014-02-22  Bill Schmidt  

* config/rs6000/altivec.md (altivec_lvex): Replace
define_insn with define_expand and new define_insn
*altivec_lvex_internal.
(altivec_stvex): Replace define_insn with define_expand
and new define_insn *altivec_stvex_internal.
* config/rs6000/rs6000-protos.h (altivec_expand_stvex_be): New
prototype.
* config/rs6000/rs6000.c (altivec_expand_lvx_be): Document use by
lve*x built-ins.
(altivec_expand_stvex_be): New function.

gcc/testsuite:

2014-02-22  Bill Schmidt  

* testsuite/gcc.dg/vmx/lde.c: New test.
* testsuite/gcc.dg/vmx/lde-be-order.c: New test.
* testsuite/gcc.dg/vmx/ste.c: New test.
* testsuite/gcc.dg/vmx/ste-be-order.c: New test.


Index: gcc/config/rs6000/altivec.md
===
--- gcc/config/rs6000/altivec.md(revision 208022)
+++ gcc/config/rs6000/altivec.md(working copy)
@@ -2325,12 +2325,26 @@
 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
 ;; identical rtl but different instructions-- and gcc gets confused.
 
-(define_insn "altivec_lvex"
+(define_expand "altivec_lvex"
   [(parallel
 [(set (match_operand:VI 0 "register_operand" "=v")
  (match_operand:VI 1 "memory_operand" "Z"))
  (unspec [(const_int 0)] UNSPEC_LVE)])]
   "TARGET_ALTIVEC"
+{
+  if (!BYTES_BIG_ENDIAN && VECTOR_ELT_ORDER_BIG)
+{
+  altivec_expand_lvx_be (operands[0], operands[1], mode, UNSPEC_LVE);
+  DONE;
+}
+})
+
+(define_insn "*altivec_lvex_internal"
+  [(parallel
+[(set (match_operand:VI 0 "register_operand" "=v")
+ (match_operand:VI 1 "memory_operand" "Z"))
+ (unspec [(const_int 0)] UNSPEC_LVE)])]
+  "TARGET_ALTIVEC"
   "lvex %0,%y1"
   [(set_attr "type" "vecload")])
 
@@ -2435,10 +2449,22 @@
   "stvxl %1,%y0"
   [(set_attr "type" "vecstore")])
 
-(define_insn "altivec_stvex"
+(define_expand "altivec_stvex"
   [(set (match_operand: 0 "memory_operand" "=Z")
(unspec: [(match_operand:VI 1 "register_operand" "v")] 
UNSPEC_STVE))]
   "TARGET_ALTIVEC"
+{
+  if (!BYTES_BIG_ENDIAN && VECTOR_ELT_ORDER_BIG)
+{
+  altivec_expand_stvex_be (operands[0], operands[1], mode, 
UNSPEC_STVE);
+  DONE;
+}
+})
+
+(define_insn "*altivec_stvex_internal"
+  [(set (match_operand: 0 "memory_operand" "=Z")
+   (unspec: [(match_operand:VI 1 "register_operand" "v")] 
UNSPEC_STVE))]
+  "TARGET_ALTIVEC"
   "stvex %1,%y0"
   [(set_attr "type" "vecstore")])
 
Index: gcc/config/rs6000/rs6000-protos.h
===
--- gcc/config/rs6000/rs6000-protos.h   (revision 208022)
+++ gcc/config/rs6000/rs6000-protos.h   (working copy)
@@ -60,6 +60,7 @@ extern void altivec_expand_vec_perm_le (rtx op[4])
 extern bool rs6000_expand_vec_perm_const (rtx op[4]);
 extern void altivec_expand_lvx_be (rtx, rtx, enum machine_mode, unsigned);
 extern void altivec_expand_stvx_be (rtx, rtx, enum machine_mode, unsigned);
+extern void altivec_expand_stvex_be (rtx, rtx, enum machine_mode, unsigned);
 extern void rs6000_expand_extract_even (rtx, rtx, rtx);
 extern void rs6000_expand_interleave (rtx, rtx, rtx, bool);
 extern void build_mask64_2_operands (rtx, rtx *);
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 208022)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -11779,7 +11779,7 @@ swap_selector_for_mode (enum machine_mode mode)
   return force_reg (V16QImode, gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v 
(16, perm)));
 }
 
-/* Generate code for an "lvx" or "lvxl" built-in for a little endian target
+/* Generate code for an "lvx", "lvxl", or "lve*x" built-in for a little endian 
target
with -maltivec=be specified.  Issue the load followed by an 
element-reversing
permute.  */
 void
@@ -11816,6 +11816,23 @@ altivec_expand_stvx_be (rtx op0, rtx op1, enum mac
   emit_insn (par);
 }
 
+/* Generate code for a "stve*x" built-in for a little endian target with 
-maltivec=be
+   specified.  Issue the store preceded by an element-reversing permute.  */
+void
+altivec_expand_stvex_be (rtx op0, rtx op1, enum machine_mode mode, unsigned 
unspec)
+{
+  enum machine_mode inner_mode = GET_MODE_IN