[wwwdocs] PATCH for Re: Austriaon gcc mirror is offline

2017-04-22 Thread Gerald Pfeifer
On Sat, 22 Apr 2017, Branko wrote:
> On your https://gcc.gnu.org/mirrors.html page, first mirror listed is 
> Austrian ftp://gd.tuwien.ac.at/gnu/gcc.
> 
> I've noticed that it is offline for a few days. I tried firing email to 
> Antonin.Sprinzl at tuwien.ac.at as listed on a page, but it keeps being 
> dropped with the reply ( "Generic address unknown" ), so I'm contacting 
> you.

Thank you for letting us know, Branko.

I disabled the Austrian mirror in our listing per the patch below.
If/when you hear anything fron Antonin or otherwise, an update would
be great.

Gerald (whose alma mater tuwien.ac.at coincidentally is)

Index: mirrors.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/mirrors.html,v
retrieving revision 1.242
diff -u -r1.242 mirrors.html
--- mirrors.html14 Apr 2017 22:47:47 -  1.242
+++ mirrors.html22 Apr 2017 13:44:35 -
@@ -14,7 +14,9 @@
 (Phoenix, Arizona, USA) directly:
 
 
+
 Canada: http://gcc.parentingamerica.com";>http://gcc.parentingamerica.com, 
thanks to James Miller (jmiller at parentingamerica.com).
 Canada: http://gcc.skazkaforyou.com";>http://gcc.skazkaforyou.com, thanks to 
Sergey Ivanov (mirrors at skazkaforyou.com)
 Canada, Quebec:


[RFC, testsuite] Add dg-save-linenr

2017-04-22 Thread Tom de Vries

Hi,

there are currently two types of line number supported in
dg-{error,warning,message,bogus} directives: absolute and relative. 
With an absolute line number, it's immediately clear what line number is 
meant, but when a line is added at the start of the file, the line 
number needs to be updated.  With a relative line number, that problem 
is solved, but when relative line numbers become large, it becomes less 
clear what line it refers to, and when adding a line inbetween the 
directive using the relative line number and the line it refers to, the 
relative line number still needs to be updated.


This patch adds a directive dg-save-linenr with argument varname, that 
saves the line number of the directive in a variable varname, which can 
be used as line number in dg directives.


Testing status:
- tested updated test-case objc.dg/try-catch-12.m
- ran tree-ssa.exp

RFC:
- good idea?
- naming of directive dg-save-linenr (dg-linenr, dg-save-line-nr,
  dg-save-lineno, dg-save-line-number, etc)
- allowed variable names (currently: start with letter, followed by
  alphanumerical or underscore)
- should we use a prefix symbol or some such when the variable is used
  (and possibly defined as well)? F.i.:
  /* { dg-save-linenr %some_func_decl } *./
  /* { dg-message "but argument is of type" "" { target *-*-* }
   %some_func_decl } */
- error message formulation

Thanks,
- Tom
Add dg-save-linenr

2017-04-22  Tom de Vries  

	* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Cleanup line number
	variables.
	(dg-save-linenr): New proc.
	(process-message): Handle line number variables.
	* objc.dg/try-catch-12.m: Use dg-save-linenr.

---
 gcc/testsuite/lib/gcc-dg.exp | 50 
 gcc/testsuite/objc.dg/try-catch-12.m |  8 +++---
 2 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 83c38cf..555e083 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -902,6 +902,7 @@ if { [info procs saved-dg-test] == [list] } {
 	global keep_saved_temps_suffixes
 	global multiline_expected_outputs
 	global freeform_regexps
+	global save_linenr_varnames
 
 	set additional_files ""
 	set additional_sources ""
@@ -928,6 +929,13 @@ if { [info procs saved-dg-test] == [list] } {
 	}
 	set multiline_expected_outputs []
 	set freeform_regexps []
+
+	if { [info exists save_linenr_varnames] } {
+	foreach varname $save_linenr_varnames {
+		eval unset $varname
+	}
+	unset save_linenr_varnames
+	}
 }
 
 proc dg-test { args } {
@@ -979,6 +987,24 @@ if { [info procs saved-dg-error] == [list] \
 }
 }
 
+proc dg-save-linenr { linenr varname } {
+set org_varname $varname
+set varname "saved_linenr_$varname"
+eval global $varname
+eval set var_defined [info exists $varname]
+if { $var_defined } {
+	eval set deflinenr \$$varname
+	error "dg-save-linenr var $org_varname defined at line $linenr, but previously defined at line $deflinenr"
+	return
+}
+eval set $varname $linenr
+if { [info exists save_linenr_varnames] } {
+	lappend save_linenr_varnames $varname
+} else {
+	set save_linenr_varnames [list $varname]
+}
+}
+
 # Modify the regular expression saved by a DejaGnu message directive to
 # include a prefix and to force the expression to match a single line.
 # MSGPROC is the procedure to call.
@@ -988,11 +1014,25 @@ if { [info procs saved-dg-error] == [list] \
 proc process-message { msgproc msgprefix dgargs } {
 upvar dg-messages dg-messages
 
-# Handle relative line specification, .+1 or .-1 etc.
-if { [llength $dgargs] == 5
-	 && [regsub "^\.\[+-\](\[0-9\]+)$" [lindex $dgargs 4] "\\1" num] } {
-	set num [expr [lindex $dgargs 0] [string index [lindex $dgargs 4] 1] $num]
-	set dgargs [lreplace $dgargs 4 4 $num]
+if { [llength $dgargs] == 5 } {
+	if { [regsub "^\.\[+-\](\[0-9\]+)$" [lindex $dgargs 4] "\\1" num] } {
+	# Handle relative line specification, .+1 or .-1 etc.
+	set num [expr [lindex $dgargs 0] [string index [lindex $dgargs 4] 1] $num]
+	set dgargs [lreplace $dgargs 4 4 $num]
+	} elseif { [regsub "^(\[a-zA-Z\]\[a-zA-Z0-9_\]*)$" [lindex $dgargs 4] "\\1" varname] } {
+	# Handle linenr variable defined by dg-save-linenr
+	set org_varname $varname
+	set varname "saved_linenr_$varname"
+	eval global $varname
+	eval set var_defined [info exists $varname]
+	if { ! $var_defined } {
+		set linenr [expr [lindex $dgargs 0]]
+		error "dg-save-linenr var $org_varname used at line $linenr, but not defined"
+		return
+	}
+	eval set num \$$varname
+	set dgargs [lreplace $dgargs 4 4 $num]
+	}
 }
 
 # Process the dg- directive, including adding the regular expression
diff --git a/gcc/testsuite/objc.dg/try-catch-12.m b/gcc/testsuite/objc.dg/try-catch-12.m
index 61e2703..558ad02 100644
--- a/gcc/testsuite/objc.dg/try-catch-12.m
+++ b/gcc/testsuite/objc.dg/try-catch-12.m
@@ -9,7 +9

Re: [RFC, testsuite] Add dg-save-linenr

2017-04-22 Thread Mike Stump
On Apr 22, 2017, at 10:49 AM, Tom de Vries  wrote:
> 
> This patch adds a directive dg-save-linenr with argument varname, that saves 
> the line number of the directive in a variable varname, which can be used as 
> line number in dg directives.

> RFC:
> - good idea?

Seems reasonable to me.  I'd like to encourage, like it, hate it comments from 
others and see what others think.



[PATCH] PR c++/77306 - Unable to specify visibility for explicit template instantiations

2017-04-22 Thread James Abbatiello
This is my first time attempting a contribution here so please point
out any mistakes.  I've tested this on x86_64-pc-linux-gnu in a VM.

-- 
James Abbatiello


gcc/ChangeLog:

PR c++/77306
* attribs.c (decl_attributes): Allow visibility attributes on explicit
template instantiations.
* gcc-family/c-attribs.c (handle_visibility_attribute): Likewise.
---
 gcc/attribs.c   | 3 ++-
 gcc/c-family/c-attribs.c| 6 --
 gcc/testsuite/g++.dg/ext/visibility/warn4.C | 5 +++--
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 55b21271b39..ed1cfa1765b 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -534,7 +534,8 @@ decl_attributes (tree *node, tree attributes, int flags)
 
   if (TYPE_P (*anode)
  && (flags & (int) ATTR_FLAG_TYPE_IN_PLACE)
- && TYPE_SIZE (*anode) != NULL_TREE)
+ && TYPE_SIZE (*anode) != NULL_TREE
+ && !is_attribute_p ("visibility", name))
{
  warning (OPT_Wattributes, "type attributes ignored after type is 
already defined");
  continue;
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index f2a88e147ba..e3fb82aef21 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -1895,12 +1895,6 @@ handle_visibility_attribute (tree *node, tree name, tree 
args,
   name);
  return NULL_TREE;
}
-  else if (TYPE_FIELDS (*node))
-   {
- error ("%qE attribute ignored because %qT is already defined",
-name, *node);
- return NULL_TREE;
-   }
 }
   else if (decl_function_context (decl) != 0 || !TREE_PUBLIC (decl))
 {
diff --git a/gcc/testsuite/g++.dg/ext/visibility/warn4.C 
b/gcc/testsuite/g++.dg/ext/visibility/warn4.C
index 33e6f678592..a55f9682a12 100644
--- a/gcc/testsuite/g++.dg/ext/visibility/warn4.C
+++ b/gcc/testsuite/g++.dg/ext/visibility/warn4.C
@@ -1,10 +1,11 @@
-// Warn if we try to give an instantiation visibility after it's already
+// Don't warn if we give an instantiation visibility after it's already
 // been instantiated.
 
 // { dg-require-visibility "" }
+// { dg-final { scan-hidden "_ZN1AIdE1fEd" } }
 
 template  struct A { void f (T); };
 template  void A::f (T) { }
 
 A ad;
-template struct __attribute ((visibility ("hidden"))) A; // { 
dg-warning "already defined" }
+template struct __attribute ((visibility ("hidden"))) A;
-- 
2.11.0



[Patch, Fortran] PR 80121: Memory leak with derived-type intent(out) argument

2017-04-22 Thread Janus Weil
Hi all,

the patch in the attachment fixes a memory leak by auto-deallocating
the allocatable components of an allocatable intent(out) argument.

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2017-04-22  Janus Weil  

PR fortran/80121
* trans-types.c (gfc_conv_procedure_call): Deallocate the components
of allocatable intent(out) arguments.

2017-04-22  Janus Weil  

PR fortran/80121
* gfortran.dg/intent_out_9.f90: New test case.
Index: gcc/fortran/trans-expr.c
===
--- gcc/fortran/trans-expr.c(revision 247077)
+++ gcc/fortran/trans-expr.c(working copy)
@@ -5454,6 +5454,16 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
  if (fsym && fsym->attr.allocatable
  && fsym->attr.intent == INTENT_OUT)
{
+ if (fsym->ts.type == BT_DERIVED
+ && fsym->ts.u.derived->attr.alloc_comp)
+ {
+   // deallocate the components first
+   tmp = gfc_deallocate_alloc_comp (fsym->ts.u.derived,
+parmse.expr, e->rank);
+   if (tmp != NULL_TREE)
+ gfc_add_expr_to_block (&se->pre, tmp);
+ }
+
  tmp = build_fold_indirect_ref_loc (input_location,
 parmse.expr);
  if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp)))
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
!
! PR 80121: Memory leak with derived-type intent(out) argument
!
! Contributed by Andrew Wood 

PROGRAM p
IMPLICIT NONE
TYPE t1
  INTEGER, ALLOCATABLE :: i(:)
END TYPE
call leak
  CONTAINS
SUBROUTINE s1(e)
  TYPE(t1), ALLOCATABLE, INTENT(OUT) :: e(:)
  ALLOCATE( e(1) )
  ALLOCATE( e(1)%i(2) )
END SUBROUTINE
SUBROUTINE leak
  TYPE(t1), ALLOCATABLE :: e(:)
  CALL s1(e)
  CALL s1(e)
END SUBROUTINE
END PROGRAM

! { dg-final { scan-tree-dump-times "__builtin_free" 6 "original" } }
! { dg-final { cleanup-tree-dump "original" } }


Re: [Patch, Fortran] PR 80121: Memory leak with derived-type intent(out) argument

2017-04-22 Thread Thomas Koenig

Hi Janus,


the patch in the attachment fixes a memory leak by auto-deallocating
the allocatable components of an allocatable intent(out) argument.

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?


OK for trunk.  Also (because this is a quite serious bug)
OK for gcc 7 after the release of 7.1.

Thanks for the patch!

Regards

Thomas


[patch, libgfortran] PR80484 Three syntax errors involving derived-type I/O

2017-04-22 Thread Jerry DeLisle

Hi all,

The attached patch fixes these issues.

Regression tested on x86_64-pc-linux-gnu. New test attached.

OK for Trunk (8)?  I think we should backport to 7 when it re-opens. The failing 
repeat count on DT format is very not good.


Regards,

Jerry

2017-04-22  Jerry DeLisle  

PR fortran/80484
* io.c (format_lex): Check for '/' and set token to FMT_SLASH.
(check_format): Move FMT_DT checking code to data_desc section.
* module.c (gfc_match_use): Include the case of INTERFACE_DTIO.
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 60df44dc..7ab897da 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -491,6 +491,11 @@ format_lex (void)
 			  token = FMT_END;
 			  break;
 			}
+		  if (c == '/')
+			{
+			  token = FMT_SLASH;
+			  break;
+			}
 		  if (c == delim)
 			continue;
 		  unget_char ();
@@ -498,6 +503,11 @@ format_lex (void)
 		}
 		}
 	}
+	  else if (c == '/')
+	{
+	  token = FMT_SLASH;
+	  break;
+	}
 	  else
 	unget_char ();
 	}
@@ -687,54 +697,6 @@ format_item_1:
 	return false;
   goto between_desc;
 
-case FMT_DT:
-  t = format_lex ();
-  if (t == FMT_ERROR)
-	goto fail;
-  switch (t)
-	{
-	case FMT_RPAREN:
-	  level--;
-	  if (level < 0)
-	goto finished;
-	  goto between_desc;
-
-	case FMT_COMMA:
-	  goto format_item;
-
-	case FMT_LPAREN:
-
-  dtio_vlist:
-	  t = format_lex ();
-	  if (t == FMT_ERROR)
-	goto fail;
-
-	  if (t != FMT_POSINT)
-	{
-	  error = posint_required;
-	  goto syntax;
-	}
-
-	  t = format_lex ();
-	  if (t == FMT_ERROR)
-	goto fail;
-
-	  if (t == FMT_COMMA)
-	goto dtio_vlist;
-	  if (t != FMT_RPAREN)
-	{
-	  error = _("Right parenthesis expected at %C");
-	  goto syntax;
-	}
-	  goto between_desc;
-
-	default:
-	  error = unexpected_element;
-	  goto syntax;
-	}
-
-  goto format_item;
-
 case FMT_SIGN:
 case FMT_BLANK:
 case FMT_DP:
@@ -783,6 +745,7 @@ format_item_1:
 case FMT_A:
 case FMT_D:
 case FMT_H:
+case FMT_DT:
   goto data_desc;
 
 case FMT_END:
@@ -1004,6 +967,53 @@ data_desc:
 
   break;
 
+case FMT_DT:
+  t = format_lex ();
+  if (t == FMT_ERROR)
+	goto fail;
+  switch (t)
+	{
+	case FMT_RPAREN:
+	  level--;
+	  if (level < 0)
+	goto finished;
+	  goto between_desc;
+
+	case FMT_COMMA:
+	  goto format_item;
+
+	case FMT_LPAREN:
+
+  dtio_vlist:
+	  t = format_lex ();
+	  if (t == FMT_ERROR)
+	goto fail;
+
+	  if (t != FMT_POSINT)
+	{
+	  error = posint_required;
+	  goto syntax;
+	}
+
+	  t = format_lex ();
+	  if (t == FMT_ERROR)
+	goto fail;
+
+	  if (t == FMT_COMMA)
+	goto dtio_vlist;
+	  if (t != FMT_RPAREN)
+	{
+	  error = _("Right parenthesis expected at %C");
+	  goto syntax;
+	}
+	  goto between_desc;
+
+	default:
+	  error = unexpected_element;
+	  goto syntax;
+	}
+  break;
+
 case FMT_F:
   t = format_lex ();
   if (t == FMT_ERROR)
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 4d6afa55..e8cba145 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -631,6 +631,7 @@ gfc_match_use (void)
 
 	case INTERFACE_USER_OP:
 	case INTERFACE_GENERIC:
+	case INTERFACE_DTIO:
 	  m = gfc_match (" =>");
 
 	  if (type == INTERFACE_USER_OP && m == MATCH_YES
! { dg-do compile }
! PR80484 Three syntax errors involving derived-type I/O
module dt_write_mod
   type, public :: B_type
  real :: amount
   end type B_type
   interface write (formatted)
  procedure :: Write_b
   end interface
contains

subroutine Write_b &
   (amount, unit, b_edit_descriptor, v_list, iostat, iomsg)

   class (B_type), intent(in) :: amount
   integer, intent(in) :: unit
   character (len=*), intent(in) :: b_edit_descriptor
   integer, dimension(:), intent(in) :: v_list
   integer, intent(out) :: iostat
   character (len=*), intent(inout) :: iomsg
   write (unit=unit, fmt="(f9.3)", iostat=iostat) amount%amount

end subroutine Write_b

end module dt_write_mod

program test
   use dt_write_mod, only: B_type  , write(formatted)
   implicit none

   real :: wage = 15.10
   integer :: ios
   character(len=99) :: iom = "OK"

   write (unit=*, fmt="(DT'$$$Z.##')", iostat=ios, iomsg=iom) &
 B_type(wage), B_type(wage)
   print *, trim(iom)
   write (unit=*, fmt="(2DT'$$$Z.##')", iostat=ios, iomsg=iom) &
 B_type(wage), B_type(wage)
   print *, trim(iom)
   write (unit=*, fmt="(3DT'$$$Z.##')", iostat=ios, iomsg=iom) &
 B_type(wage), B_type(wage)
   print *, trim(iom)
   write (unit=*, fmt="(DT'$$$Z.##'/)", iostat=ios, iomsg=iom) &
 B_type(wage), B_type(wage)
   print *, trim(iom)
end program test