Re: [PATCH 2/4] Docs: extend.texi: Remove trailing blanks from lines

2011-05-04 Thread Mike Stump
On May 4, 2011, at 11:46 AM, Joseph S. Myers wrote:
 I explicitly approve trailing whitespace removal from all .texi files and 
 other documentation not imported from upstream sources outside of GCC 
 (subject to handling generated files properly, so any changes to tm.texi 
 should be done by changing source files such as tm.texi.in and then 
 regenerating tm.texi).

Checked in r173401 and r173402.  These sorts of patches usually I don't post, 
as they tend to hit the size limitation and are exceedingly boring.  The 
important part of it is:

$ svn diff -r173400:173402 . -x -b
Index: loop.texi
===
Index: generic.texi
===
Index: sourcebuild.texi
===
Index: plugins.texi
===
Index: cpp.texi
===
Index: extend.texi
===
Index: passes.texi
===
Index: cfg.texi
===
Index: objc.texi
===
Index: gimple.texi
===
Index: tm.texi
===
Index: libgcc.texi
===
Index: tree-ssa.texi
===
Index: tm.texi.in
===
Index: invoke.texi
===
Index: gcov.texi
===
Index: contrib.texi
===
Index: md.texi
===
Index: rtl.texi
===
Index: hostconfig.texi
===
Index: gty.texi
===
Index: install.texi
===

which is one of the audit steps I perform before checkin of these types of 
patches.  One other step, is to hand audit every single character changed.  The 
testsuite has a few lines that cannot be changed, for example.  These are the 
doc bits I care about.


Re: [PATCH 2/4] Docs: extend.texi: Remove trailing blanks from lines

2011-05-04 Thread Mike Stump
On May 4, 2011, at 11:40 AM, Gerald Pfeifer wrote:
 Documentation may be a bit more relaxed, and if you have one doc
 maintainer approve and the other abstain that may be more boring
 that you might hope for. :-)

Actually, I was aiming for a global person to ack gcc/*...  This could be less 
boring that just gcc/doc.  :-)


[PATCH] don't use build_function_type in the ObjC/C++ frontends

2011-05-04 Thread Nathan Froyd
The last remaining uses of build_function_type in the ObjC/C++ frontends
comes from this pattern:

  tree method_param_types =
get_arg_type_list (method_prototype, METHOD_REF, super_flag);
  tree ftype = build_function_type (ret_type, method_param_types);

To eliminate this, I made the following changes:

- Package the above pattern up into a function,
  build_function_type_for_method.  This change meant that
  get_arg_type_list didn't need to exist as a separate function, so I
  made get_arg_type_list go away.

- To make build_function_type_for_method call build_function_type_vec, I
  needed to change the interface to the runtime hook function
  get_arg_type_list_base: it now takes a VEC to which it appends the
  necessary arguments.  build_function_type_for_method then appends the
  appropriate arguments and builds the new function type.

- However, the NeXT v2 ABI method call builder used the type list
  returned by get_arg_type_list separately, passing it to
  objc_copy_to_temp_side_effect_params.  I therefore changed that
  function to consult the newly built function type instead, using an
  iterator.

I also adjust the header comments to reflect the new world order and
wrapped them to  80 columns where appropriate.

Tested on x86_64-unknown-linux-gnu, ObjC/C++ testsuites.  I will fix any
Darwin breakage that comes up, though I may need some debugging help to
do so.  OK to commit?

-Nathan

gcc/objc/
* objc-runtime-shared-support.h (get_arg_type_list): Delete.
(build_function_type_for_method): Declare.
* objc-runtime-hooks.h (struct _objc_runtime_hooks_r): Change
type of get_arg_type_base_list field.
* objc-act.h (OBJC_VOID_AT_END): Delete.
* objc-act.c (get_arg_type_list): Delete.
(build_function_type_for_method): New function.
(objc_decl_method_attributes): Call build_function_type_for_method.
(really_start_method): Likewise.
* objc-gnu-runtime-abi-01.c
(gnu_runtime_abi_01_get_type_arg_list_base): Change prototype and
adjust function accordingly.  Update header comment.
(build_objc_method_call): Call build_function_type_for_method.
* objc-next-runtime-abi-01.c
(next_runtime_abi_01_get_type_arg_list_base): Change prototype and
adjust function accordingly.  Update header comment.
(build_objc_method_call): Call build_function_type_for_method.
* objc-next-runtime-abi-02.c
(next_runtime_abi_02_get_type_arg_list_base): Change prototype and
adjust function accordingly.  Update header comment.
(objc_copy_to_temp_side_effect_params): Take fntype instead of a
typelist.  Use function_args_iterator for traversing fntype.
(build_v2_build_objc_method_call): Adjust call to it.
Call build_function_type_for_method

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 025f375..e3de6db 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -5040,8 +5040,9 @@ objc_decl_method_attributes (tree *node, tree attributes, 
int flags)
 (by setting TREE_DEPRECATED and TREE_THIS_VOLATILE) so there
 is nothing to do.  */
   tree saved_type = TREE_TYPE (*node);
-  TREE_TYPE (*node) = build_function_type
-   (TREE_VALUE (saved_type), get_arg_type_list (*node, METHOD_REF, 0));
+  TREE_TYPE (*node)
+   = build_function_type_for_method (TREE_VALUE (saved_type), *node,
+ METHOD_REF, 0);
   decl_attributes (node, filtered_attributes, flags);
   METHOD_TYPE_ATTRIBUTES (*node) = TYPE_ATTRIBUTES (TREE_TYPE (*node));
   TREE_TYPE (*node) = saved_type;
@@ -5054,60 +5055,66 @@ objc_method_decl (enum tree_code opcode)
   return opcode == INSTANCE_METHOD_DECL || opcode == CLASS_METHOD_DECL;
 }
 
-/* Used by `build_objc_method_call'.  Return an argument list for
-   method METH.  CONTEXT is either METHOD_DEF or METHOD_REF, saying
-   whether we are trying to define a method or call one.  SUPERFLAG
-   says this is for a send to super; this makes a difference for the
-   NeXT calling sequence in which the lookup and the method call are
-   done together.  If METH is null, user-defined arguments (i.e.,
-   beyond self and _cmd) shall be represented by `...'.  */
+/* Return a function type for METHOD with RETURN_TYPE.  CONTEXT is
+   either METHOD_DEF or METHOD_REF, indicating whether we are defining a
+   method or calling one.  SUPER_FLAG indicates whether this is a send
+   to super; this makes a difference for the NeXT calling sequence in
+   which the lookup and the method call are done together.  If METHOD is
+   NULL, user-defined arguments (i.e., beyond self and _cmd) shall be
+   represented as varargs.  */
 
 tree
-get_arg_type_list (tree meth, int context, int superflag)
+build_function_type_for_method (tree return_type, tree method,
+   int context, bool super_flag)
 {
-  tree arglist, akey;
+  VEC(tree,gc) 

Go patch committed: Use backend interface for slice types

2011-05-04 Thread Ian Lance Taylor
This patch to the Go frontend uses the backend interface for slice
types.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 37dae2a9c21b go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed May 04 08:38:47 2011 -0700
+++ b/go/gogo-tree.cc	Wed May 04 22:18:22 2011 -0700
@@ -1936,38 +1936,6 @@
   return build_fold_addr_expr(decl);
 }
 
-// Build the type of the struct that holds a slice for the given
-// element type.
-
-tree
-Gogo::slice_type_tree(tree element_type_tree)
-{
-  // We use int for the count and capacity fields in a slice header.
-  // This matches 6g.  The language definition guarantees that we
-  // can't allocate space of a size which does not fit in int
-  // anyhow. FIXME: integer_type_node is the the C type int but is
-  // not necessarily the Go type int.  They will differ when the C
-  // type int has fewer than 32 bits.
-  return Gogo::builtin_struct(NULL, __go_slice, NULL_TREE, 3,
-			  __values,
-			  build_pointer_type(element_type_tree),
-			  __count,
-			  integer_type_node,
-			  __capacity,
-			  integer_type_node);
-}
-
-// Given the tree for a slice type, return the tree for the type of
-// the elements of the slice.
-
-tree
-Gogo::slice_element_type_tree(tree slice_type_tree)
-{
-  go_assert(TREE_CODE(slice_type_tree) == RECORD_TYPE
-	  POINTER_TYPE_P(TREE_TYPE(TYPE_FIELDS(slice_type_tree;
-  return TREE_TYPE(TREE_TYPE(TYPE_FIELDS(slice_type_tree)));
-}
-
 // Build a constructor for a slice.  SLICE_TYPE_TREE is the type of
 // the slice.  VALUES is the value pointer and COUNT is the number of
 // entries.  If CAPACITY is not NULL, it is the capacity; otherwise
@@ -2011,21 +1979,6 @@
   return build_constructor(slice_type_tree, init);
 }
 
-// Build a constructor for an empty slice.
-
-tree
-Gogo::empty_slice_constructor(tree slice_type_tree)
-{
-  tree element_field = TYPE_FIELDS(slice_type_tree);
-  tree ret = Gogo::slice_constructor(slice_type_tree,
- fold_convert(TREE_TYPE(element_field),
-		  null_pointer_node),
- size_zero_node,
- size_zero_node);
-  TREE_CONSTANT(ret) = 1;
-  return ret;
-}
-
 // Build a map descriptor for a map of type MAPTYPE.
 
 tree
diff -r 37dae2a9c21b go/gogo.h
--- a/go/gogo.h	Wed May 04 08:38:47 2011 -0700
+++ b/go/gogo.h	Wed May 04 22:18:22 2011 -0700
@@ -465,16 +465,6 @@
   static void
   mark_fndecl_as_builtin_library(tree fndecl);
 
-  // Build the type of the struct that holds a slice for the given
-  // element type.
-  tree
-  slice_type_tree(tree element_type_tree);
-
-  // Given a tree for a slice type, return the tree for the element
-  // type.
-  static tree
-  slice_element_type_tree(tree slice_type_tree);
-
   // Build a constructor for a slice.  SLICE_TYPE_TREE is the type of
   // the slice.  VALUES points to the values.  COUNT is the size,
   // CAPACITY is the capacity.  If CAPACITY is NULL, it is set to
@@ -483,11 +473,6 @@
   slice_constructor(tree slice_type_tree, tree values, tree count,
 		tree capacity);
 
-  // Build a constructor for an empty slice.  SLICE_TYPE_TREE is the
-  // type of the slice.
-  static tree
-  empty_slice_constructor(tree slice_type_tree);
-
   // Build a map descriptor.
   tree
   map_descriptor(Map_type*);
diff -r 37dae2a9c21b go/types.cc
--- a/go/types.cc	Wed May 04 08:38:47 2011 -0700
+++ b/go/types.cc	Wed May 04 22:18:22 2011 -0700
@@ -4399,6 +4399,41 @@
   return this-length_tree_;
 }
 
+// Get the backend representation of the fields of a slice.  This is
+// not declared in types.h so that types.h doesn't have to #include
+// backend.h.
+//
+// We use int for the count and capacity fields.  This matches 6g.
+// The language more or less assumes that we can't allocate space of a
+// size which does not fit in int.
+
+static void
+get_backend_slice_fields(Gogo* gogo, Array_type* type,
+			 std::vectorBackend::Btyped_identifier* bfields)
+{
+  bfields-resize(3);
+
+  Type* pet = Type::make_pointer_type(type-element_type());
+  Btype* pbet = tree_to_type(pet-get_tree(gogo));
+
+  Backend::Btyped_identifier* p = (*bfields)[0];
+  p-name = __values;
+  p-btype = pbet;
+  p-location = UNKNOWN_LOCATION;
+
+  Type* int_type = Type::lookup_integer_type(int);
+
+  p = (*bfields)[1];
+  p-name = __count;
+  p-btype = tree_to_type(int_type-get_tree(gogo));
+  p-location = UNKNOWN_LOCATION;
+
+  p = (*bfields)[2];
+  p-name = __capacity;
+  p-btype = tree_to_type(int_type-get_tree(gogo));
+  p-location = UNKNOWN_LOCATION;
+}
+
 // Get a tree for the type of this array.  A fixed array is simply
 // represented as ARRAY_TYPE with the appropriate index--i.e., it is
 // just like an array in C.  An open array is a struct with three
@@ -4409,8 +,9 @@
 {
   if (this-length_ == NULL)
 {
-  tree struct_type = gogo-slice_type_tree(void_type_node);
-  return this-fill_in_slice_tree(gogo, struct_type);
+  std::vectorBackend::Btyped_identifier bfields;
+  get_backend_slice_fields(gogo, 

[google] improves option mismatch handling for LIPO (issue4479045)

2011-05-04 Thread David Li
This patch improves cross module option mismatch handling in LIPO mode -- will 
be commited to google/main.

1) Remove duplicates in the option list before comparison;
2) Force module incompatiblity when two modules disagree in -fexceptions 
setting. In LIPO mode, when option mismatch is discovered between the primary 
and aux module, a warning message is emitted, but the modules will be 
considered incompatible when -fripa-disallow-opt-mismatch is specified. With 
this change, exception option mismatch will force the primary module to reject 
the aux module.

Tested: SPEC with LIPO.


2011-05-04  David Li  davi...@google.com

* coverage.c (incompatible_cl_args): Better handling
of option mismatch.

Index: coverage.c
===
--- coverage.c  (revision 173353)
+++ coverage.c  (working copy)
@@ -213,6 +213,27 @@ is_last_module (unsigned mod_id)
   return (mod_id == module_infos[num_in_fnames - 1]-ident);
 }
 
+/* String hash function  */
+
+static hashval_t
+str_hash (const void *p)
+{
+  const char *s = (const char *)p;
+  return htab_hash_string (s);
+}
+
+/* String equal function  */
+
+static int
+str_eq (const void *p1, const void *p2)
+{
+  const char *s1 = (const char *)p1;
+  const char *s2 = (const char *)p2;
+
+  return !strcmp (s1, s2);
+}
+
+
 /* Returns true if the command-line arguments stored in the given module-infos
are incompatible.  */
 static bool
@@ -227,6 +248,9 @@ incompatible_cl_args (struct gcov_module
   unsigned int num_non_warning_opts1 = 0, num_non_warning_opts2 = 0;
   bool warning_mismatch = false;
   bool non_warning_mismatch = false;
+  bool with_fexceptions1 = true;
+  bool with_fexceptions2 = true;
+  htab_t option_tab1, option_tab2;
   unsigned int start_index1 = mod_info1-num_quote_paths +
 mod_info1-num_bracket_paths + mod_info1-num_cpp_defines +
 mod_info1-num_cpp_includes;
@@ -234,22 +258,52 @@ incompatible_cl_args (struct gcov_module
 mod_info2-num_bracket_paths + mod_info2-num_cpp_defines +
 mod_info2-num_cpp_includes;
 
+  option_tab1 = htab_create (10, str_hash, str_eq, NULL);
+  option_tab2 = htab_create (10, str_hash, str_eq, NULL);
+
   /* First, separate the warning and non-warning options.  */
   for (i = 0; i  mod_info1-num_cl_args; i++)
 if (mod_info1-string_array[start_index1 + i][1] == 'W')
   warning_opts1[num_warning_opts1++] =
mod_info1-string_array[start_index1 + i];
 else
-  non_warning_opts1[num_non_warning_opts1++] =
-   mod_info1-string_array[start_index1 + i];
+  {
+void **slot;
+char* option_string = mod_info1-string_array[start_index1 + i];
+
+if (!strcmp (-fexceptions, option_string))
+  with_fexceptions1 = true;
+else if (!strcmp (-fno-exceptions, option_string))
+  with_fexceptions1 = false;
+
+slot = htab_find_slot (option_tab1, option_string, INSERT);
+if (!*slot)
+  {
+*slot = option_string;
+non_warning_opts1[num_non_warning_opts1++] = option_string;
+  }
+  }
 
   for (i = 0; i  mod_info2-num_cl_args; i++)
 if (mod_info2-string_array[start_index2 + i][1] == 'W')
   warning_opts2[num_warning_opts2++] =
mod_info2-string_array[start_index2 + i];
 else
-  non_warning_opts2[num_non_warning_opts2++] =
-   mod_info2-string_array[start_index2 + i];
+  {
+void **slot;
+char* option_string = mod_info2-string_array[start_index2 + i];
+
+if (!strcmp (-fexceptions, option_string))
+  with_fexceptions2 = true;
+else if (!strcmp (-fno-exceptions, option_string))
+  with_fexceptions2 = false;
+slot = htab_find_slot (option_tab2, option_string, INSERT);
+if (!*slot)
+  {
+*slot = option_string;
+non_warning_opts2[num_non_warning_opts2++] = option_string;
+  }
+  }
 
   /* Compare warning options. If these mismatch, we emit a warning.  */
   if (num_warning_opts1 != num_warning_opts2)
@@ -272,11 +326,24 @@ incompatible_cl_args (struct gcov_module
 warning (OPT_Wripa_opt_mismatch, command line arguments mismatch for %s 
 and %s, mod_info1-source_filename, mod_info2-source_filename);
 
+   if (warn_ripa_opt_mismatch  non_warning_mismatch  flag_ripa_verbose)
+ {
+   inform (UNKNOWN_LOCATION, Options for %s, mod_info1-source_filename);
+   for (i = 0; i  num_non_warning_opts1; i++)
+ inform (UNKNOWN_LOCATION, non_warning_opts1[i]);
+   inform (UNKNOWN_LOCATION, Options for %s, mod_info2-source_filename);
+   for (i = 0; i  num_non_warning_opts2; i++)
+ inform (UNKNOWN_LOCATION, non_warning_opts2[i]);
+ }
+
   XDELETEVEC (warning_opts1);
   XDELETEVEC (warning_opts2);
   XDELETEVEC (non_warning_opts1);
   XDELETEVEC (non_warning_opts2);
-  return flag_ripa_disallow_opt_mismatch  non_warning_mismatch;
+  htab_delete (option_tab1);
+  

[Patch, Fortran] -std=f2008tr, TR 29113 and OPTIONAL arguments with BIND(C)

2011-05-04 Thread Tobias Burnus
This patch does the first minor steps towards TR 29113: It accepts the 
OPTIONAL attribute in procedures with C binding. As gfortran already 
passes absent arguments a NULL pointer, there is no changed needed, 
except in the diagnostics part. Additionally, it is a feature also 
supported by other compilers.


Additionally, this patch adds the option -std=f2008tr (tr = Technical 
Report(s)), which is supposed to cover Fortran 2008 and the two 
technical reports, TR 29113 (further interop with C) and the TR about 
enhanced coarray support.


I think it would be nice if TYPE(*) and DIMENSION(..) could also be 
implemented during the 4.7 development period as they are useful for C 
interoperability (void *buffer) - and in particular for MPI 3; 
additionally, they do not seem to be that difficult to implement. 
However, I do not plan to work on them in the near future.


Build and regtested on x86-64-linux
OK for the trunk?

The implementation status will be tracked at 
http://gcc.gnu.org/wiki/TR29113Status ;-)


Tobias

PS: I included in the patch also a patchlet for IMPORT, cf. Mikael's 
comment at http://gcc.gnu.org/ml/fortran/2011-05/msg5.html; with 
that patch, sym is always set to NULL when entering the loop for the 
next symbol. I think it is not really needed as gfc_current_ns-parent 
should be always != NULL, but maybe one manages have it NULL.
2011-05-04  Tobias Burnus  bur...@net-b.de

	PR fortran/48858
	PR fortran/48820
	* lang.opt (std=f2008tr): New.
	* libgfortran.h (GFC_STD_F2008_TR): New macro constant.
	* decl.c (verify_c_interop_param): Allow OPTIONAL in BIND(C)
	procedures for -std=f2008tr/gnu/legacy.
	(gfc_match_import): Set sym to NULL.
	* options.c (set_default_std_flags,gfc_handle_option): Handle
	-std=f2008tr.
	* invoke.texi (-std=): Document -std=f2008tr.

2011-05-04  Tobias Burnus  bur...@net-b.de

	PR fortran/48858
	PR fortran/48820
	* gfortran.dg/bind_c_usage_22.f90: New.
	* gfortran.dg/bind_c_usage_23.f90: New.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index dfbca29..8acd594 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1060,14 +1060,22 @@ verify_c_interop_param (gfc_symbol *sym)
 	  retval = FAILURE;
 	}
 
-	  if (sym-attr.optional == 1)
+	  if (sym-attr.optional == 1  sym-attr.value)
 	{
-	  gfc_error (Variable '%s' at %L cannot have the 
-			 OPTIONAL attribute because procedure '%s'
-			  is BIND(C), sym-name, (sym-declared_at),
+	  gfc_error (Variable '%s' at %L cannot have both the OPTIONAL 
+			 and the VALUE attribute because procedure '%s' 
+			 is BIND(C), sym-name, (sym-declared_at),
 			 sym-ns-proc_name-name);
 	  retval = FAILURE;
 	}
+	  else if (sym-attr.optional == 1
+		gfc_notify_std (GFC_STD_F2008_TR, TR29113: Variable '%s' 
+  at %L with OPTIONAL attribute in 
+  procedure '%s' which is BIND(C),
+  sym-name, (sym-declared_at),
+  sym-ns-proc_name-name)
+		  == FAILURE)
+	retval = FAILURE;
 
   /* Make sure that if it has the dimension attribute, that it is
 	 either assumed size or explicit shape.  */
@@ -2985,6 +2993,7 @@ gfc_match_import (void)
 
   for(;;)
 {
+  sym = NULL;
   m = gfc_match ( %n, name);
   switch (m)
 	{
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 015493e..ce944e3 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -590,6 +590,10 @@ std=f2008
 Fortran
 Conform to the ISO Fortran 2008 standard
 
+std=f2008tr
+Fortran
+Conform to the ISO Fortran 2008 standard including TR 29113
+
 std=f95
 Fortran
 Conform to the ISO Fortran 95 standard
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index 09524d0..035a32a 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
Note that no features were obsoleted nor deleted in F2003.
Please remember to keep those definitions in sync with
gfortran.texi.  */
+#define GFC_STD_F2008_TR	(19)	/* POST-F2008 technical reports.  */
 #define GFC_STD_F2008_OBS	(18)	/* Obsolescent in F2008.  */
 #define GFC_STD_F2008		(17)	/* New in F2008.  */
 #define GFC_STD_LEGACY		(16)	/* Backward compatibility.  */
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index f56fad7..ff66e0e 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -49,7 +49,7 @@ set_default_std_flags (void)
 {
   gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
-| GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY;
+| GFC_STD_F2008_OBS | GFC_STD_F2008_TR | GFC_STD_GNU | GFC_STD_LEGACY;
   gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
 }
 
@@ -942,6 +945,16 @@ gfc_handle_option (size_t scode, const char *arg, int value,
   gfc_option.warn_tabs = 0;
   break;
 
+case OPT_std_f2008tr:
+  gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
+	| GFC_STD_F2003 | 

<    1   2