[gcc-7] 347/354: * Update to SVN 20171115 (r254781) from the gcc-7-branch.

Ximin Luo infinity0 at debian.org
Thu Nov 23 15:51:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository gcc-7.

commit aa04fc2309cddff957a90f0ba19a63ac994ae7a8
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date:   Wed Nov 15 19:14:15 2017 +0000

      * Update to SVN 20171115 (r254781) from the gcc-7-branch.
    
    
    git-svn-id: svn+ssh://svn.debian.org/svn/gcccvs/branches/sid/gcc-7@9831 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
 debian/changelog                |    6 +-
 debian/patches/svn-updates.diff | 3725 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 3708 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 87af8fa..0ff885d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,9 @@
 gcc-7 (7.2.0-15) UNRELEASED; urgency=medium
 
+  * Update to SVN 20171115 (r254781) from the gcc-7-branch.
+    - Fix PR fortran/82934, PR fortran/78619, PR fortran/82869,
+      PR tree-optimization/82985, PR tree-optimization/81790,
+      PR debug/82155.
   * Fix libgo build on ia64 (Jason Duerstock). Closes: #881372.
   * Port libgo to the Hurd (Svante Signell).
   * Compress debug symbols for compiler binaries with dwz.
@@ -9,7 +13,7 @@ gcc-7 (7.2.0-15) UNRELEASED; urgency=medium
     Closes: #881729.
   * gcc-7-base: Add breaks to gnat (<< 7). Closes: #881775.
 
- -- Matthias Klose <doko at debian.org>  Mon, 13 Nov 2017 22:47:12 +0100
+ -- Matthias Klose <doko at debian.org>  Wed, 15 Nov 2017 20:02:41 +0100
 
 gcc-7 (7.2.0-14) unstable; urgency=medium
 
diff --git a/debian/patches/svn-updates.diff b/debian/patches/svn-updates.diff
index c211641..a60e0f4 100644
--- a/debian/patches/svn-updates.diff
+++ b/debian/patches/svn-updates.diff
@@ -1,10 +1,10 @@
-# DP: updates from the 7 branch upto 20171109 (r254567).
+# DP: updates from the 7 branch upto 20171115 (r254781).
 
 last_update()
 {
 	cat > ${dir}LAST_UPDATED <EOF
-Thu Nov  9 11:55:34 CET 2017
-Thu Nov  9 10:55:34 UTC 2017 (revision 254567)
+Wed Nov 15 19:55:19 CET 2017
+Wed Nov 15 18:55:19 UTC 2017 (revision 254781)
 EOF
 }
 
@@ -10246,7 +10246,7 @@ Index: gcc/DATESTAMP
 +++ b/src/gcc/DATESTAMP	(.../branches/gcc-7-branch)
 @@ -1 +1 @@
 -20170814
-+20171109
++20171115
 Index: gcc/tree.c
 ===================================================================
 --- a/src/gcc/tree.c	(.../tags/gcc_7_2_0_release)
@@ -10391,6 +10391,49 @@ Index: gcc/tree.h
  
  /* Return a tree representing the offset, in bytes, of the field referenced
     by EXP.  This does not include any offset in DECL_FIELD_BIT_OFFSET.  */
+Index: gcc/configure
+===================================================================
+--- a/src/gcc/configure	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/configure	(.../branches/gcc-7-branch)
+@@ -25449,6 +25449,38 @@
+ 	;;
+     esac
+ 
++    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -xbrace_comment" >&5
++$as_echo_n "checking assembler for -xbrace_comment... " >&6; }
++if test "${gcc_cv_as_ix86_xbrace_comment+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  gcc_cv_as_ix86_xbrace_comment=no
++  if test x$gcc_cv_as != x; then
++    $as_echo '.text' > conftest.s
++    if { ac_try='$gcc_cv_as $gcc_cv_as_flags -xbrace_comment=no -o conftest.o conftest.s >&5'
++  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; }; }
++    then
++	gcc_cv_as_ix86_xbrace_comment=yes
++    else
++      echo "configure: failed program was" >&5
++      cat conftest.s >&5
++    fi
++    rm -f conftest.o conftest.s
++  fi
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ix86_xbrace_comment" >&5
++$as_echo "$gcc_cv_as_ix86_xbrace_comment" >&6; }
++if test $gcc_cv_as_ix86_xbrace_comment = yes; then
++
++$as_echo "#define HAVE_AS_XBRACE_COMMENT_OPTION 1" >>confdefs.h
++
++fi
++
++
+     # Test if the assembler supports the section flag 'e' for specifying
+     # an excluded section.
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .section with e" >&5
 Index: gcc/internal-fn.c
 ===================================================================
 --- a/src/gcc/internal-fn.c	(.../tags/gcc_7_2_0_release)
@@ -10767,7 +10810,36 @@ Index: gcc/tree-ssa-sccvn.c
 ===================================================================
 --- a/src/gcc/tree-ssa-sccvn.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/tree-ssa-sccvn.c	(.../branches/gcc-7-branch)
-@@ -2304,7 +2304,7 @@
+@@ -1643,13 +1643,25 @@
+ /* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables.  */
+ 
+ static tree
+-vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops)
++vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops_)
+ {
+   if (!rcode.is_tree_code ())
+     return NULL_TREE;
++  tree *ops = ops_;
++  unsigned int length = TREE_CODE_LENGTH ((tree_code) rcode);
++  if (rcode == CONSTRUCTOR
++      /* ???  We're arriving here with SCCVNs view, decomposed CONSTRUCTOR
++	 and GIMPLEs / match-and-simplifies, CONSTRUCTOR as GENERIC tree.  */
++      && TREE_CODE (ops_[0]) == CONSTRUCTOR)
++    {
++      length = CONSTRUCTOR_NELTS (ops_[0]);
++      ops = XALLOCAVEC (tree, length);
++      for (unsigned i = 0; i < length; ++i)
++	ops[i] = CONSTRUCTOR_ELT (ops_[0], i)->value;
++    }
+   vn_nary_op_t vnresult = NULL;
+-  return vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
+-				   (tree_code) rcode, type, ops, &vnresult);
++  return vn_nary_op_lookup_pieces (length, (tree_code) rcode,
++				   type, ops, &vnresult);
+ }
+ 
+ /* Return a value-number for RCODE OPS... either by looking up an existing
+@@ -2304,7 +2316,7 @@
        memset (&op, 0, sizeof (op));
        op.type = vr->type;
        op.opcode = MEM_REF;
@@ -10776,7 +10848,7 @@ Index: gcc/tree-ssa-sccvn.c
        op.off = at - lhs_offset + rhs_offset;
        vr->operands[0] = op;
        op.type = TREE_TYPE (rhs);
-@@ -2990,16 +2990,13 @@
+@@ -2990,16 +3002,13 @@
  	      return false;
  
  	    /* Verify the controlling stmt is the same.  */
@@ -10798,7 +10870,7 @@ Index: gcc/tree-ssa-sccvn.c
  				      &inverted_p))
  	      return false;
  
-@@ -3084,7 +3081,7 @@
+@@ -3084,7 +3093,7 @@
    vp1.ccrhs = NULL_TREE;
    basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1.block);
    if (EDGE_COUNT (idom1->succs) == 2)
@@ -10807,7 +10879,7 @@ Index: gcc/tree-ssa-sccvn.c
        {
  	vp1.cclhs = vn_valueize (gimple_cond_lhs (last1));
  	vp1.ccrhs = vn_valueize (gimple_cond_rhs (last1));
-@@ -3130,7 +3127,7 @@
+@@ -3130,7 +3139,7 @@
    vp1->ccrhs = NULL_TREE;
    basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block);
    if (EDGE_COUNT (idom1->succs) == 2)
@@ -10820,7 +10892,39 @@ Index: gcc/ChangeLog
 ===================================================================
 --- a/src/gcc/ChangeLog	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/ChangeLog	(.../branches/gcc-7-branch)
-@@ -1,3 +1,775 @@
+@@ -1,3 +1,807 @@
++2017-11-15  Richard Biener  <rguenther at suse.de>
++
++	PR tree-optimization/82985
++	Backport from mainline
++	2017-08-15  Richard Biener  <rguenther at suse.de>
++
++	PR tree-optimization/81790
++	* tree-ssa-sccvn.c (vn_lookup_simplify_result): Handle both
++	CONSTRUCTORs from simplifying and VN.
++
++2017-11-15  Pierre-Marie de Rodat  <derodat at adacore.com>
++
++	Backport from mainline
++	2017-09-25  Pierre-Marie de Rodat  <derodat at adacore.com>
++
++	PR debug/82155
++	* dwarf2out.c (dwarf2out_early_global_decl): Call dwarf2out_decl
++	on the FUNCTION_DECL function context if it has a DIE that is a
++	declaration.
++
++2017-11-13  Rainer Orth  <ro at CeBiTec.Uni-Bielefeld.DE>
++
++	Backport from mainline
++	2017-10-26  Rainer Orth  <ro at CeBiTec.Uni-Bielefeld.DE>
++
++	* configure.ac (gcc_cv_as_ix86_xbrace_comment): Check if assembler
++	supports -xbrace_comment option.
++	* configure: Regenerate.
++	* config.in: Regenerate.
++	* config/i386/sol2.h (ASM_XBRACE_COMMENT_SPEC): Define.
++	(ASM_CPU_SPEC): Use it.
++
 +2017-11-09  Segher Boessenkool  <segher at kernel.crashing.org>
 +
 +	Backport from mainline
@@ -11596,7 +11700,7 @@ Index: gcc/ChangeLog
  2017-08-14  Release Manager
  
  	* GCC 7.2.0 released.
-@@ -5411,11 +6187,6 @@
+@@ -5411,11 +6219,6 @@
  	* doc/invoke.texi: Replace inequality signs with square brackets
  	for -Wnormalized.
  
@@ -11608,7 +11712,7 @@ Index: gcc/ChangeLog
  2017-02-22  Matthew Fortune  <matthew.fortune at imgtec.com>
  
  	PR target/78660
-@@ -6987,8 +7758,6 @@
+@@ -6987,8 +7790,6 @@
  	* tree-vrp.c (process_assert_insertions): Properly adjust common
  	when removing a duplicate.
  
@@ -12949,6 +13053,50 @@ Index: gcc/testsuite/gfortran.dg/equiv_pure.f90
 +     d = h
 +   end function
 +end module r
+Index: gcc/testsuite/gfortran.dg/logical_temp_io.f90
+===================================================================
+--- a/src/gcc/testsuite/gfortran.dg/logical_temp_io.f90	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gfortran.dg/logical_temp_io.f90	(.../branches/gcc-7-branch)
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! PR 82869
++! A temp variable of type logical was incorrectly transferred
++! to the I/O library as a logical type of a different kind.
++program pr82869
++  use, intrinsic :: iso_c_binding
++  type(c_ptr) :: p = c_null_ptr
++  character(len=4) :: s
++  write (s, *) c_associated(p), c_associated(c_null_ptr)
++  if (s /= ' F F') then
++     call abort()
++  end if
++end program pr82869
+Index: gcc/testsuite/gfortran.dg/pr78619.f90
+===================================================================
+--- a/src/gcc/testsuite/gfortran.dg/pr78619.f90	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gfortran.dg/pr78619.f90	(.../branches/gcc-7-branch)
+@@ -0,0 +1,21 @@
++! { dg-do compile }
++! { dg-options "-Werror -O3" }
++!
++! Tests the fix for PR78619, in which the recursive use of 'f' at line 13
++! caused an ICE.
++!
++! Contributed by Gerhard Steinmetz  <gerhard.steinmetz.fortran at t-online.de>
++!
++  print *, g(1.0) ! 'g' is OK
++contains
++  function f(x) result(z)
++    real :: x, z
++    z = sign(1.0, f) ! { dg-error "calling itself recursively|must be the same type" }
++  end
++  real function g(x)
++    real :: x
++    g = -1
++    g = -sign(1.0, g) ! This is OK.
++  end
++end
++! { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 }
 Index: gcc/testsuite/gfortran.dg/dtio_12.f90
 ===================================================================
 --- a/src/gcc/testsuite/gfortran.dg/dtio_12.f90	(.../tags/gcc_7_2_0_release)
@@ -13114,6 +13262,39 @@ Index: gcc/testsuite/gfortran.dg/typebound_proc_27.f03
 +! { dg-final { scan-tree-dump-times "__builtin_free" 10 "original" } }
  !
  
+Index: gcc/testsuite/gfortran.dg/allocate_assumed_charlen_1.f90
+===================================================================
+--- a/src/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_1.f90	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_1.f90	(.../branches/gcc-7-branch)
+@@ -0,0 +1,28 @@
++! { dg-do run }
++!
++! PR82934: Segfault on compilation in trans-stmt.c:5919(8.0.0).
++! The original report only had one item in the allocate list. This
++! has been doubled up to verify that the correct string length is
++! is used in the allocation.
++!
++! Contributed by FortranFan on clf.
++!
++   character(len=42), allocatable :: foo
++   character(len=22), allocatable :: foofoo
++
++   call alloc( foo , foofoo)
++
++   if (len(foo) .ne. 42) call abort
++   if (len(foofoo) .ne. 22) call abort
++
++contains
++
++   subroutine alloc( bar, barbar )
++
++      character(len=*), allocatable :: bar, barbar
++
++      allocate( character(len=*) :: bar , barbar) ! <= Here!
++
++   end subroutine
++
++end
 Index: gcc/testsuite/gfortran.dg/assumed_size_2.f90
 ===================================================================
 --- a/src/gcc/testsuite/gfortran.dg/assumed_size_2.f90	(.../tags/gcc_7_2_0_release)
@@ -13346,6 +13527,25 @@ Index: gcc/testsuite/gfortran.dg/submodule_29.f08
 +  if (i .ne. 42) call abort
 +  if (j .ne. 1037) call abort
 +end program
+Index: gcc/testsuite/gfortran.dg/logical_temp_io_kind8.f90
+===================================================================
+--- a/src/gcc/testsuite/gfortran.dg/logical_temp_io_kind8.f90	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gfortran.dg/logical_temp_io_kind8.f90	(.../branches/gcc-7-branch)
+@@ -0,0 +1,14 @@
++! { dg-do run }
++! { dg-options "-fdefault-integer-8" }
++! PR 82869
++! A temp variable of type logical was incorrectly transferred
++! to the I/O library as a logical type of a different kind.
++program pr82869_8
++  use, intrinsic :: iso_c_binding
++  type(c_ptr) :: p = c_null_ptr
++  character(len=4) :: s
++  write (s, *) c_associated(p), c_associated(c_null_ptr)
++  if (s /= ' F F') then
++     call abort()
++  end if
++end program pr82869_8
 Index: gcc/testsuite/gfortran.dg/associate_9.f03
 ===================================================================
 --- a/src/gcc/testsuite/gfortran.dg/associate_9.f03	(.../tags/gcc_7_2_0_release)
@@ -14423,6 +14623,39 @@ Index: gcc/testsuite/gnat.dg/incomplete5.ads
 +   end record;
 +
 +end Incomplete5;
+Index: gcc/testsuite/gnat.dg/opt69.adb
+===================================================================
+--- a/src/gcc/testsuite/gnat.dg/opt69.adb	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gnat.dg/opt69.adb	(.../branches/gcc-7-branch)
+@@ -0,0 +1,28 @@
++-- { dg-do compile }
++-- { dg-options "-O" }
++
++with Ada.Text_IO;
++
++procedure Opt69 is
++
++   procedure Inner
++     (A : String := (1 .. 15 => ASCII.NUL);
++      B : String := (1 .. 5 => ASCII.NUL);
++      C : String := (1 .. 5 => ASCII.NUL))
++   is
++      Aa : String (1 .. 15);
++      Bb : String (1 .. 5);
++      Cc : String (1 .. 5);
++   begin
++      Aa := A;
++      Bb := B;
++      Cc := C;
++
++      Ada.Text_IO.Put_Line (Aa);
++      Ada.Text_IO.Put_Line (Bb);
++      Ada.Text_IO.Put_Line (Cc);
++   end;
++
++begin
++   Inner;
++end;
 Index: gcc/testsuite/gnat.dg/pack9.adb
 ===================================================================
 --- a/src/gcc/testsuite/gnat.dg/pack9.adb	(.../tags/gcc_7_2_0_release)
@@ -14861,6 +15094,39 @@ Index: gcc/testsuite/gcc.dg/torture/pr82285.c
 +    __builtin_abort ();
 +  return 0;
 +}
+Index: gcc/testsuite/gcc.dg/torture/pr81790.c
+===================================================================
+--- a/src/gcc/testsuite/gcc.dg/torture/pr81790.c	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/gcc.dg/torture/pr81790.c	(.../branches/gcc-7-branch)
+@@ -0,0 +1,28 @@
++/* { dg-do compile } */
++/* { dg-additional-options "--param sccvn-max-scc-size=10" } */
++
++typedef int a __attribute__ ((__vector_size__ (16)));
++typedef struct
++{
++  a b;
++} c;
++
++int d, e;
++
++void foo (c *ptr);
++
++void bar ()
++{
++  double b = 1842.9028;
++  c g, h;
++  if (d)
++    b = 77.7998;
++  for (; e;)
++    {
++      g.b = g.b = g.b + g.b;
++      h.b = (a){b};
++      h.b = h.b + h.b;
++    }
++  foo (&g);
++  foo (&h);
++}
 Index: gcc/testsuite/gcc.dg/torture/pr81181.c
 ===================================================================
 --- a/src/gcc/testsuite/gcc.dg/torture/pr81181.c	(.../tags/gcc_7_2_0_release)
@@ -15352,7 +15618,46 @@ Index: gcc/testsuite/ChangeLog
 ===================================================================
 --- a/src/gcc/testsuite/ChangeLog	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/testsuite/ChangeLog	(.../branches/gcc-7-branch)
-@@ -1,3 +1,656 @@
+@@ -1,3 +1,695 @@
++2017-11-15  Richard Biener  <rguenther at suse.de>
++
++	PR tree-optimization/82985
++	Backport from mainline
++	2017-08-15  Richard Biener  <rguenther at suse.de>
++
++	PR tree-optimization/81790
++	* gcc.dg/torture/pr81790.c: New testcase.
++	* g++.dg/torture/pr82985.C: Likewise.
++
++2017-11-15  Pierre-Marie de Rodat  <derodat at adacore.com>
++
++	Backport from mainline
++	2017-09-25  Pierre-Marie de Rodat  <derodat at adacore.com>
++
++	* g++.dg/pr82155.C: New testcase.
++
++2017-11-13  Paul Thomas  <pault at gcc.gnu.org>
++
++	Backport from trunk
++	PR fortran/82934
++	* gfortran.dg/allocate_assumed_charlen_1.f90: New test.
++
++2017-11-13  Paul Thomas  <pault at gcc.gnu.org>
++
++	Backport from trunk
++	PR fortran/78619
++	* gfortran.dg/pr78619.f90: New test.
++
++2017-11-13  Janne Blomqvist  <jb at gcc.gnu.org>
++
++	PR 82869
++	* gfortran.dg/logical_temp_io.f90: New test.
++	* gfortran.dg/logical_temp_io_kind8.f90: New test.
++
++2017-11-10  Eric Botcazou  <ebotcazou at adacore.com>
++
++	* gnat.dg/opt69.adb: New test.
++
 +2017-11-06  Paul Thomas  <pault at gcc.gnu.org>
 +
 +	Backported from trunk
@@ -16009,7 +16314,7 @@ Index: gcc/testsuite/ChangeLog
  2017-08-14  Release Manager
  
  	* GCC 7.2.0 released.
-@@ -150,7 +803,7 @@
+@@ -150,7 +842,7 @@
  	* gfortran.dg/pr81175.f: New testcase.
  
  	2017-06-21  Marc Glisse  <marc.glisse at inria.fr>
@@ -16018,7 +16323,7 @@ Index: gcc/testsuite/ChangeLog
   	* gcc.dg/tree-ssa/addadd.c: Un-XFAIL.
   	* gcc.dg/tree-ssa/addadd-2.c: New file.
  
-@@ -358,7 +1011,7 @@
+@@ -358,7 +1050,7 @@
  	* c-c++-common/ubsan/sanitize-recover-7.c (dg-options): Add -w.
  
  2017-06-24  Marek Polacek  <polacek at redhat.com>
@@ -16027,7 +16332,7 @@ Index: gcc/testsuite/ChangeLog
  	Backport from mainline
  	2017-05-04  Marek Polacek  <polacek at redhat.com>
  
-@@ -2273,7 +2926,7 @@
+@@ -2273,7 +2965,7 @@
  
  	PR fortran/80156
  	PR fortran/79382
@@ -16036,7 +16341,7 @@ Index: gcc/testsuite/ChangeLog
  	testcase for PR80156. Add a main programme that tests that
  	the typebound generic is accessible.
  
-@@ -2609,13 +3262,13 @@
+@@ -2609,13 +3301,13 @@
  2017-03-18  Paul Thomas  <pault at gcc.gnu.org>
  
  	PR fortran/79676
@@ -16053,7 +16358,7 @@ Index: gcc/testsuite/ChangeLog
  
  2017-03-17  Pat Haugen  <pthaugen at us.ibm.com>
  
-@@ -3474,6 +4127,11 @@
+@@ -3474,6 +4166,11 @@
  	PR lto/79587
  	* gcc.dg/tree-prof/pr79587.c: New test.
  
@@ -16569,6 +16874,469 @@ Index: gcc/testsuite/g++.dg/torture/pr81987.C
 +    }
 +  }
 +}
+Index: gcc/testsuite/g++.dg/torture/pr82985.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/torture/pr82985.C	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/g++.dg/torture/pr82985.C	(.../branches/gcc-7-branch)
+@@ -0,0 +1,458 @@
++/* { dg-do compile } */
++/* { dg-additional-options "-w" } */
++/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */
++
++namespace std {
++template < typename _Default > struct __detector { using type = _Default; };
++template < typename _Default, template < typename > class >
++using __detected_or = __detector< _Default >;
++template < typename _Default, template < typename > class _Op >
++using __detected_or_t = typename __detected_or< _Default, _Op >::type;
++template < typename > struct iterator_traits;
++template < typename _Tp > struct iterator_traits< _Tp * > {
++  typedef _Tp reference;
++};
++} // std
++using std::iterator_traits;
++template < typename _Iterator, typename > struct __normal_iterator {
++  typename iterator_traits< _Iterator >::reference operator*();
++  void operator++();
++};
++template < typename _IteratorL, typename _IteratorR, typename _Container >
++int operator!=(__normal_iterator< _IteratorL, _Container >,
++               __normal_iterator< _IteratorR, _Container >);
++namespace std {
++template < typename _Tp > struct allocator { typedef _Tp value_type; };
++struct __allocator_traits_base {
++  template < typename _Tp > using __pointer = typename _Tp::pointer;
++};
++template < typename _Alloc > struct allocator_traits : __allocator_traits_base {
++  using pointer = __detected_or_t< typename _Alloc::value_type *, __pointer >;
++};
++} // std
++typedef double __m128d __attribute__((__vector_size__(16)));
++typedef double __m256d __attribute__((__vector_size__(32)));
++enum { InnerVectorizedTraversal, LinearVectorizedTraversal };
++enum { ReadOnlyAccessors };
++template < int, typename Then, typename > struct conditional {
++  typedef Then type;
++};
++template < typename Then, typename Else > struct conditional< 0, Then, Else > {
++  typedef Else type;
++};
++template < typename, typename > struct is_same {
++  enum { value };
++};
++template < typename T > struct is_same< T, T > {
++  enum { value = 1 };
++};
++template < typename > struct traits;
++struct accessors_level {
++  enum { has_direct_access, has_write_access, value };
++};
++template < typename > struct EigenBase;
++template < typename > struct PlainObjectBase;
++template < typename, int = accessors_level::value > struct DenseCoeffsBase;
++template < typename, int, int, int = 0, int = 0, int = 0 > struct Matrix;
++template < typename > struct MatrixBase;
++template < typename, int, int, bool = 0 > struct Block;
++struct VectorBlock;
++template < typename, typename > struct CwiseNullaryOp;
++template < typename, typename, typename > struct CwiseBinaryOp;
++template < typename, int = accessors_level::has_write_access > struct MapBase;
++template < typename > struct packet_traits;
++template < typename > struct unpacket_traits;
++template < int Size, typename PacketType,
++           int = Size == is_same< PacketType, typename unpacket_traits<
++                                                  PacketType >::half >::value >
++struct find_best_packet_helper;
++template < int Size, typename PacketType >
++struct find_best_packet_helper< Size, PacketType, 1 > {
++  typedef PacketType type;
++};
++template < int Size, typename PacketType >
++struct find_best_packet_helper< Size, PacketType, 0 > {
++  typedef typename find_best_packet_helper<
++      1, typename unpacket_traits< PacketType >::half >::type type;
++};
++template < typename T, int Size > struct find_best_packet {
++  typedef typename find_best_packet_helper<
++      Size, typename packet_traits< T >::type >::type type;
++};
++struct compute_matrix_flags {
++  enum { ret = 1 };
++};
++struct ref_selector {
++  typedef Matrix< double, 10, 1 > &type;
++};
++template < typename Derived > struct dense_xpr_base {
++  typedef MatrixBase< Derived > type;
++};
++template < typename ExpressionType > struct is_lvalue {
++  enum { value = traits< ExpressionType >::Flags };
++};
++template < typename Packet > void pmul(Packet);
++template < typename Packet >
++Packet pload(const typename unpacket_traits< Packet >::type *);
++template < typename Packet >
++Packet pset1(const typename unpacket_traits< Packet >::type &);
++template < typename Scalar, typename Packet > void pstoreu(Scalar, Packet &);
++template < typename Packet, int >
++Packet ploadt(const typename unpacket_traits< Packet >::type *from) {
++  return pload< Packet >(from);
++}
++template < typename Scalar, typename Packet, int >
++void pstoret(Scalar *to, const Packet from) {
++  pstoreu(to, from);
++}
++typedef __m128d Packet2d;
++template <> struct unpacket_traits< Packet2d > {
++  typedef double type;
++  typedef Packet2d half;
++};
++template <> Packet2d pload(const double *from) { return *(__m128d *)from; }
++typedef __m256d Packet4d;
++template <> struct packet_traits< double > { typedef Packet4d type; };
++template <> struct unpacket_traits< Packet4d > {
++  typedef double type;
++  typedef Packet2d half;
++};
++__m256d pset1___trans_tmp_1;
++template <> Packet4d pset1(const double &) {
++  int __A;
++  pset1___trans_tmp_1 = __m256d{__A};
++  return pset1___trans_tmp_1;
++}
++template <> void pstoreu(double *to, const Packet4d &from) {
++  *(__attribute__((__vector_size__(4 * sizeof(double)))) double *)to = from;
++}
++struct scalar_product_op {
++  template < typename Packet > void packetOp(Packet a, Packet) { pmul(a); }
++};
++struct scalar_constant_op {
++  template < typename PacketType > PacketType packetOp() {
++    return pset1< PacketType >(0);
++  }
++};
++struct assign_op {
++  template < int, typename Packet > void assignPacket(double *a, Packet b) {
++    pstoret< double, Packet, 0 >(a, b);
++  }
++};
++template < typename Derived >
++struct DenseCoeffsBase< Derived, 0 > : EigenBase< Derived > {};
++template < typename Derived >
++struct DenseCoeffsBase< Derived > : DenseCoeffsBase< Derived, 0 > {};
++template < typename Derived > struct DenseBase : DenseCoeffsBase< Derived > {
++  using DenseCoeffsBase< Derived >::derived;
++  enum { SizeAtCompileTime, MaxSizeAtCompileTime };
++  static CwiseNullaryOp< scalar_constant_op, Derived > Constant();
++  Derived &setConstant();
++  struct FixedSegmentReturnType {
++    typedef VectorBlock Type;
++  };
++  template < int > typename FixedSegmentReturnType::Type segment() {
++    return typename FixedSegmentReturnType::Type(derived(), 0, 0);
++  }
++};
++template < typename Derived > struct MatrixBase : DenseBase< Derived > {
++  using DenseBase< Derived >::derived;
++  template < typename OtherDerived >
++  CwiseBinaryOp< scalar_product_op, const Derived, const OtherDerived >
++  cwiseProduct(OtherDerived) {
++    return CwiseBinaryOp< scalar_product_op, const Derived,
++                          const OtherDerived >(derived(), derived());
++  }
++  template < typename OtherDerived >
++  Derived &operator=(const DenseBase< OtherDerived > &);
++};
++template < typename Derived > struct EigenBase {
++  Derived &derived() { return *static_cast< Derived * >(this); }
++  Derived derived() const;
++};
++template < typename > struct binary_evaluator;
++template < typename Derived > struct evaluator {
++  typedef Derived PlainObjectType;
++  typedef typename PlainObjectType::Scalar Scalar;
++  enum { IsVectorAtCompileTime, Flags };
++  evaluator(PlainObjectType m) : m_data(m.data()) {}
++  Scalar &coeffRef(int, int);
++  template < int, typename PacketType > PacketType packet(int, int) {
++    return ploadt< PacketType, 0 >(m_data);
++  }
++  const Scalar *m_data;
++};
++template < typename Scalar, int Rows, int Cols, int Options, int MaxRows,
++           int MaxCols >
++struct evaluator< Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > >
++    : evaluator< PlainObjectBase< Matrix< Scalar, Rows, Cols > > > {
++  typedef Matrix< Scalar, Rows, Cols > XprType;
++  evaluator(XprType m) : evaluator< PlainObjectBase< XprType > >(m) {}
++};
++struct nullary_wrapper {
++  template < typename T, typename IndexType >
++  T packetOp(scalar_constant_op op, IndexType, IndexType) {
++    return op.packetOp< T >();
++  }
++};
++template < typename NullaryOp, typename PlainObjectType >
++struct evaluator< CwiseNullaryOp< NullaryOp, PlainObjectType > > {
++  evaluator(CwiseNullaryOp< NullaryOp, PlainObjectType >);
++  template < int, typename PacketType, typename IndexType >
++  PacketType packet(IndexType row, IndexType col) {
++    return m_wrapper.packetOp< PacketType >(m_functor, row, col);
++  }
++  NullaryOp m_functor;
++  nullary_wrapper m_wrapper;
++};
++template < typename BinaryOp, typename Lhs, typename Rhs >
++struct evaluator< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >
++    : binary_evaluator< CwiseBinaryOp< BinaryOp, Lhs, Rhs > > {
++  evaluator(CwiseBinaryOp< BinaryOp, Lhs, Rhs > xpr)
++      : binary_evaluator< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >(xpr) {}
++};
++template < typename BinaryOp, typename Lhs, typename Rhs >
++struct binary_evaluator< CwiseBinaryOp< BinaryOp, Lhs, Rhs > > {
++  binary_evaluator(CwiseBinaryOp< BinaryOp, Lhs, Rhs > xpr)
++      : m_lhsImpl(xpr.lhs()), m_rhsImpl(xpr.rhs()) {}
++  template < int, typename PacketType > PacketType packet(int, int) {
++    PacketType __trans_tmp_1 = m_lhsImpl.template packet< 0, PacketType >(0, 0);
++    PacketType __trans_tmp_2;
++    m_functor.packetOp(__trans_tmp_1, __trans_tmp_2);
++  }
++  BinaryOp m_functor;
++  evaluator< Lhs > m_lhsImpl;
++  evaluator< Rhs > m_rhsImpl;
++};
++template < typename Derived > struct mapbase_evaluator {
++  typedef Derived XprType;
++  mapbase_evaluator(XprType map) : m_data(map.data()) {}
++  typename XprType::Scalar &coeffRef(int, int) { return m_data[0]; }
++  typename XprType::PointerType m_data;
++};
++template < int > struct block_evaluator;
++template < typename ArgType, int BlockRows, int BlockCols, bool InnerPanel >
++struct evaluator< Block< ArgType, BlockRows, BlockCols, InnerPanel > >
++    : block_evaluator< BlockCols > {
++  enum { Flags };
++  evaluator(Block< ArgType, 1, 1 > block) : block_evaluator< 1 >(block) {}
++};
++template < int BlockCols >
++struct block_evaluator
++    : mapbase_evaluator< Block< Matrix< double, 10, 1 >, 1, BlockCols > > {
++  typedef Block< Matrix< double, 10, 1 >, 1, BlockCols > XprType;
++  block_evaluator(XprType block) : mapbase_evaluator< XprType >(block) {}
++};
++template < typename DstEvaluator > struct copy_using_evaluator_traits {
++  typedef typename DstEvaluator::XprType Dst;
++  typedef typename Dst::Scalar DstScalar;
++  enum { DstFlags = DstEvaluator::Flags };
++  enum { InnerSize = DstFlags };
++  typedef typename conditional<
++      int() == LinearVectorizedTraversal,
++      typename find_best_packet< DstScalar, Dst::SizeAtCompileTime >::type,
++      typename find_best_packet< DstScalar, InnerSize >::type >::type
++      PacketType;
++};
++template < typename Kernel >
++struct copy_using_evaluator_innervec_CompleteUnrolling {
++  enum { outer, inner, SrcAlignment, DstAlignment };
++  static void run(Kernel kernel) {
++    kernel.template assignPacketByOuterInner< DstAlignment, SrcAlignment,
++                                              typename Kernel::PacketType >(
++        outer, inner);
++  }
++};
++template < typename Kernel > struct dense_assignment_loop {
++  static void run(Kernel kernel) {
++    copy_using_evaluator_innervec_CompleteUnrolling< Kernel >::run(kernel);
++  }
++};
++template < typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT,
++           typename Functor >
++struct generic_dense_assignment_kernel {
++  typedef DstEvaluatorTypeT DstXprType;
++  typedef DstEvaluatorTypeT DstEvaluatorType;
++  typedef SrcEvaluatorTypeT SrcEvaluatorType;
++  typedef typename copy_using_evaluator_traits< DstEvaluatorTypeT >::PacketType
++      PacketType;
++  generic_dense_assignment_kernel(DstEvaluatorType dst, SrcEvaluatorType src,
++                                  Functor, DstXprType dstExpr)
++      : m_dst(dst), m_src(src), m_dstExpr(dstExpr) {}
++  template < int StoreMode, int LoadMode, typename >
++  void assignPacketByOuterInner(long, long) {
++    long row;
++    long col;
++    m_functor.template assignPacket< StoreMode >(
++        &m_dst.coeffRef(row, col),
++        m_src.template packet< LoadMode, PacketType >(row, col));
++  }
++  DstEvaluatorType &m_dst;
++  SrcEvaluatorType m_src;
++  Functor m_functor;
++  DstXprType m_dstExpr;
++};
++template < typename DstXprType, typename SrcXprType, typename Functor >
++void call_dense_assignment_loop(DstXprType dst, SrcXprType src, Functor func) {
++  typedef evaluator< DstXprType > DstEvaluatorType;
++  typedef evaluator< SrcXprType > SrcEvaluatorType;
++  SrcEvaluatorType srcEvaluator(src);
++  DstEvaluatorType dstEvaluator(dst);
++  typedef generic_dense_assignment_kernel< DstEvaluatorType, SrcEvaluatorType,
++                                           Functor >
++      Kernel;
++  Kernel kernel(dstEvaluator, srcEvaluator, func, dst);
++  dense_assignment_loop< Kernel >::run(kernel);
++}
++template < typename, typename, typename > struct Assignment;
++template < typename Dst, typename Src > void call_assignment(Dst dst, Src src) {
++  call_assignment(dst, src, assign_op());
++}
++template < typename Dst, typename Src, typename Func >
++void call_assignment(Dst dst, Src src, Func func) {
++  call_assignment_no_alias(dst, src, func);
++}
++template < typename Dst, typename Src, typename Func >
++void call_assignment_no_alias(Dst dst, Src src, Func func) {
++  enum { NeedToTranspose };
++  Assignment< typename conditional< NeedToTranspose, int, Dst >::type, Src,
++              Func >::run(dst, src, func);
++}
++template < typename DstXprType, typename SrcXprType, typename Functor >
++struct Assignment {
++  static void run(DstXprType dst, SrcXprType src, Functor func) {
++    call_dense_assignment_loop(dst, src, func);
++  }
++};
++template < typename Derived >
++template < typename OtherDerived >
++Derived &MatrixBase< Derived >::
++operator=(const DenseBase< OtherDerived > &other) {
++  call_assignment(derived(), other.derived());
++}
++template < int Size > struct plain_array { double array[Size]; };
++template < int Size > class DenseStorage {
++  plain_array< Size > m_data;
++
++public:
++  const double *data() const { return m_data.array; }
++  double *data() { return m_data.array; }
++};
++template < typename Derived >
++struct PlainObjectBase : dense_xpr_base< Derived >::type {
++  typedef typename dense_xpr_base< Derived >::type Base;
++  typedef typename traits< Derived >::Scalar Scalar;
++  DenseStorage< Base::MaxSizeAtCompileTime > m_storage;
++  const Scalar *data() const { return m_storage.data(); }
++  Scalar *data() { return m_storage.data(); }
++  PlainObjectBase() {}
++  template < typename OtherDerived > PlainObjectBase(OtherDerived other) {
++    call_assignment_no_alias(this->derived(), other, assign_op());
++  }
++};
++template < typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
++           int _MaxCols >
++struct traits< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > > {
++  typedef _Scalar Scalar;
++  enum { Flags = compute_matrix_flags::ret };
++};
++template < typename, int _Rows, int _Cols, int, int, int >
++struct Matrix : PlainObjectBase< Matrix< double, _Rows, _Cols > > {
++  PlainObjectBase< Matrix > Base;
++  Matrix() {}
++  template < typename OtherDerived > Matrix(OtherDerived other) : Base(other) {}
++};
++template < typename, typename, typename > struct CwiseBinaryOp {
++  typedef ref_selector::type LhsNested;
++  CwiseBinaryOp(Matrix< double, 10, 1 > &aLhs, Matrix< double, 0, 0 >)
++      : m_lhs(aLhs) {}
++  LhsNested lhs() { return m_lhs; }
++  Matrix< double, 8, 1 > rhs() {}
++  LhsNested m_lhs;
++};
++template < typename NullaryOp, typename >
++struct CwiseNullaryOp
++    : dense_xpr_base< CwiseNullaryOp< NullaryOp, int > >::type {};
++template < typename Derived > Derived &DenseBase< Derived >::setConstant() {
++  derived() = Constant();
++}
++template < typename Derived >
++struct MapBase< Derived, ReadOnlyAccessors > : dense_xpr_base< Derived >::type {
++  typedef typename dense_xpr_base< Derived >::type Base;
++  typedef typename traits< Derived >::Scalar Scalar;
++  typedef typename conditional< is_lvalue< Derived >::value, Scalar *,
++                                Scalar >::type PointerType;
++  Scalar *data() { return m_data; }
++  MapBase(PointerType dataPtr, long, long) : m_data(dataPtr) {}
++  PointerType m_data;
++};
++template < typename Derived >
++struct MapBase< Derived > : MapBase< Derived, ReadOnlyAccessors > {
++  typedef MapBase< Derived, ReadOnlyAccessors > Base;
++  MapBase(typename Base::PointerType dataPtr, long rows, long cols)
++      : Base(dataPtr, rows, cols) {}
++  using MapBase< Derived, ReadOnlyAccessors >::Base::operator=;
++};
++template < typename XprType, int BlockRows, int BlockCols, bool InnerPanel >
++struct traits< Block< XprType, BlockRows, BlockCols, InnerPanel > >
++    : traits< XprType > {};
++template < int, int > struct BlockImpl_dense;
++template < typename, int, int, typename > class BlockImpl;
++template < typename, int BlockRows, int BlockCols, bool >
++struct Block : BlockImpl< Matrix< double, 10, 1 >, BlockRows, BlockCols, int > {
++  typedef BlockImpl< Matrix< double, 10, 1 >, BlockRows, BlockCols, int > Impl;
++  using Impl::operator=;
++  Block(Matrix< double, 10, 1 > &xpr, long startRow, long startCol,
++        long blockRows, long blockCols)
++      : Impl(xpr, startRow, startCol, blockRows, blockCols) {}
++};
++template < typename XprType, int BlockRows, int BlockCols >
++struct BlockImpl< XprType, BlockRows, BlockCols, int >
++    : BlockImpl_dense< BlockRows, BlockCols > {
++  typedef BlockImpl_dense< BlockRows, BlockCols > Impl;
++  typedef Impl Base;
++  using Base::operator=;
++  BlockImpl(XprType &xpr, long startRow, long startCol, long blockRows,
++            long blockCols)
++      : Impl(xpr, startRow, startCol, blockRows, blockCols) {}
++};
++template < int BlockRows, int BlockCols >
++struct BlockImpl_dense
++    : MapBase< Block< Matrix< double, 10, 1 >, BlockRows, BlockCols > > {
++  typedef MapBase< Block< Matrix< double, 10, 1 >, BlockRows, BlockCols > >
++      Base;
++  using Base::operator=;
++  BlockImpl_dense(Matrix< double, 10, 1 > &xpr, long, long, long blockRows,
++                  long blockCols)
++      : Base(xpr.data(), blockRows, blockCols) {}
++};
++struct VectorBlock : Block< int, traits< Matrix< double, 0, 1 > >::Flags, 1 > {
++  VectorBlock(Matrix< double, 10, 1 > &vector, long start, long size)
++      : Block(vector, 0, start, 1, size) {}
++};
++namespace std {
++template < typename _Alloc > struct _Vector_base {
++  typedef typename allocator_traits< _Alloc >::pointer pointer;
++};
++template < typename _Tp, typename _Alloc = allocator< _Tp > > class vector {
++public:
++  typedef __normal_iterator< typename _Vector_base< _Alloc >::pointer, int >
++      iterator;
++  iterator begin();
++  iterator end();
++};
++struct FrameHessian {
++  Matrix< double, 0, 1 > step;
++  void setState(Matrix< double, 0, 1 >);
++};
++struct FullSystem {
++  bool doStepFromBackup();
++  vector< FrameHessian * > frameHessians;
++};
++bool FullSystem::doStepFromBackup() {
++  Matrix< double, 10, 1 > pstepfac;
++  pstepfac.segment< 4 >().setConstant();
++  for (FrameHessian *fh : frameHessians)
++    fh->setState(pstepfac.cwiseProduct(fh->step));
++}
++} // namespace std
 Index: gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C
 ===================================================================
 --- a/src/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C	(.../tags/gcc_7_2_0_release)
@@ -16942,6 +17710,47 @@ Index: gcc/testsuite/g++.dg/pr80287.C
 +} a;
 +
 +char b = a.ino;
+Index: gcc/testsuite/g++.dg/pr82155.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/pr82155.C	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/testsuite/g++.dg/pr82155.C	(.../branches/gcc-7-branch)
+@@ -0,0 +1,36 @@
++/* { dg-do compile { target c++11 } } */
++/* { dg-options "-g -O2" } */
++
++template <typename a> struct b { a c; };
++template <typename d> struct e { d *operator->(); };
++template <typename d> class h {
++public:
++  typedef e<d> ag;
++};
++class i {
++protected:
++  i(int);
++};
++class j {
++  virtual void k(int) = 0;
++
++public:
++  int f;
++  void l() { k(f); }
++};
++struct m : i {
++  int cn;
++  m() : i(cn) {
++    struct n : j {
++      n() {}
++      void k(int) {}
++    };
++  }
++};
++struct o {
++  o() {
++    for (h<b<b<j *>>>::ag g;;)
++      g->c.c->l();
++  }
++};
++void fn1() { o(); }
 Index: gcc/testsuite/g++.dg/other/bitfield6.C
 ===================================================================
 --- a/src/gcc/testsuite/g++.dg/other/bitfield6.C	(.../tags/gcc_7_2_0_release)
@@ -18004,6 +18813,23 @@ Index: gcc/tree-ssa-alias.c
  	    return true;
  	}
  
+Index: gcc/config.in
+===================================================================
+--- a/src/gcc/config.in	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/config.in	(.../branches/gcc-7-branch)
+@@ -709,6 +709,12 @@
+ #endif
+ 
+ 
++/* Define if your assembler supports -xbrace_comment option. */
++#ifndef USED_FOR_TARGET
++#undef HAVE_AS_XBRACE_COMMENT_OPTION
++#endif
++
++
+ /* Define to 1 if you have the `atoq' function. */
+ #ifndef USED_FOR_TARGET
+ #undef HAVE_ATOQ
 Index: gcc/dwarf2out.c
 ===================================================================
 --- a/src/gcc/dwarf2out.c	(.../tags/gcc_7_2_0_release)
@@ -18210,7 +19036,26 @@ Index: gcc/dwarf2out.c
    if (die != NULL && die->die_parent == NULL)
      add_child_die (context_die, die);
    else if (TREE_CODE (decl_or_origin) == IMPORTED_DECL)
-@@ -26058,7 +26087,8 @@
+@@ -25490,10 +25519,16 @@
+ 	     so that all nested DIEs are generated at the proper scope in the
+ 	     first shot.  */
+ 	  tree context = decl_function_context (decl);
+-	  if (context != NULL && lookup_decl_die (context) == NULL)
++	  if (context != NULL)
+ 	    {
++	      dw_die_ref context_die = lookup_decl_die (context);
+ 	      current_function_decl = context;
+-	      dwarf2out_decl (context);
++
++	      /* Avoid emitting DIEs multiple times, but still process CONTEXT
++		 enough so that it lands in its own context.  This avoids type
++		 pruning issues later on.  */
++	      if (context_die == NULL || is_declaration_die (context_die))
++		dwarf2out_decl (context);
+ 	    }
+ 
+ 	  current_function_decl = decl;
+@@ -26058,7 +26093,8 @@
        j = 0;
        FOR_EACH_VEC_ELT (*tmpl_value_parm_die_table, i, e)
  	{
@@ -18578,7 +19423,14 @@ Index: gcc/ada/ChangeLog
 ===================================================================
 --- a/src/gcc/ada/ChangeLog	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/ada/ChangeLog	(.../branches/gcc-7-branch)
-@@ -1,3 +1,68 @@
+@@ -1,3 +1,75 @@
++2017-11-10  Eric Botcazou  <ebotcazou at adacore.com>
++
++	* gcc-interface/utils.c (convert) <RECORD_TYPE>: Add comment and do
++	not fall through to the next case.
++	<ARRAY_TYPE>: Deal specially with a dereference from another array
++	type with the same element type.
++
 +2017-10-21  Eric Botcazou  <ebotcazou at adacore.com>
 +
 +	* gcc-interface/Makefile.in: Remove bogus settings for VxWorks.
@@ -18651,7 +19503,44 @@ Index: gcc/ada/gcc-interface/utils.c
 ===================================================================
 --- a/src/gcc/ada/gcc-interface/utils.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/ada/gcc-interface/utils.c	(.../branches/gcc-7-branch)
-@@ -5230,20 +5230,26 @@
+@@ -4660,6 +4660,7 @@
+       return fold (convert_to_real (type, expr));
+ 
+     case RECORD_TYPE:
++      /* Do a normal conversion between scalar and justified modular type.  */
+       if (TYPE_JUSTIFIED_MODULAR_P (type) && !AGGREGATE_TYPE_P (etype))
+ 	{
+ 	  vec<constructor_elt, va_gc> *v;
+@@ -4671,9 +4672,27 @@
+ 	  return gnat_build_constructor (type, v);
+ 	}
+ 
+-      /* ... fall through ... */
++      /* In these cases, assume the front-end has validated the conversion.
++	 If the conversion is valid, it will be a bit-wise conversion, so
++	 it can be viewed as an unchecked conversion.  */
++      return unchecked_convert (type, expr, false);
+ 
+     case ARRAY_TYPE:
++      /* Do a normal conversion between unconstrained and constrained array
++	 type, assuming the latter is a constrained version of the former.  */
++      if (TREE_CODE (expr) == INDIRECT_REF
++	  && ecode == ARRAY_TYPE
++	  && TREE_TYPE (etype) == TREE_TYPE (type))
++	{
++	  tree ptr_type = build_pointer_type (type);
++	  tree t = build_unary_op (INDIRECT_REF, NULL_TREE,
++				   fold_convert (ptr_type,
++						 TREE_OPERAND (expr, 0)));
++	  TREE_READONLY (t) = TREE_READONLY (expr);
++	  TREE_THIS_NOTRAP (t) = TREE_THIS_NOTRAP (expr);
++	  return t;
++	}
++
+       /* In these cases, assume the front-end has validated the conversion.
+ 	 If the conversion is valid, it will be a bit-wise conversion, so
+ 	 it can be viewed as an unchecked conversion.  */
+@@ -5230,20 +5249,26 @@
  					? TYPE_RM_SIZE (etype)
  					: TYPE_SIZE (etype)) == 0)))
      {
@@ -19394,6 +20283,146 @@ Index: gcc/fortran/trans-expr.c
 ===================================================================
 --- a/src/gcc/fortran/trans-expr.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/trans-expr.c	(.../branches/gcc-7-branch)
+@@ -1287,7 +1287,7 @@
+ 
+ 	  from_len = gfc_conv_descriptor_size (from_data, 1);
+ 	  tmp = fold_build2_loc (input_location, NE_EXPR,
+-				  boolean_type_node, from_len, orig_nelems);
++				  logical_type_node, from_len, orig_nelems);
+ 	  msg = xasprintf ("Array bound mismatch for dimension %d "
+ 			   "of array '%s' (%%ld/%%ld)",
+ 			   1, name);
+@@ -1338,7 +1338,7 @@
+ 	  extcopy = gfc_finish_block (&ifbody);
+ 
+ 	  tmp = fold_build2_loc (input_location, GT_EXPR,
+-				 boolean_type_node, from_len,
++				 logical_type_node, from_len,
+ 				 integer_zero_node);
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR,
+ 				 void_type_node, tmp, extcopy, stdcopy);
+@@ -1366,7 +1366,7 @@
+ 	  vec_safe_push (args, to_len);
+ 	  extcopy = build_call_vec (fcn_type, fcn, args);
+ 	  tmp = fold_build2_loc (input_location, GT_EXPR,
+-				 boolean_type_node, from_len,
++				 logical_type_node, from_len,
+ 				 integer_zero_node);
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR,
+ 				 void_type_node, tmp, extcopy, stdcopy);
+@@ -1380,7 +1380,7 @@
+     {
+       tree cond;
+       cond = fold_build2_loc (input_location, NE_EXPR,
+-			      boolean_type_node,
++			      logical_type_node,
+ 			      from_data, null_pointer_node);
+       tmp = fold_build3_loc (input_location, COND_EXPR,
+ 			     void_type_node, cond,
+@@ -1425,7 +1425,7 @@
+       gfc_init_se (&src, NULL);
+       gfc_conv_expr (&src, rhs);
+       src.expr = gfc_build_addr_expr (NULL_TREE, src.expr);
+-      tree cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tree cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   src.expr, fold_convert (TREE_TYPE (src.expr),
+ 							   null_pointer_node));
+       res = build3_loc (input_location, COND_EXPR, TREE_TYPE (res), cond, res,
+@@ -1492,7 +1492,7 @@
+ 	{
+ 	  /* Check if _def_init is non-NULL. */
+ 	  tree cond = fold_build2_loc (input_location, NE_EXPR,
+-				       boolean_type_node, src.expr,
++				       logical_type_node, src.expr,
+ 				       fold_convert (TREE_TYPE (src.expr),
+ 						     null_pointer_node));
+ 	  tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (tmp), cond,
+@@ -1662,7 +1662,7 @@
+       decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
+     }
+ 
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, decl,
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, decl,
+ 			  fold_convert (TREE_TYPE (decl), null_pointer_node));
+ 
+   /* Fortran 2008 allows to pass null pointers and non-associated pointers
+@@ -1699,10 +1699,10 @@
+ 
+       if (tmp != NULL_TREE)
+ 	{
+-	  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
++	  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, tmp,
+ 				 fold_convert (TREE_TYPE (tmp), null_pointer_node));
+ 	  cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-				  boolean_type_node, cond, tmp);
++				  logical_type_node, cond, tmp);
+ 	}
+     }
+ 
+@@ -2264,15 +2264,15 @@
+   if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+     {
+       tree nonempty = fold_build2_loc (input_location, LE_EXPR,
+-				       boolean_type_node, start.expr,
++				       logical_type_node, start.expr,
+ 				       end.expr);
+ 
+       /* Check lower bound.  */
+-      fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      fault = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       start.expr,
+ 			       build_int_cst (gfc_charlen_type_node, 1));
+       fault = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-			       boolean_type_node, nonempty, fault);
++			       logical_type_node, nonempty, fault);
+       if (name)
+ 	msg = xasprintf ("Substring out of bounds: lower bound (%%ld) of '%s' "
+ 			 "is less than one", name);
+@@ -2285,10 +2285,10 @@
+       free (msg);
+ 
+       /* Check upper bound.  */
+-      fault = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++      fault = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			       end.expr, se->string_length);
+       fault = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-			       boolean_type_node, nonempty, fault);
++			       logical_type_node, nonempty, fault);
+       if (name)
+ 	msg = xasprintf ("Substring out of bounds: upper bound (%%ld) of '%s' "
+ 			 "exceeds string length (%%ld)", name);
+@@ -2890,9 +2890,9 @@
+   /* If rhs < 0 and lhs is an integer, the result is -1, 0 or 1.  */
+   if ((sgn == -1) && (TREE_CODE (type) == INTEGER_TYPE))
+     {
+-      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			     lhs, build_int_cst (TREE_TYPE (lhs), -1));
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			      lhs, build_int_cst (TREE_TYPE (lhs), 1));
+ 
+       /* If rhs is even,
+@@ -2900,7 +2900,7 @@
+       if ((n & 1) == 0)
+         {
+ 	  tmp = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				 boolean_type_node, tmp, cond);
++				 logical_type_node, tmp, cond);
+ 	  se->expr = fold_build3_loc (input_location, COND_EXPR, type,
+ 				      tmp, build_int_cst (type, 1),
+ 				      build_int_cst (type, 0));
+@@ -3386,8 +3386,8 @@
+ 
+   if (lop)
+     {
+-      /* The result of logical ops is always boolean_type_node.  */
+-      tmp = fold_build2_loc (input_location, code, boolean_type_node,
++      /* The result of logical ops is always logical_type_node.  */
++      tmp = fold_build2_loc (input_location, code, logical_type_node,
+ 			     lse.expr, rse.expr);
+       se->expr = convert (type, tmp);
+     }
 @@ -4178,9 +4178,7 @@
        if (arg2 && arg2->expr_type == EXPR_CONSTANT)
  	d = mpz_get_si (arg2->value.integer) - 1;
@@ -19405,6 +20434,24 @@ Index: gcc/fortran/trans-expr.c
  
        if (expr->value.function.isym->id == GFC_ISYM_LBOUND)
  	{
+@@ -4987,7 +4985,7 @@
+ 	      tree descriptor_data;
+ 
+ 	      descriptor_data = ss->info->data.array.data;
+-	      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				     descriptor_data,
+ 				     fold_convert (TREE_TYPE (descriptor_data),
+ 						   null_pointer_node));
+@@ -5151,7 +5149,7 @@
+ 			  tree cond;
+ 			  tmp = gfc_build_addr_expr (NULL_TREE, parmse.expr);
+ 			  cond = fold_build2_loc (input_location, NE_EXPR,
+-						  boolean_type_node, tmp,
++						  logical_type_node, tmp,
+ 						  fold_convert (TREE_TYPE (tmp),
+ 							    null_pointer_node));
+ 			  gfc_start_block (&block);
 @@ -5173,10 +5171,39 @@
  			}
  		      else
@@ -19449,6 +20496,89 @@ Index: gcc/fortran/trans-expr.c
  			  parmse.expr = gfc_build_addr_expr (NULL_TREE, var);
  			}
  		    }
+@@ -5653,16 +5680,16 @@
+ 	      present = gfc_conv_expr_present (e->symtree->n.sym);
+ 	      type = TREE_TYPE (present);
+ 	      present = fold_build2_loc (input_location, EQ_EXPR,
+-					 boolean_type_node, present,
++					 logical_type_node, present,
+ 					 fold_convert (type,
+ 						       null_pointer_node));
+ 	      type = TREE_TYPE (parmse.expr);
+ 	      null_ptr = fold_build2_loc (input_location, EQ_EXPR,
+-					  boolean_type_node, parmse.expr,
++					  logical_type_node, parmse.expr,
+ 					  fold_convert (type,
+ 							null_pointer_node));
+ 	      cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+-				      boolean_type_node, present, null_ptr);
++				      logical_type_node, present, null_ptr);
+ 	    }
+           else
+ 	    {
+@@ -5689,7 +5716,7 @@
+ 		tmp = gfc_build_addr_expr (NULL_TREE, tmp);
+ 
+ 	      cond = fold_build2_loc (input_location, EQ_EXPR,
+-				      boolean_type_node, tmp,
++				      logical_type_node, tmp,
+ 				      fold_convert (TREE_TYPE (tmp),
+ 						    null_pointer_node));
+ 	    }
+@@ -6184,7 +6211,7 @@
+ 		     happen in a function returning a pointer.  */
+ 		  tmp = gfc_conv_descriptor_data_get (info->descriptor);
+ 		  tmp = fold_build2_loc (input_location, NE_EXPR,
+-					 boolean_type_node,
++					 logical_type_node,
+ 					 tmp, info->data);
+ 		  gfc_trans_runtime_check (true, false, tmp, &se->pre, NULL,
+ 					   gfc_msg_fault);
+@@ -6310,7 +6337,7 @@
+ 
+ 	  final_fndecl = gfc_class_vtab_final_get (se->expr);
+ 	  is_final = fold_build2_loc (input_location, NE_EXPR,
+-				      boolean_type_node,
++				      logical_type_node,
+  			    	      final_fndecl,
+ 				      fold_convert (TREE_TYPE (final_fndecl),
+ 					   	    null_pointer_node));
+@@ -6384,7 +6411,7 @@
+   gfc_init_block (&loop);
+ 
+   /* Exit condition.  */
+-  cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, i,
++  cond = fold_build2_loc (input_location, LE_EXPR, logical_type_node, i,
+ 			  build_zero_cst (sizetype));
+   tmp = build1_v (GOTO_EXPR, exit_label);
+   tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp,
+@@ -6477,7 +6504,7 @@
+   */
+ 
+   /* Do nothing if the destination length is zero.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, dlen,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node, dlen,
+ 			  build_int_cst (size_type_node, 0));
+ 
+   /* For non-default character kinds, we have to multiply the string
+@@ -6513,7 +6540,7 @@
+   gfc_add_expr_to_block (&tmpblock2, tmp2);
+ 
+   /* If the destination is longer, fill the end with spaces.  */
+-  cond2 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, slen,
++  cond2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node, slen,
+ 			   dlen);
+ 
+   /* Wstringop-overflow appears at -O3 even though this warning is not
+@@ -7098,7 +7125,7 @@
+ 					null_pointer_node);
+ 	  null_expr = gfc_finish_block (&block);
+ 	  tmp = gfc_conv_descriptor_data_get (arg->symtree->n.sym->backend_decl);
+-	  tmp = build2_loc (input_location, EQ_EXPR, boolean_type_node, tmp,
++	  tmp = build2_loc (input_location, EQ_EXPR, logical_type_node, tmp,
+ 			    fold_convert (TREE_TYPE (tmp), null_pointer_node));
+ 	  return build3_v (COND_EXPR, tmp,
+ 			   null_expr, non_null_expr);
 @@ -8051,7 +8078,7 @@
      {
        /* Get the vptr from the rhs expression only, when it is variable.
@@ -19570,6 +20700,92 @@ Index: gcc/fortran/trans-expr.c
  	  else if (expr2->expr_type == EXPR_FUNCTION)
  	    {
  	      tree bound[GFC_MAX_DIMENSIONS];
+@@ -8621,7 +8666,7 @@
+ 
+ 	  lsize = gfc_evaluate_now (lsize, &block);
+ 	  rsize = gfc_evaluate_now (rsize, &block);
+-	  fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  fault = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				   rsize, lsize);
+ 
+ 	  msg = _("Target of rank remapping is too small (%ld < %ld)");
+@@ -8740,7 +8785,7 @@
+       /* Are the rhs and the lhs the same?  */
+       if (deep_copy)
+ 	{
+-	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				  gfc_build_addr_expr (NULL_TREE, lse->expr),
+ 				  gfc_build_addr_expr (NULL_TREE, rse->expr));
+ 	  cond = gfc_evaluate_now (cond, &lse->pre);
+@@ -9015,7 +9060,7 @@
+      the lhs descriptor.  */
+   tmp = gfc_conv_descriptor_data_get (desc);
+   zero_cond = fold_build2_loc (input_location, EQ_EXPR,
+-			       boolean_type_node, tmp,
++			       logical_type_node, tmp,
+ 			       build_int_cst (TREE_TYPE (tmp), 0));
+   zero_cond = gfc_evaluate_now (zero_cond, &se->post);
+   tmp = gfc_call_free (tmp);
+@@ -9039,11 +9084,11 @@
+       tmp = fold_build2_loc (input_location, PLUS_EXPR,
+ 			     gfc_array_index_type, tmp, tmp1);
+       tmp = fold_build2_loc (input_location, NE_EXPR,
+-			     boolean_type_node, tmp,
++			     logical_type_node, tmp,
+ 			     gfc_index_zero_node);
+       tmp = gfc_evaluate_now (tmp, &se->post);
+       zero_cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				   boolean_type_node, tmp,
++				   logical_type_node, tmp,
+ 				   zero_cond);
+     }
+ 
+@@ -9482,7 +9527,7 @@
+ 
+   /* Do the allocation if the lhs is NULL. Otherwise go to label 1.  */
+   tmp = build_int_cst (TREE_TYPE (lse.expr), 0);
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			  lse.expr, tmp);
+   tmp = build3_v (COND_EXPR, cond,
+ 		  build1_v (GOTO_EXPR, jump_label1),
+@@ -9560,7 +9605,7 @@
+      rhs are different.  */
+   if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred)
+     {
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			      lse.string_length, size);
+       /* Jump past the realloc if the lengths are the same.  */
+       tmp = build3_v (COND_EXPR, cond,
+@@ -9706,7 +9751,7 @@
+       gfc_init_block (&alloc);
+       gfc_allocate_using_malloc (&alloc, class_han, tmp, NULL_TREE);
+       tmp = fold_build2_loc (input_location, EQ_EXPR,
+-			     boolean_type_node, class_han,
++			     logical_type_node, class_han,
+ 			     build_int_cst (prvoid_type_node, 0));
+       tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 			     gfc_unlikely (tmp,
+@@ -9759,7 +9804,7 @@
+ 	  extcopy = build_call_vec (TREE_TYPE (TREE_TYPE (fcn)), fcn, args);
+ 
+ 	  tmp = fold_build2_loc (input_location, GT_EXPR,
+-				 boolean_type_node, from_len,
++				 logical_type_node, from_len,
+ 				 integer_zero_node);
+ 	  return fold_build3_loc (input_location, COND_EXPR,
+ 				  void_type_node, tmp,
+@@ -9988,7 +10033,7 @@
+ 	  if (TREE_CODE (lse.expr) == ARRAY_REF)
+ 	    tmp = gfc_build_addr_expr (NULL_TREE, tmp);
+ 
+-	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				  tmp, build_int_cst (TREE_TYPE (tmp), 0));
+ 	  msg = _("Assignment of scalar to unallocated array");
+ 	  gfc_trans_runtime_check (true, false, cond, &loop.pre,
 @@ -10019,12 +10064,16 @@
       NOTE: This relies on having the exact dependence of the length type
       parameter available to the caller; gfortran saves it in the .mod files.
@@ -19594,6 +20810,42 @@ Index: gcc/fortran/trans-array.c
 ===================================================================
 --- a/src/gcc/fortran/trans-array.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/trans-array.c	(.../branches/gcc-7-branch)
+@@ -895,7 +895,7 @@
+ 	      gfc_add_expr_to_block (&do_copying, tmp);
+ 
+ 	      was_packed = fold_build2_loc (input_location, EQ_EXPR,
+-					    boolean_type_node, packed,
++					    logical_type_node, packed,
+ 					    source_data);
+ 	      tmp = gfc_finish_block (&do_copying);
+ 	      tmp = build3_v (COND_EXPR, was_packed, tmp,
+@@ -1163,7 +1163,7 @@
+ 				 to[n], gfc_index_one_node);
+ 
+ 	  /* Check whether the size for this dimension is negative.  */
+-	  cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 				  tmp, gfc_index_zero_node);
+ 	  cond = gfc_evaluate_now (cond, pre);
+ 
+@@ -1171,7 +1171,7 @@
+ 	    or_expr = cond;
+ 	  else
+ 	    or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				       boolean_type_node, or_expr, cond);
++				       logical_type_node, or_expr, cond);
+ 
+ 	  size = fold_build2_loc (input_location, MULT_EXPR,
+ 				  gfc_array_index_type, size, tmp);
+@@ -1431,7 +1431,7 @@
+ 	      /* Verify that all constructor elements are of the same
+ 		 length.  */
+ 	      tree cond = fold_build2_loc (input_location, NE_EXPR,
+-					   boolean_type_node, first_len_val,
++					   logical_type_node, first_len_val,
+ 					   se->string_length);
+ 	      gfc_trans_runtime_check
+ 		(true, false, cond, &se->pre, &expr->where,
 @@ -1441,6 +1441,17 @@
  	    }
  	}
@@ -19612,6 +20864,470 @@ Index: gcc/fortran/trans-array.c
    else
      {
        /* TODO: Should the frontend already have done this conversion?  */
+@@ -1762,14 +1773,14 @@
+ 	  /* Generate the exit condition.  Depending on the sign of
+ 	     the step variable we have to generate the correct
+ 	     comparison.  */
+-	  tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 				 step, build_int_cst (TREE_TYPE (step), 0));
+ 	  cond = fold_build3_loc (input_location, COND_EXPR,
+-		      boolean_type_node, tmp,
++		      logical_type_node, tmp,
+ 		      fold_build2_loc (input_location, GT_EXPR,
+-				       boolean_type_node, shadow_loopvar, end),
++				       logical_type_node, shadow_loopvar, end),
+ 		      fold_build2_loc (input_location, LT_EXPR,
+-				       boolean_type_node, shadow_loopvar, end));
++				       logical_type_node, shadow_loopvar, end));
+ 	  tmp = build1_v (GOTO_EXPR, exit_label);
+ 	  TREE_USED (exit_label) = 1;
+ 	  tmp = build3_v (COND_EXPR, cond, tmp,
+@@ -2277,7 +2288,7 @@
+ 	  /* Check if the character length is negative.  If it is, then
+ 	     set LEN = 0.  */
+ 	  neg_len = fold_build2_loc (input_location, LT_EXPR,
+-				     boolean_type_node, ss_info->string_length,
++				     logical_type_node, ss_info->string_length,
+ 				     build_int_cst (gfc_charlen_type_node, 0));
+ 	  /* Print a warning if bounds checking is enabled.  */
+ 	  if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+@@ -2915,13 +2926,13 @@
+ 	msg = xasprintf ("Index '%%ld' of dimension %d "
+ 			 "outside of expected range (%%ld:%%ld)", n+1);
+ 
+-      fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      fault = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       index, tmp_lo);
+       gfc_trans_runtime_check (true, false, fault, &se->pre, where, msg,
+ 			       fold_convert (long_integer_type_node, index),
+ 			       fold_convert (long_integer_type_node, tmp_lo),
+ 			       fold_convert (long_integer_type_node, tmp_up));
+-      fault = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++      fault = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			       index, tmp_up);
+       gfc_trans_runtime_check (true, false, fault, &se->pre, where, msg,
+ 			       fold_convert (long_integer_type_node, index),
+@@ -2940,7 +2951,7 @@
+ 	msg = xasprintf ("Index '%%ld' of dimension %d "
+ 			 "below lower bound of %%ld", n+1);
+ 
+-      fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      fault = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       index, tmp_lo);
+       gfc_trans_runtime_check (true, false, fault, &se->pre, where, msg,
+ 			       fold_convert (long_integer_type_node, index),
+@@ -3445,7 +3456,7 @@
+ 	      tmp = tmpse.expr;
+ 	    }
+ 
+-	  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  indexse.expr, tmp);
+ 	  msg = xasprintf ("Index '%%ld' of dimension %d of array '%s' "
+ 			   "below lower bound of %%ld", n+1, var_name);
+@@ -3470,7 +3481,7 @@
+ 		}
+ 
+ 	      cond = fold_build2_loc (input_location, GT_EXPR,
+-				      boolean_type_node, indexse.expr, tmp);
++				      logical_type_node, indexse.expr, tmp);
+ 	      msg = xasprintf ("Index '%%ld' of dimension %d of array '%s' "
+ 			       "above upper bound of %%ld", n+1, var_name);
+ 	      gfc_trans_runtime_check (true, false, cond, &se->pre, where, msg,
+@@ -3715,7 +3726,7 @@
+       OMP_FOR_INIT (stmt) = init;
+       /* The exit condition.  */
+       TREE_VEC_ELT (cond, 0) = build2_loc (input_location, LE_EXPR,
+-					   boolean_type_node,
++					   logical_type_node,
+ 					   loop->loopvar[n], loop->to[n]);
+       SET_EXPR_LOCATION (TREE_VEC_ELT (cond, 0), input_location);
+       OMP_FOR_COND (stmt) = cond;
+@@ -3750,7 +3761,7 @@
+ 
+       /* The exit condition.  */
+       cond = fold_build2_loc (input_location, reverse_loop ? LT_EXPR : GT_EXPR,
+-			  boolean_type_node, loop->loopvar[n], loop->to[n]);
++			  logical_type_node, loop->loopvar[n], loop->to[n]);
+       tmp = build1_v (GOTO_EXPR, exit_label);
+       TREE_USED (exit_label) = 1;
+       tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -4182,7 +4193,7 @@
+ 		check_upper = true;
+ 
+ 	      /* Zero stride is not allowed.  */
+-	      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				     info->stride[dim], gfc_index_zero_node);
+ 	      msg = xasprintf ("Zero stride is not allowed, for dimension %d "
+ 			       "of array '%s'", dim + 1, expr_name);
+@@ -4205,23 +4216,23 @@
+ 	      /* non_zerosized is true when the selected range is not
+ 		 empty.  */
+ 	      stride_pos = fold_build2_loc (input_location, GT_EXPR,
+-					boolean_type_node, info->stride[dim],
++					logical_type_node, info->stride[dim],
+ 					gfc_index_zero_node);
+-	      tmp = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++	      tmp = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 				     info->start[dim], end);
+ 	      stride_pos = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					    boolean_type_node, stride_pos, tmp);
++					    logical_type_node, stride_pos, tmp);
+ 
+ 	      stride_neg = fold_build2_loc (input_location, LT_EXPR,
+-				     boolean_type_node,
++				     logical_type_node,
+ 				     info->stride[dim], gfc_index_zero_node);
+-	      tmp = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++	      tmp = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 				     info->start[dim], end);
+ 	      stride_neg = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					    boolean_type_node,
++					    logical_type_node,
+ 					    stride_neg, tmp);
+ 	      non_zerosized = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-					       boolean_type_node,
++					       logical_type_node,
+ 					       stride_pos, stride_neg);
+ 
+ 	      /* Check the start of the range against the lower and upper
+@@ -4231,16 +4242,16 @@
+ 	      if (check_upper)
+ 		{
+ 		  tmp = fold_build2_loc (input_location, LT_EXPR,
+-					 boolean_type_node,
++					 logical_type_node,
+ 					 info->start[dim], lbound);
+ 		  tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					 boolean_type_node,
++					 logical_type_node,
+ 					 non_zerosized, tmp);
+ 		  tmp2 = fold_build2_loc (input_location, GT_EXPR,
+-					  boolean_type_node,
++					  logical_type_node,
+ 					  info->start[dim], ubound);
+ 		  tmp2 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					  boolean_type_node,
++					  logical_type_node,
+ 					  non_zerosized, tmp2);
+ 		  msg = xasprintf ("Index '%%ld' of dimension %d of array '%s' "
+ 				   "outside of expected range (%%ld:%%ld)",
+@@ -4260,10 +4271,10 @@
+ 	      else
+ 		{
+ 		  tmp = fold_build2_loc (input_location, LT_EXPR,
+-					 boolean_type_node,
++					 logical_type_node,
+ 					 info->start[dim], lbound);
+ 		  tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					 boolean_type_node, non_zerosized, tmp);
++					 logical_type_node, non_zerosized, tmp);
+ 		  msg = xasprintf ("Index '%%ld' of dimension %d of array '%s' "
+ 				   "below lower bound of %%ld",
+ 				   dim + 1, expr_name);
+@@ -4287,15 +4298,15 @@
+ 	      tmp = fold_build2_loc (input_location, MINUS_EXPR,
+ 				     gfc_array_index_type, end, tmp);
+ 	      tmp2 = fold_build2_loc (input_location, LT_EXPR,
+-				      boolean_type_node, tmp, lbound);
++				      logical_type_node, tmp, lbound);
+ 	      tmp2 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				      boolean_type_node, non_zerosized, tmp2);
++				      logical_type_node, non_zerosized, tmp2);
+ 	      if (check_upper)
+ 		{
+ 		  tmp3 = fold_build2_loc (input_location, GT_EXPR,
+-					  boolean_type_node, tmp, ubound);
++					  logical_type_node, tmp, ubound);
+ 		  tmp3 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-					  boolean_type_node, non_zerosized, tmp3);
++					  logical_type_node, non_zerosized, tmp3);
+ 		  msg = xasprintf ("Index '%%ld' of dimension %d of array '%s' "
+ 				   "outside of expected range (%%ld:%%ld)",
+ 				   dim + 1, expr_name);
+@@ -4341,7 +4352,7 @@
+ 	      if (size[n])
+ 		{
+ 		  tmp3 = fold_build2_loc (input_location, NE_EXPR,
+-					  boolean_type_node, tmp, size[n]);
++					  logical_type_node, tmp, size[n]);
+ 		  msg = xasprintf ("Array bound mismatch for dimension %d "
+ 				   "of array '%s' (%%ld/%%ld)",
+ 				   dim + 1, expr_name);
+@@ -5025,7 +5036,7 @@
+ 			 gfc_index_one_node);
+ 
+   /* Check whether the size for this dimension is negative.  */
+-  cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, res,
++  cond = fold_build2_loc (input_location, LE_EXPR, logical_type_node, res,
+ 			  gfc_index_zero_node);
+   res = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type, cond,
+ 			 gfc_index_zero_node, res);
+@@ -5033,7 +5044,7 @@
+   /* Build OR expression.  */
+   if (or_expr)
+     *or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				boolean_type_node, *or_expr, cond);
++				logical_type_node, *or_expr, cond);
+ 
+   return res;
+ }
+@@ -5162,7 +5173,7 @@
+       gfc_add_modify (pblock, tmp, gfc_get_dtype (type));
+     }
+ 
+-  or_expr = boolean_false_node;
++  or_expr = logical_false_node;
+ 
+   for (n = 0; n < rank; n++)
+     {
+@@ -5270,12 +5281,12 @@
+ 					   TYPE_MAX_VALUE (gfc_array_index_type)),
+ 					   size);
+       cond = gfc_unlikely (fold_build2_loc (input_location, LT_EXPR,
+-					    boolean_type_node, tmp, stride),
++					    logical_type_node, tmp, stride),
+ 			   PRED_FORTRAN_OVERFLOW);
+       tmp = fold_build3_loc (input_location, COND_EXPR, integer_type_node, cond,
+ 			     integer_one_node, integer_zero_node);
+       cond = gfc_unlikely (fold_build2_loc (input_location, EQ_EXPR,
+-					    boolean_type_node, size,
++					    logical_type_node, size,
+ 					    gfc_index_zero_node),
+ 			   PRED_FORTRAN_SIZE_ZERO);
+       tmp = fold_build3_loc (input_location, COND_EXPR, integer_type_node, cond,
+@@ -5371,12 +5382,12 @@
+ 			 size_type_node,
+ 			 TYPE_MAX_VALUE (size_type_node), element_size);
+   cond = gfc_unlikely (fold_build2_loc (input_location, LT_EXPR,
+-					boolean_type_node, tmp, stride),
++					logical_type_node, tmp, stride),
+ 		       PRED_FORTRAN_OVERFLOW);
+   tmp = fold_build3_loc (input_location, COND_EXPR, integer_type_node, cond,
+ 			 integer_one_node, integer_zero_node);
+   cond = gfc_unlikely (fold_build2_loc (input_location, EQ_EXPR,
+-					boolean_type_node, element_size,
++					logical_type_node, element_size,
+ 					build_int_cst (size_type_node, 0)),
+ 		       PRED_FORTRAN_SIZE_ZERO);
+   tmp = fold_build3_loc (input_location, COND_EXPR, integer_type_node, cond,
+@@ -5634,7 +5645,7 @@
+   if (dimension)
+     {
+       cond = gfc_unlikely (fold_build2_loc (input_location, NE_EXPR,
+-			   boolean_type_node, var_overflow, integer_zero_node),
++			   logical_type_node, var_overflow, integer_zero_node),
+ 			   PRED_FORTRAN_OVERFLOW);
+       tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond,
+ 			     error, gfc_finish_block (&elseblock));
+@@ -5652,7 +5663,7 @@
+   if (status != NULL_TREE)
+     {
+       cond = fold_build2_loc (input_location, EQ_EXPR,
+-			  boolean_type_node, status,
++			  logical_type_node, status,
+ 			  build_int_cst (TREE_TYPE (status), 0));
+       gfc_add_expr_to_block (&se->pre,
+ 		 fold_build3_loc (input_location, COND_EXPR, void_type_node,
+@@ -5902,7 +5913,7 @@
+ 
+ 	  /* Make sure that negative size arrays are translated
+ 	     to being zero size.  */
+-	  tmp = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 				 stride, gfc_index_zero_node);
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR,
+ 				 gfc_array_index_type, tmp,
+@@ -6189,10 +6200,10 @@
+       /* For non-constant shape arrays we only check if the first dimension
+ 	 is contiguous.  Repacking higher dimensions wouldn't gain us
+ 	 anything as we still don't know the array stride.  */
+-      partial = gfc_create_var (boolean_type_node, "partial");
++      partial = gfc_create_var (logical_type_node, "partial");
+       TREE_USED (partial) = 1;
+       tmp = gfc_conv_descriptor_stride_get (dumdesc, gfc_rank_cst[0]);
+-      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, tmp,
++      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, tmp,
+ 			     gfc_index_one_node);
+       gfc_add_modify (&init, partial, tmp);
+     }
+@@ -6207,7 +6218,7 @@
+       stride = gfc_conv_descriptor_stride_get (dumdesc, gfc_rank_cst[0]);
+       stride = gfc_evaluate_now (stride, &init);
+ 
+-      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			     stride, gfc_index_zero_node);
+       tmp = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
+ 			     tmp, gfc_index_one_node, stride);
+@@ -6448,7 +6459,7 @@
+       else
+ 	tmp = build_fold_indirect_ref_loc (input_location, dumdesc);
+       tmp = gfc_conv_descriptor_data_get (tmp);
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			     tmp, tmpdesc);
+       stmtCleanup = build3_v (COND_EXPR, tmp, stmtCleanup,
+ 			      build_empty_stmt (input_location));
+@@ -7712,12 +7723,12 @@
+ 	  tmp = build_fold_indirect_ref_loc (input_location,
+ 					 desc);
+ 	  tmp = gfc_conv_array_data (tmp);
+-	  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				 fold_convert (TREE_TYPE (tmp), ptr), tmp);
+ 
+ 	  if (fsym && fsym->attr.optional && sym && sym->attr.optional)
+ 	    tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				   boolean_type_node,
++				   logical_type_node,
+ 				   gfc_conv_expr_present (sym), tmp);
+ 
+ 	  gfc_trans_runtime_check (false, true, tmp, &se->pre,
+@@ -7747,12 +7758,12 @@
+       tmp = build_fold_indirect_ref_loc (input_location,
+ 				     desc);
+       tmp = gfc_conv_array_data (tmp);
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			     fold_convert (TREE_TYPE (tmp), ptr), tmp);
+ 
+       if (fsym && fsym->attr.optional && sym && sym->attr.optional)
+ 	tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-			       boolean_type_node,
++			       logical_type_node,
+ 			       gfc_conv_expr_present (sym), tmp);
+ 
+       tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
+@@ -7891,7 +7902,7 @@
+     null_cond = gfc_conv_descriptor_data_get (src);
+ 
+   null_cond = convert (pvoid_type_node, null_cond);
+-  null_cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  null_cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       null_cond, null_pointer_node);
+   return build3_v (COND_EXPR, null_cond, tmp, null_data);
+ }
+@@ -8025,7 +8036,7 @@
+     null_cond = gfc_conv_descriptor_data_get (src);
+ 
+   null_cond = convert (pvoid_type_node, null_cond);
+-  null_cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  null_cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       null_cond, null_pointer_node);
+   gfc_add_expr_to_block (&globalblock, build3_v (COND_EXPR, null_cond, tmp,
+ 						 null_data));
+@@ -8137,7 +8148,7 @@
+ 
+ 	  null_cond = gfc_conv_descriptor_data_get (decl);
+ 	  null_cond = fold_build2_loc (input_location, NE_EXPR,
+-				       boolean_type_node, null_cond,
++				       logical_type_node, null_cond,
+ 				       build_int_cst (TREE_TYPE (null_cond), 0));
+ 	}
+       else
+@@ -8375,7 +8386,7 @@
+ 							    dealloc_fndecl);
+ 	      tmp = build_int_cst (TREE_TYPE (comp), 0);
+ 	      is_allocated = fold_build2_loc (input_location, NE_EXPR,
+-					      boolean_type_node, tmp,
++					      logical_type_node, tmp,
+ 					      comp);
+ 	      cdesc = gfc_build_addr_expr (NULL_TREE, cdesc);
+ 
+@@ -8655,7 +8666,7 @@
+ 	      null_data = gfc_finish_block (&tmpblock);
+ 
+ 	      null_cond = fold_build2_loc (input_location, NE_EXPR,
+-					   boolean_type_node, src_data,
++					   logical_type_node, src_data,
+ 				           null_pointer_node);
+ 
+ 	      gfc_add_expr_to_block (&fnblock, build3_v (COND_EXPR, null_cond,
+@@ -8830,25 +8841,25 @@
+       lbound = gfc_conv_descriptor_lbound_get (desc, tmp);
+       ubound = gfc_conv_descriptor_ubound_get (desc, tmp);
+       stride = gfc_conv_descriptor_stride_get (desc, tmp);
+-      cond1 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++      cond1 = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 			       ubound, lbound);
+-      cond3 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++      cond3 = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 			       stride, gfc_index_zero_node);
+       cond3 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-			       boolean_type_node, cond3, cond1);
+-      cond4 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++			       logical_type_node, cond3, cond1);
++      cond4 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       stride, gfc_index_zero_node);
+       if (assumed_size)
+-	cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				tmp, build_int_cst (gfc_array_index_type,
+ 						    expr->rank - 1));
+       else
+-	cond = boolean_false_node;
++	cond = logical_false_node;
+ 
+       cond1 = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-			       boolean_type_node, cond3, cond4);
++			       logical_type_node, cond3, cond4);
+       cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-			      boolean_type_node, cond, cond1);
++			      logical_type_node, cond, cond1);
+ 
+       return fold_build3_loc (input_location, COND_EXPR,
+ 			      gfc_array_index_type, cond,
+@@ -9101,11 +9112,11 @@
+   jump_label2 = gfc_build_label_decl (NULL_TREE);
+ 
+   /* Allocate if data is NULL.  */
+-  cond_null = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++  cond_null = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			 array1, build_int_cst (TREE_TYPE (array1), 0));
+ 
+   if (expr1->ts.deferred)
+-    cond_null = gfc_evaluate_now (boolean_true_node, &fblock);
++    cond_null = gfc_evaluate_now (logical_true_node, &fblock);
+   else
+     cond_null= gfc_evaluate_now (cond_null, &fblock);
+ 
+@@ -9145,7 +9156,7 @@
+ 			     gfc_array_index_type,
+ 			     tmp, ubound);
+       cond = fold_build2_loc (input_location, NE_EXPR,
+-			      boolean_type_node,
++			      logical_type_node,
+ 			      tmp, gfc_index_zero_node);
+       tmp = build3_v (COND_EXPR, cond,
+ 		      build1_v (GOTO_EXPR, jump_label1),
+@@ -9195,13 +9206,13 @@
+     }
+   size2 = gfc_evaluate_now (size2, &fblock);
+ 
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			  size1, size2);
+ 
+   /* If the lhs is deferred length, assume that the element size
+      changes and force a reallocation.  */
+   if (expr1->ts.deferred)
+-    neq_size = gfc_evaluate_now (boolean_true_node, &fblock);
++    neq_size = gfc_evaluate_now (logical_true_node, &fblock);
+   else
+     neq_size = gfc_evaluate_now (cond, &fblock);
+ 
+@@ -9481,7 +9492,7 @@
+   /* Malloc if not allocated; realloc otherwise.  */
+   tmp = build_int_cst (TREE_TYPE (array1), 0);
+   cond = fold_build2_loc (input_location, EQ_EXPR,
+-			  boolean_type_node,
++			  logical_type_node,
+ 			  array1, tmp);
+   tmp = build3_v (COND_EXPR, cond, alloc_expr, realloc_expr);
+   gfc_add_expr_to_block (&fblock, tmp);
 Index: gcc/fortran/decl.c
 ===================================================================
 --- a/src/gcc/fortran/decl.c	(.../tags/gcc_7_2_0_release)
@@ -19646,11 +21362,269 @@ Index: gcc/fortran/decl.c
      return false;
  
    /* Check if the name has already been defined as a type.  The
+Index: gcc/fortran/trans-openmp.c
+===================================================================
+--- a/src/gcc/fortran/trans-openmp.c	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/fortran/trans-openmp.c	(.../branches/gcc-7-branch)
+@@ -413,7 +413,7 @@
+ 	    {
+ 	      tem = fold_convert (pvoid_type_node, tem);
+ 	      tem = fold_build2_loc (input_location, NE_EXPR,
+-				     boolean_type_node, tem,
++				     logical_type_node, tem,
+ 				     null_pointer_node);
+ 	      then_b = build3_loc (input_location, COND_EXPR, void_type_node,
+ 				   tem, then_b,
+@@ -540,7 +540,7 @@
+ 			       GFC_DESCRIPTOR_TYPE_P (type)
+ 			       ? gfc_conv_descriptor_data_get (outer) : outer);
+       tem = unshare_expr (tem);
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      tem, null_pointer_node);
+       gfc_add_expr_to_block (&block,
+ 			     build3_loc (input_location, COND_EXPR,
+@@ -646,7 +646,7 @@
+ 		    build_zero_cst (TREE_TYPE (dest)));
+   else_b = gfc_finish_block (&cond_block);
+ 
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			  unshare_expr (srcptr), null_pointer_node);
+   gfc_add_expr_to_block (&block,
+ 			 build3_loc (input_location, COND_EXPR,
+@@ -699,7 +699,7 @@
+ 			       GFC_DESCRIPTOR_TYPE_P (type)
+ 			       ? gfc_conv_descriptor_data_get (dest) : dest);
+       tem = unshare_expr (tem);
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      tem, null_pointer_node);
+       tem = build3_loc (input_location, COND_EXPR, void_type_node, cond,
+ 			then_b, build_empty_stmt (input_location));
+@@ -739,7 +739,7 @@
+   destptr = fold_convert (pvoid_type_node, destptr);
+   gfc_add_modify (&cond_block, ptr, destptr);
+ 
+-  nonalloc = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++  nonalloc = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			      destptr, null_pointer_node);
+   cond = nonalloc;
+   if (GFC_DESCRIPTOR_TYPE_P (type))
+@@ -755,11 +755,11 @@
+ 	  tem = fold_build2_loc (input_location, PLUS_EXPR,
+ 				 gfc_array_index_type, tem,
+ 				 gfc_conv_descriptor_lbound_get (dest, rank));
+-	  tem = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  tem = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				 tem, gfc_conv_descriptor_ubound_get (dest,
+ 								      rank));
+ 	  cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+-				  boolean_type_node, cond, tem);
++				  logical_type_node, cond, tem);
+ 	}
+     }
+ 
+@@ -835,7 +835,7 @@
+ 	}
+       else_b = gfc_finish_block (&cond_block);
+ 
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      unshare_expr (srcptr), null_pointer_node);
+       gfc_add_expr_to_block (&block,
+ 			     build3_loc (input_location, COND_EXPR,
+@@ -1028,7 +1028,7 @@
+ 			  GFC_DESCRIPTOR_TYPE_P (type)
+ 			  ? gfc_conv_descriptor_data_get (decl) : decl);
+       tem = unshare_expr (tem);
+-      tree cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tree cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   tem, null_pointer_node);
+       tem = build3_loc (input_location, COND_EXPR, void_type_node, cond,
+ 			then_b, build_empty_stmt (input_location));
+@@ -1129,7 +1129,7 @@
+ 	  tem = gfc_conv_descriptor_data_get (decl);
+ 	  tem = fold_convert (pvoid_type_node, tem);
+ 	  cond = fold_build2_loc (input_location, NE_EXPR,
+-				  boolean_type_node, tem, null_pointer_node);
++				  logical_type_node, tem, null_pointer_node);
+ 	  gfc_add_expr_to_block (&block, build3_loc (input_location, COND_EXPR,
+ 						     void_type_node, cond,
+ 						     then_b, else_b));
+@@ -2155,7 +2155,7 @@
+ 			  tem = gfc_conv_descriptor_data_get (decl);
+ 			  tem = fold_convert (pvoid_type_node, tem);
+ 			  cond = fold_build2_loc (input_location, NE_EXPR,
+-						  boolean_type_node,
++						  logical_type_node,
+ 						  tem, null_pointer_node);
+ 			  gfc_add_expr_to_block (block,
+ 						 build3_loc (input_location,
+@@ -3596,7 +3596,7 @@
+ 	  /* The condition should not be folded.  */
+ 	  TREE_VEC_ELT (cond, i) = build2_loc (input_location, simple > 0
+ 					       ? LE_EXPR : GE_EXPR,
+-					       boolean_type_node, dovar, to);
++					       logical_type_node, dovar, to);
+ 	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location, PLUS_EXPR,
+ 						    type, dovar, step);
+ 	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location,
+@@ -3623,7 +3623,7 @@
+ 					     build_int_cst (type, 0));
+ 	  /* The condition should not be folded.  */
+ 	  TREE_VEC_ELT (cond, i) = build2_loc (input_location, LT_EXPR,
+-					       boolean_type_node,
++					       logical_type_node,
+ 					       count, tmp);
+ 	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location, PLUS_EXPR,
+ 						    type, count,
 Index: gcc/fortran/ChangeLog
 ===================================================================
 --- a/src/gcc/fortran/ChangeLog	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/ChangeLog	(.../branches/gcc-7-branch)
-@@ -1,3 +1,153 @@
+@@ -1,3 +1,294 @@
++2017-11-13  Paul Thomas  <pault at gcc.gnu.org>
++
++	Backport from trunk
++	PR fortran/82934
++	* trans-stmt.c (gfc_trans_allocate): Remove the gcc_assert on
++	null string length for assumed length typespec and set
++	expr3_esize to NULL_TREE;
++
++2017-11-13  Paul Thomas  <pault at gcc.gnu.org>
++
++	Backport from trunk
++	PR fortran/78619
++	* check.c (same_type_check): Introduce a new argument 'assoc'
++	with default value false. If this is true, use the symbol type
++	spec of BT_PROCEDURE expressions.
++	(gfc_check_associated): Set 'assoc' true in the call to
++	'same_type_check'.
++
++2017-11-13  Janne Blomqvist  <jb at gcc.gnu.org>
++
++	PR 82869
++	* convert.c (truthvalue_conversion): Use logical_type_node.
++	* trans-array.c (gfc_trans_allocate_array_storage): Likewise.
++	(gfc_trans_create_temp_array): Likewise.
++	(gfc_trans_array_ctor_element): Likewise.
++	(gfc_trans_array_constructor_value): Likewise.
++	(trans_array_constructor): Likewise.
++	(trans_array_bound_check): Likewise.
++	(gfc_conv_array_ref): Likewise.
++	(gfc_trans_scalarized_loop_end): Likewise.
++	(gfc_conv_array_extent_dim): Likewise.
++	(gfc_array_init_size): Likewise.
++	(gfc_array_allocate): Likewise.
++	(gfc_trans_array_bounds): Likewise.
++	(gfc_trans_dummy_array_bias): Likewise.
++	(gfc_conv_array_parameter): Likewise.
++	(duplicate_allocatable): Likewise.
++	(duplicate_allocatable_coarray): Likewise.
++	(structure_alloc_comps): Likewise
++	(get_std_lbound): Likewise
++	(gfc_alloc_allocatable_for_assignment): Likewise
++	* trans-decl.c (add_argument_checking): Likewise
++	(gfc_generate_function_code): Likewise
++	* trans-expr.c (gfc_copy_class_to_class): Likewise
++	(gfc_trans_class_array_init_assign): Likewise
++	(gfc_trans_class_init_assign): Likewise
++	(gfc_conv_expr_present): Likewise
++	(gfc_conv_substring): Likewise
++	(gfc_conv_cst_int_power): Likewise
++	(gfc_conv_expr_op): Likewise
++	(gfc_conv_procedure_call): Likewise
++	(fill_with_spaces): Likewise
++	(gfc_trans_string_copy): Likewise
++	(gfc_trans_alloc_subarray_assign): Likewise
++	(gfc_trans_pointer_assignment): Likewise
++	(gfc_trans_scalar_assign): Likewise
++	(fcncall_realloc_result): Likewise
++	(alloc_scalar_allocatable_for_assignment): Likewise
++	(trans_class_assignment): Likewise
++	(gfc_trans_assignment_1): Likewise
++	* trans-intrinsic.c (build_fixbound_expr): Likewise
++	(gfc_conv_intrinsic_aint): Likewise
++	(gfc_trans_same_strlen_check): Likewise
++	(conv_caf_send): Likewise
++	(trans_this_image): Likewise
++	(conv_intrinsic_image_status): Likewise
++	(trans_image_index): Likewise
++	(gfc_conv_intrinsic_bound): Likewise
++	(conv_intrinsic_cobound): Likewise
++	(gfc_conv_intrinsic_mod): Likewise
++	(gfc_conv_intrinsic_dshift): Likewise
++	(gfc_conv_intrinsic_dim): Likewise
++	(gfc_conv_intrinsic_sign): Likewise
++	(gfc_conv_intrinsic_ctime): Likewise
++	(gfc_conv_intrinsic_fdate): Likewise
++	(gfc_conv_intrinsic_ttynam): Likewise
++	(gfc_conv_intrinsic_minmax): Likewise
++	(gfc_conv_intrinsic_minmax_char): Likewise
++	(gfc_conv_intrinsic_anyall): Likewise
++	(gfc_conv_intrinsic_arith): Likewise
++	(gfc_conv_intrinsic_minmaxloc): Likewise
++	(gfc_conv_intrinsic_minmaxval): Likewise
++	(gfc_conv_intrinsic_btest): Likewise
++	(gfc_conv_intrinsic_bitcomp): Likewise
++	(gfc_conv_intrinsic_shift): Likewise
++	(gfc_conv_intrinsic_ishft): Likewise
++	(gfc_conv_intrinsic_ishftc): Likewise
++	(gfc_conv_intrinsic_leadz): Likewise
++	(gfc_conv_intrinsic_trailz): Likewise
++	(gfc_conv_intrinsic_mask): Likewise
++	(gfc_conv_intrinsic_spacing): Likewise
++	(gfc_conv_intrinsic_rrspacing): Likewise
++	(gfc_conv_intrinsic_size): Likewise
++	(gfc_conv_intrinsic_sizeof): Likewise
++	(gfc_conv_intrinsic_transfer): Likewise
++	(gfc_conv_allocated): Likewise
++	(gfc_conv_associated): Likewise
++	(gfc_conv_same_type_as): Likewise
++	(gfc_conv_intrinsic_trim): Likewise
++	(gfc_conv_intrinsic_repeat): Likewise
++	(conv_isocbinding_function): Likewise
++	(conv_intrinsic_ieee_is_normal): Likewise
++	(conv_intrinsic_ieee_is_negative): Likewise
++	(conv_intrinsic_ieee_copy_sign): Likewise
++	(conv_intrinsic_move_alloc): Likewise
++	* trans-io.c (set_parameter_value_chk): Likewise
++	(set_parameter_value_inquire): Likewise
++	(set_string): Likewise
++	* trans-openmp.c (gfc_walk_alloc_comps): Likewise
++	(gfc_omp_clause_default_ctor): Likewise
++	(gfc_omp_clause_copy_ctor): Likewise
++	(gfc_omp_clause_assign_op): Likewise
++	(gfc_omp_clause_dtor): Likewise
++	(gfc_omp_finish_clause): Likewise
++	(gfc_trans_omp_clauses): Likewise
++	(gfc_trans_omp_do): Likewise
++	* trans-stmt.c (gfc_trans_goto): Likewise
++	(gfc_trans_sync): Likewise
++	(gfc_trans_arithmetic_if): Likewise
++	(gfc_trans_simple_do): Likewise
++	(gfc_trans_do): Likewise
++	(gfc_trans_forall_loop): Likewise
++	(gfc_trans_where_2): Likewise
++	(gfc_trans_allocate): Likewise
++	(gfc_trans_deallocate): Likewise
++	* trans-types.c (gfc_init_types): Initialize logical_type_node and
++	their true/false trees.
++	(gfc_get_array_descr_info): Use logical_type_node.
++	* trans-types.h (logical_type_node): New tree.
++	(logical_true_node): Likewise.
++	(logical_false_node): Likewise.
++	* trans.c (gfc_trans_runtime_check): Use logical_type_node.
++	(gfc_call_malloc): Likewise
++	(gfc_allocate_using_malloc): Likewise
++	(gfc_allocate_allocatable): Likewise
++	(gfc_add_comp_finalizer_call): Likewise
++	(gfc_add_finalizer_call): Likewise
++	(gfc_deallocate_with_status): Likewise
++	(gfc_deallocate_scalar_with_status): Likewise
++	(gfc_call_realloc): Likewise
++
 +2017-11-06  Paul Thomas  <pault at gcc.gnu.org>
 +
 +	Backported from trunk
@@ -19808,6 +21782,15 @@ Index: gcc/fortran/trans-stmt.c
 ===================================================================
 --- a/src/gcc/fortran/trans-stmt.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/trans-stmt.c	(.../branches/gcc-7-branch)
+@@ -150,7 +150,7 @@
+   gfc_start_block (&se.pre);
+   gfc_conv_label_variable (&se, code->expr1);
+   tmp = GFC_DECL_STRING_LEN (se.expr);
+-  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
++  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, tmp,
+ 			 build_int_cst (TREE_TYPE (tmp), -1));
+   gfc_trans_runtime_check (true, false, tmp, &se.pre, &loc,
+ 			   "Assigned label is not a target label");
 @@ -452,7 +452,10 @@
  	 subscripts.  This could be prevented in the elemental case
  	 as temporaries are handled separatedly
@@ -19820,6 +21803,241 @@ Index: gcc/fortran/trans-stmt.c
        gfc_mark_ss_chain_used (ss, 1);
  
        /* Convert the arguments, checking for dependencies.  */
+@@ -1103,7 +1106,7 @@
+     {
+       tree cond;
+       if (flag_coarray != GFC_FCOARRAY_LIB)
+-	cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				images, build_int_cst (TREE_TYPE (images), 1));
+       else
+ 	{
+@@ -1111,13 +1114,13 @@
+ 	  tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_num_images,
+ 				     2, integer_zero_node,
+ 				     build_int_cst (integer_type_node, -1));
+-	  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 				  images, tmp);
+-	  cond2 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				   images,
+ 				   build_int_cst (TREE_TYPE (images), 1));
+ 	  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				  boolean_type_node, cond, cond2);
++				  logical_type_node, cond, cond2);
+ 	}
+       gfc_trans_runtime_check (true, false, cond, &se.pre,
+ 			       &code->expr1->where, "Invalid image number "
+@@ -1409,10 +1412,10 @@
+       branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2));
+ 
+       if (code->label1->value != code->label3->value)
+-        tmp = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++        tmp = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       se.expr, zero);
+       else
+-        tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++        tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       se.expr, zero);
+ 
+       branch1 = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+@@ -1426,7 +1429,7 @@
+     {
+       /* if (cond <= 0) take branch1 else take branch2.  */
+       branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3));
+-      tmp = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 			     se.expr, zero);
+       branch1 = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 tmp, branch1, branch2);
+@@ -1910,10 +1913,10 @@
+ 
+   /* Evaluate the loop condition.  */
+   if (is_step_positive)
+-    cond = fold_build2_loc (loc, GT_EXPR, boolean_type_node, dovar,
++    cond = fold_build2_loc (loc, GT_EXPR, logical_type_node, dovar,
+ 			    fold_convert (type, to));
+   else
+-    cond = fold_build2_loc (loc, LT_EXPR, boolean_type_node, dovar,
++    cond = fold_build2_loc (loc, LT_EXPR, logical_type_node, dovar,
+ 			    fold_convert (type, to));
+ 
+   cond = gfc_evaluate_now_loc (loc, cond, &body);
+@@ -1932,7 +1935,7 @@
+       tree boundary = is_step_positive ? TYPE_MAX_VALUE (type)
+ 	: TYPE_MIN_VALUE (type);
+ 
+-      tmp = fold_build2_loc (loc, EQ_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (loc, EQ_EXPR, logical_type_node,
+ 			     dovar, boundary);
+       gfc_trans_runtime_check (true, false, tmp, &body, &code->loc,
+ 			       "Loop iterates infinitely");
+@@ -1952,7 +1955,7 @@
+   /* Check whether someone has modified the loop variable.  */
+   if (gfc_option.rtcheck & GFC_RTCHECK_DO)
+     {
+-      tmp = fold_build2_loc (loc, NE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (loc, NE_EXPR, logical_type_node,
+ 			     dovar, saved_dovar);
+       gfc_trans_runtime_check (true, false, tmp, &body, &code->loc,
+ 			       "Loop variable has been modified");
+@@ -2061,7 +2064,7 @@
+ 
+   if (gfc_option.rtcheck & GFC_RTCHECK_DO)
+     {
+-      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, step,
++      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, step,
+ 			     build_zero_cst (type));
+       gfc_trans_runtime_check (true, false, tmp, &block, &code->loc,
+ 			       "DO step value is zero");
+@@ -2128,7 +2131,7 @@
+ 
+       /* For a positive step, when to < from, exit, otherwise compute
+          countm1 = ((unsigned)to - (unsigned)from) / (unsigned)step  */
+-      tmp = fold_build2_loc (loc, LT_EXPR, boolean_type_node, to, from);
++      tmp = fold_build2_loc (loc, LT_EXPR, logical_type_node, to, from);
+       tmp2 = fold_build2_loc (loc, TRUNC_DIV_EXPR, utype,
+ 			      fold_build2_loc (loc, MINUS_EXPR, utype,
+ 					       tou, fromu),
+@@ -2143,7 +2146,7 @@
+ 
+       /* For a negative step, when to > from, exit, otherwise compute
+          countm1 = ((unsigned)from - (unsigned)to) / -(unsigned)step  */
+-      tmp = fold_build2_loc (loc, GT_EXPR, boolean_type_node, to, from);
++      tmp = fold_build2_loc (loc, GT_EXPR, logical_type_node, to, from);
+       tmp2 = fold_build2_loc (loc, TRUNC_DIV_EXPR, utype,
+ 			      fold_build2_loc (loc, MINUS_EXPR, utype,
+ 					       fromu, tou),
+@@ -2156,7 +2159,7 @@
+ 				build1_loc (loc, GOTO_EXPR, void_type_node,
+ 					    exit_label), NULL_TREE));
+ 
+-      tmp = fold_build2_loc (loc, LT_EXPR, boolean_type_node, step,
++      tmp = fold_build2_loc (loc, LT_EXPR, logical_type_node, step,
+ 			     build_int_cst (TREE_TYPE (step), 0));
+       tmp = fold_build3_loc (loc, COND_EXPR, void_type_node, tmp, neg, pos);
+ 
+@@ -2177,13 +2180,13 @@
+ 
+       /* We need a special check for empty loops:
+ 	 empty = (step > 0 ? to < from : to > from);  */
+-      pos_step = fold_build2_loc (loc, GT_EXPR, boolean_type_node, step,
++      pos_step = fold_build2_loc (loc, GT_EXPR, logical_type_node, step,
+ 				  build_zero_cst (type));
+-      tmp = fold_build3_loc (loc, COND_EXPR, boolean_type_node, pos_step,
++      tmp = fold_build3_loc (loc, COND_EXPR, logical_type_node, pos_step,
+ 			     fold_build2_loc (loc, LT_EXPR,
+-					      boolean_type_node, to, from),
++					      logical_type_node, to, from),
+ 			     fold_build2_loc (loc, GT_EXPR,
+-					      boolean_type_node, to, from));
++					      logical_type_node, to, from));
+       /* If the loop is empty, go directly to the exit label.  */
+       tmp = fold_build3_loc (loc, COND_EXPR, void_type_node, tmp,
+ 			 build1_v (GOTO_EXPR, exit_label),
+@@ -2208,7 +2211,7 @@
+   /* Check whether someone has modified the loop variable.  */
+   if (gfc_option.rtcheck & GFC_RTCHECK_DO)
+     {
+-      tmp = fold_build2_loc (loc, NE_EXPR, boolean_type_node, dovar,
++      tmp = fold_build2_loc (loc, NE_EXPR, logical_type_node, dovar,
+ 			     saved_dovar);
+       gfc_trans_runtime_check (true, false, tmp, &body, &code->loc,
+ 			       "Loop variable has been modified");
+@@ -2241,7 +2244,7 @@
+   gfc_add_modify_loc (loc, &body, countm1, tmp);
+ 
+   /* End with the loop condition.  Loop until countm1t == 0.  */
+-  cond = fold_build2_loc (loc, EQ_EXPR, boolean_type_node, countm1t,
++  cond = fold_build2_loc (loc, EQ_EXPR, logical_type_node, countm1t,
+ 			  build_int_cst (utype, 0));
+   tmp = fold_build1_loc (loc, GOTO_EXPR, void_type_node, exit_label);
+   tmp = fold_build3_loc (loc, COND_EXPR, void_type_node,
+@@ -3395,7 +3398,7 @@
+       gfc_init_block (&block);
+ 
+       /* The exit condition.  */
+-      cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 			      count, build_int_cst (TREE_TYPE (count), 0));
+       if (forall_tmp->do_concurrent)
+ 	cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
+@@ -5073,7 +5076,7 @@
+ 					  &inner_size_body, block);
+ 
+       /* Check whether the size is negative.  */
+-      cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, size,
++      cond = fold_build2_loc (input_location, LE_EXPR, logical_type_node, size,
+ 			      gfc_index_zero_node);
+       size = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
+ 			      cond, gfc_index_zero_node, size);
+@@ -5857,10 +5860,9 @@
+       if (code->ext.alloc.ts.type != BT_CHARACTER)
+ 	expr3_esize = TYPE_SIZE_UNIT (
+ 	      gfc_typenode_for_spec (&code->ext.alloc.ts));
+-      else
++      else if (code->ext.alloc.ts.u.cl->length != NULL)
+ 	{
+ 	  gfc_expr *sz;
+-	  gcc_assert (code->ext.alloc.ts.u.cl->length != NULL);
+ 	  sz = gfc_copy_expr (code->ext.alloc.ts.u.cl->length);
+ 	  gfc_init_se (&se_sz, NULL);
+ 	  gfc_conv_expr (&se_sz, sz);
+@@ -5874,6 +5876,8 @@
+ 					 tmp, se_sz.expr);
+ 	  expr3_esize = gfc_evaluate_now (expr3_esize, &block);
+ 	}
++      else
++	expr3_esize = NULL_TREE;
+     }
+ 
+   /* The routine gfc_trans_assignment () already implements all
+@@ -6078,7 +6082,7 @@
+ 		     polymorphic and stores a _len dependent object,
+ 		     e.g., a string.  */
+ 		  memsz = fold_build2_loc (input_location, GT_EXPR,
+-					   boolean_type_node, expr3_len,
++					   logical_type_node, expr3_len,
+ 					   integer_zero_node);
+ 		  memsz = fold_build3_loc (input_location, COND_EXPR,
+ 					 TREE_TYPE (expr3_esize),
+@@ -6211,7 +6215,7 @@
+ 	{
+ 	  tmp = build1_v (GOTO_EXPR, label_errmsg);
+ 	  parm = fold_build2_loc (input_location, NE_EXPR,
+-				  boolean_type_node, stat,
++				  logical_type_node, stat,
+ 				  build_int_cst (TREE_TYPE (stat), 0));
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 gfc_unlikely (parm, PRED_FORTRAN_FAIL_ALLOC),
+@@ -6430,7 +6434,7 @@
+ 			     gfc_default_character_kind);
+       dlen = gfc_finish_block (&errmsg_block);
+ 
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			     stat, build_int_cst (TREE_TYPE (stat), 0));
+ 
+       tmp = build3_v (COND_EXPR, tmp,
+@@ -6668,7 +6672,7 @@
+ 	{
+           tree cond;
+ 
+-	  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, stat,
++	  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, stat,
+ 				  build_int_cst (TREE_TYPE (stat), 0));
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 gfc_unlikely (cond, PRED_FORTRAN_FAIL_ALLOC),
+@@ -6708,7 +6712,7 @@
+ 			     slen, errmsg_str, gfc_default_character_kind);
+       tmp = gfc_finish_block (&errmsg_block);
+ 
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, stat,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, stat,
+ 			     build_int_cst (TREE_TYPE (stat), 0));
+       tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 			     gfc_unlikely (cond, PRED_FORTRAN_FAIL_ALLOC), tmp,
 Index: gcc/fortran/expr.c
 ===================================================================
 --- a/src/gcc/fortran/expr.c	(.../tags/gcc_7_2_0_release)
@@ -19867,6 +22085,268 @@ Index: gcc/fortran/trans.c
    else
      span = NULL_TREE;
  
+@@ -526,9 +533,9 @@
+ 
+   if (once)
+     {
+-       tmpvar = gfc_create_var (boolean_type_node, "print_warning");
++       tmpvar = gfc_create_var (logical_type_node, "print_warning");
+        TREE_STATIC (tmpvar) = 1;
+-       DECL_INITIAL (tmpvar) = boolean_true_node;
++       DECL_INITIAL (tmpvar) = logical_true_node;
+        gfc_add_expr_to_block (pblock, tmpvar);
+     }
+ 
+@@ -547,7 +554,7 @@
+   va_end (ap);
+ 
+   if (once)
+-    gfc_add_modify (&block, tmpvar, boolean_false_node);
++    gfc_add_modify (&block, tmpvar, logical_false_node);
+ 
+   body = gfc_finish_block (&block);
+ 
+@@ -600,7 +607,7 @@
+   if (gfc_option.rtcheck & GFC_RTCHECK_MEM)
+     {
+       null_result = fold_build2_loc (input_location, EQ_EXPR,
+-				     boolean_type_node, res,
++				     logical_type_node, res,
+ 				     build_int_cst (pvoid_type_node, 0));
+       msg = gfc_build_addr_expr (pchar_type_node,
+ 	      gfc_build_localized_cstring_const ("Memory allocation failed"));
+@@ -686,7 +693,7 @@
+     }
+ 
+   error_cond = fold_build2_loc (input_location, EQ_EXPR,
+-				boolean_type_node, pointer,
++				logical_type_node, pointer,
+ 				build_int_cst (prvoid_type_node, 0));
+   tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 			 gfc_unlikely (error_cond, PRED_FORTRAN_FAIL_ALLOC),
+@@ -788,7 +795,7 @@
+ 
+   size = fold_convert (size_type_node, size);
+   null_mem = gfc_unlikely (fold_build2_loc (input_location, NE_EXPR,
+-					    boolean_type_node, mem,
++					    logical_type_node, mem,
+ 					    build_int_cst (type, 0)),
+ 			   PRED_FORTRAN_REALLOC);
+ 
+@@ -866,7 +873,7 @@
+ 	{
+ 	  TREE_USED (label_finish) = 1;
+ 	  tmp = build1_v (GOTO_EXPR, label_finish);
+-	  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				  status, build_zero_cst (TREE_TYPE (status)));
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 gfc_unlikely (cond, PRED_FORTRAN_FAIL_ALLOC),
+@@ -1083,12 +1090,12 @@
+     {
+       tmp = GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (array))
+ 	    ?  gfc_conv_descriptor_data_get (array) : array;
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			    tmp, fold_convert (TREE_TYPE (tmp),
+ 						 null_pointer_node));
+     }
+   else
+-    cond = boolean_true_node;
++    cond = logical_true_node;
+ 
+   if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (array)))
+     {
+@@ -1104,12 +1111,12 @@
+ 
+   if (!final_expr)
+     {
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			     final_fndecl,
+ 			     fold_convert (TREE_TYPE (final_fndecl),
+ 					   null_pointer_node));
+       cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-			      boolean_type_node, cond, tmp);
++			      logical_type_node, cond, tmp);
+     }
+ 
+   if (POINTER_TYPE_P (TREE_TYPE (final_fndecl)))
+@@ -1205,7 +1212,7 @@
+       gfc_init_se (&se, NULL);
+       se.want_pointer = 1;
+       gfc_conv_expr (&se, final_expr);
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      se.expr, build_int_cst (TREE_TYPE (se.expr), 0));
+ 
+       /* For CLASS(*) not only sym->_vtab->_final can be NULL
+@@ -1223,11 +1230,11 @@
+ 	  gfc_conv_expr (&se, vptr_expr);
+ 	  gfc_free_expr (vptr_expr);
+ 
+-	  cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   se.expr,
+ 				   build_int_cst (TREE_TYPE (se.expr), 0));
+ 	  cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-				  boolean_type_node, cond2, cond);
++				  logical_type_node, cond2, cond);
+ 	}
+ 
+       tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+@@ -1333,7 +1340,7 @@
+   else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
+     pointer = gfc_conv_descriptor_data_get (pointer);
+ 
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pointer,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, pointer,
+ 			  build_int_cst (TREE_TYPE (pointer), 0));
+ 
+   /* When POINTER is NULL, we set STATUS to 1 if it's present, otherwise
+@@ -1360,7 +1367,7 @@
+       tree cond2;
+ 
+       status_type = TREE_TYPE (TREE_TYPE (status));
+-      cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       status, build_int_cst (TREE_TYPE (status), 0));
+       tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+ 			     fold_build1_loc (input_location, INDIRECT_REF,
+@@ -1393,7 +1400,7 @@
+ 	  tree status_type = TREE_TYPE (TREE_TYPE (status));
+ 	  tree cond2;
+ 
+-	  cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   status,
+ 				   build_int_cst (TREE_TYPE (status), 0));
+ 	  tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+@@ -1456,7 +1463,7 @@
+ 
+ 	  TREE_USED (label_finish) = 1;
+ 	  tmp = build1_v (GOTO_EXPR, label_finish);
+-	  cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   stat, build_zero_cst (TREE_TYPE (stat)));
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 gfc_unlikely (cond2, PRED_FORTRAN_REALLOC),
+@@ -1492,7 +1499,7 @@
+       && comp_ref)
+     caf_dereg_type = GFC_CAF_COARRAY_DEALLOCATE_ONLY;
+ 
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pointer,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, pointer,
+ 			  build_int_cst (TREE_TYPE (pointer), 0));
+ 
+   /* When POINTER is NULL, we set STATUS to 1 if it's present, otherwise
+@@ -1519,7 +1526,7 @@
+       tree status_type = TREE_TYPE (TREE_TYPE (status));
+       tree cond2;
+ 
+-      cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       status, build_int_cst (TREE_TYPE (status), 0));
+       tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+ 			     fold_build1_loc (input_location, INDIRECT_REF,
+@@ -1564,7 +1571,7 @@
+ 	  tree status_type = TREE_TYPE (TREE_TYPE (status));
+ 	  tree cond2;
+ 
+-	  cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   status,
+ 				   build_int_cst (TREE_TYPE (status), 0));
+ 	  tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+@@ -1614,7 +1621,7 @@
+ 
+ 	  TREE_USED (label_finish) = 1;
+ 	  tmp = build1_v (GOTO_EXPR, label_finish);
+-	  cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  cond2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				   stat, build_zero_cst (TREE_TYPE (stat)));
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 gfc_unlikely (cond2, PRED_FORTRAN_REALLOC),
+@@ -1657,11 +1664,11 @@
+ 			 builtin_decl_explicit (BUILT_IN_REALLOC), 2,
+ 			 fold_convert (pvoid_type_node, mem), size);
+   gfc_add_modify (block, res, fold_convert (type, tmp));
+-  null_result = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++  null_result = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				 res, build_int_cst (pvoid_type_node, 0));
+-  nonzero = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, size,
++  nonzero = fold_build2_loc (input_location, NE_EXPR, logical_type_node, size,
+ 			     build_int_cst (size_type_node, 0));
+-  null_result = fold_build2_loc (input_location, TRUTH_AND_EXPR, boolean_type_node,
++  null_result = fold_build2_loc (input_location, TRUTH_AND_EXPR, logical_type_node,
+ 				 null_result, nonzero);
+   msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
+ 			     ("Allocation would exceed memory limit"));
+Index: gcc/fortran/trans-types.c
+===================================================================
+--- a/src/gcc/fortran/trans-types.c	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/fortran/trans-types.c	(.../branches/gcc-7-branch)
+@@ -60,6 +60,9 @@
+ tree pchar_type_node;
+ tree pfunc_type_node;
+ 
++tree logical_type_node;
++tree logical_true_node;
++tree logical_false_node;
+ tree gfc_charlen_type_node;
+ 
+ tree gfc_float128_type_node = NULL_TREE;
+@@ -976,6 +979,11 @@
+ 			wi::mask (n, UNSIGNED,
+ 				  TYPE_PRECISION (size_type_node)));
+ 
++
++  logical_type_node = gfc_get_logical_type (gfc_default_logical_kind);
++  logical_true_node = build_int_cst (logical_type_node, 1);
++  logical_false_node = build_int_cst (logical_type_node, 0);
++
+   /* ??? Shouldn't this be based on gfc_index_integer_kind or so?  */
+   gfc_charlen_int_kind = 4;
+   gfc_charlen_type_node = gfc_get_int_type (gfc_charlen_int_kind);
+@@ -3228,11 +3236,11 @@
+   t = build1 (NOP_EXPR, build_pointer_type (ptr_type_node), t);
+   info->data_location = build1 (INDIRECT_REF, ptr_type_node, t);
+   if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE)
+-    info->allocated = build2 (NE_EXPR, boolean_type_node,
++    info->allocated = build2 (NE_EXPR, logical_type_node,
+ 			      info->data_location, null_pointer_node);
+   else if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+ 	   || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT)
+-    info->associated = build2 (NE_EXPR, boolean_type_node,
++    info->associated = build2 (NE_EXPR, logical_type_node,
+ 			       info->data_location, null_pointer_node);
+   if ((GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ASSUMED_RANK
+        || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ASSUMED_RANK_CONT)
+Index: gcc/fortran/trans-types.h
+===================================================================
+--- a/src/gcc/fortran/trans-types.h	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/fortran/trans-types.h	(.../branches/gcc-7-branch)
+@@ -33,6 +33,20 @@
+ extern GTY(()) tree gfc_float128_type_node;
+ extern GTY(()) tree gfc_complex_float128_type_node;
+ 
++/* logical_type_node is the Fortran LOGICAL type of default kind.  In
++   addition to uses mandated by the Fortran standard, also prefer it
++   for compiler generated temporary variables, is it avoids some minor
++   issues with boolean_type_node (the C/C++ _Bool/bool). Namely:
++   - On x86, partial register stalls with 8/16 bit register access,
++     and length prefix changes.
++   - On s390 there is a compare with immediate and jump instruction,
++     but it works only with 32-bit quantities and not 8-bit such as
++     boolean_type_node.
++*/
++extern GTY(()) tree logical_type_node;
++extern GTY(()) tree logical_true_node;
++extern GTY(()) tree logical_false_node;
++
+ /* This is the type used to hold the lengths of character variables.
+    It must be the same as the corresponding definition in gfortran.h.  */
+ /* TODO: This is still hardcoded as kind=4 in some bits of the compiler
 Index: gcc/fortran/resolve.c
 ===================================================================
 --- a/src/gcc/fortran/resolve.c	(.../tags/gcc_7_2_0_release)
@@ -20046,6 +22526,64 @@ Index: gcc/fortran/trans-decl.c
  
  	      /* Deallocate when leaving the scope. Nullifying is not
  		 needed.  */
+@@ -5695,7 +5698,7 @@
+ 	/* Build the condition.  For optional arguments, an actual length
+ 	   of 0 is also acceptable if the associated string is NULL, which
+ 	   means the argument was not passed.  */
+-	cond = fold_build2_loc (input_location, comparison, boolean_type_node,
++	cond = fold_build2_loc (input_location, comparison, logical_type_node,
+ 				cl->passed_length, cl->backend_decl);
+ 	if (fsym->attr.optional)
+ 	  {
+@@ -5704,7 +5707,7 @@
+ 	    tree absent_failed;
+ 
+ 	    not_0length = fold_build2_loc (input_location, NE_EXPR,
+-					   boolean_type_node,
++					   logical_type_node,
+ 					   cl->passed_length,
+ 					   build_zero_cst (gfc_charlen_type_node));
+ 	    /* The symbol needs to be referenced for gfc_get_symbol_decl.  */
+@@ -5712,11 +5715,11 @@
+ 	    not_absent = gfc_conv_expr_present (fsym);
+ 
+ 	    absent_failed = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-					     boolean_type_node, not_0length,
++					     logical_type_node, not_0length,
+ 					     not_absent);
+ 
+ 	    cond = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				    boolean_type_node, cond, absent_failed);
++				    logical_type_node, cond, absent_failed);
+ 	  }
+ 
+ 	/* Build the runtime check.  */
+@@ -6287,13 +6290,13 @@
+ 
+       msg = xasprintf ("Recursive call to nonrecursive procedure '%s'",
+ 		       sym->name);
+-      recurcheckvar = gfc_create_var (boolean_type_node, "is_recursive");
++      recurcheckvar = gfc_create_var (logical_type_node, "is_recursive");
+       TREE_STATIC (recurcheckvar) = 1;
+-      DECL_INITIAL (recurcheckvar) = boolean_false_node;
++      DECL_INITIAL (recurcheckvar) = logical_false_node;
+       gfc_add_expr_to_block (&init, recurcheckvar);
+       gfc_trans_runtime_check (true, false, recurcheckvar, &init,
+ 			       &sym->declared_at, msg);
+-      gfc_add_modify (&init, recurcheckvar, boolean_true_node);
++      gfc_add_modify (&init, recurcheckvar, logical_true_node);
+       free (msg);
+     }
+ 
+@@ -6422,7 +6425,7 @@
+   if ((gfc_option.rtcheck & GFC_RTCHECK_RECURSION)
+       && !is_recursive && !flag_openmp && recurcheckvar != NULL_TREE)
+     {
+-      gfc_add_modify (&cleanup, recurcheckvar, boolean_false_node);
++      gfc_add_modify (&cleanup, recurcheckvar, logical_false_node);
+       recurcheckvar = NULL;
+     }
+ 
 Index: gcc/fortran/match.c
 ===================================================================
 --- a/src/gcc/fortran/match.c	(.../tags/gcc_7_2_0_release)
@@ -20072,6 +22610,54 @@ Index: gcc/fortran/trans-io.c
 ===================================================================
 --- a/src/gcc/fortran/trans-io.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/trans-io.c	(.../branches/gcc-7-branch)
+@@ -581,7 +581,7 @@
+       /* UNIT numbers should be greater than the min.  */
+       i = gfc_validate_kind (BT_INTEGER, 4, false);
+       val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].pedantic_min_int, 4);
+-      cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			      se.expr,
+ 			      fold_convert (TREE_TYPE (se.expr), val));
+       gfc_trans_io_runtime_check (has_iostat, cond, var, LIBERROR_BAD_UNIT,
+@@ -590,7 +590,7 @@
+ 
+       /* UNIT numbers should be less than the max.  */
+       val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
+-      cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			      se.expr,
+ 			      fold_convert (TREE_TYPE (se.expr), val));
+       gfc_trans_io_runtime_check (has_iostat, cond, var, LIBERROR_BAD_UNIT,
+@@ -641,17 +641,17 @@
+ 
+       /* UNIT numbers should be greater than zero.  */
+       i = gfc_validate_kind (BT_INTEGER, 4, false);
+-      cond1 = build2_loc (input_location, LT_EXPR, boolean_type_node,
++      cond1 = build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			  se.expr,
+ 			  fold_convert (TREE_TYPE (se.expr),
+ 			  integer_zero_node));
+       /* UNIT numbers should be less than the max.  */
+       val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
+-      cond2 = build2_loc (input_location, GT_EXPR, boolean_type_node,
++      cond2 = build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  se.expr,
+ 			  fold_convert (TREE_TYPE (se.expr), val));
+       cond3 = build2_loc (input_location, TRUTH_OR_EXPR,
+-			  boolean_type_node, cond1, cond2);
++			  logical_type_node, cond1, cond2);
+ 
+       gfc_start_block (&newblock);
+ 
+@@ -826,7 +826,7 @@
+ 
+       gfc_conv_label_variable (&se, e);
+       tmp = GFC_DECL_STRING_LEN (se.expr);
+-      cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			      tmp, build_int_cst (TREE_TYPE (tmp), 0));
+ 
+       msg = xasprintf ("Label assigned to variable '%s' (%%ld) is not a format "
 @@ -2214,19 +2214,25 @@
    bool formatted = false;
    gfc_dt *dt = code->ext.dt;
@@ -20112,7 +22698,44 @@ Index: gcc/fortran/check.c
 ===================================================================
 --- a/src/gcc/fortran/check.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/check.c	(.../branches/gcc-7-branch)
-@@ -1731,7 +1731,7 @@
+@@ -427,15 +427,22 @@
+ /* Make sure two expressions have the same type.  */
+ 
+ static bool
+-same_type_check (gfc_expr *e, int n, gfc_expr *f, int m)
++same_type_check (gfc_expr *e, int n, gfc_expr *f, int m, bool assoc = false)
+ {
+   gfc_typespec *ets = &e->ts;
+   gfc_typespec *fts = &f->ts;
+ 
+-  if (e->ts.type == BT_PROCEDURE && e->symtree->n.sym)
+-    ets = &e->symtree->n.sym->ts;
+-  if (f->ts.type == BT_PROCEDURE && f->symtree->n.sym)
+-    fts = &f->symtree->n.sym->ts;
++  if (assoc)
++    {
++      /* Procedure pointer component expressions have the type of the interface
++	 procedure. If they are being tested for association with a procedure
++	 pointer (ie. not a component), the type of the procedure must be
++	 determined.  */
++      if (e->ts.type == BT_PROCEDURE && e->symtree->n.sym)
++	ets = &e->symtree->n.sym->ts;
++      if (f->ts.type == BT_PROCEDURE && f->symtree->n.sym)
++	fts = &f->symtree->n.sym->ts;
++    }
+ 
+   if (gfc_compare_types (ets, fts))
+     return true;
+@@ -1002,7 +1009,7 @@
+     }
+ 
+   t = true;
+-  if (!same_type_check (pointer, 0, target, 1))
++  if (!same_type_check (pointer, 0, target, 1, true))
+     t = false;
+   if (!rank_check (target, 0, pointer->rank))
+     t = false;
+@@ -1731,7 +1738,7 @@
  
    if (!gfc_compare_types (&a->ts, &sym->result->ts))
      {
@@ -20121,6 +22744,62 @@ Index: gcc/fortran/check.c
  		 "OPERATOR at %L returns %s",
  		 &a->where, gfc_typename (&a->ts), &op->where,
  		 gfc_typename (&sym->result->ts));
+Index: gcc/fortran/convert.c
+===================================================================
+--- a/src/gcc/fortran/convert.c	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/fortran/convert.c	(.../branches/gcc-7-branch)
+@@ -29,10 +29,14 @@
+ #include "fold-const.h"
+ #include "convert.h"
+ 
++#include "gfortran.h"
++#include "trans.h"
++#include "trans-types.h"
++
+ /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
+    or validate its data type for a GIMPLE `if' or `while' statement.
+ 
+-   The resulting type should always be `boolean_type_node'.  */
++   The resulting type should always be `logical_type_node'.  */
+ 
+ static tree
+ truthvalue_conversion (tree expr)
+@@ -40,25 +44,29 @@
+   switch (TREE_CODE (TREE_TYPE (expr)))
+     {
+     case BOOLEAN_TYPE:
+-      if (TREE_TYPE (expr) == boolean_type_node)
++      if (TREE_TYPE (expr) == logical_type_node)
+ 	return expr;
+       else if (COMPARISON_CLASS_P (expr))
+ 	{
+-	  TREE_TYPE (expr) = boolean_type_node;
++	  TREE_TYPE (expr) = logical_type_node;
+ 	  return expr;
+ 	}
+       else if (TREE_CODE (expr) == NOP_EXPR)
+         return fold_build1_loc (input_location, NOP_EXPR,
+-			    boolean_type_node, TREE_OPERAND (expr, 0));
++				logical_type_node,
++				TREE_OPERAND (expr, 0));
+       else
+-        return fold_build1_loc (input_location, NOP_EXPR, boolean_type_node,
++        return fold_build1_loc (input_location, NOP_EXPR,
++				logical_type_node,
+ 				expr);
+ 
+     case INTEGER_TYPE:
+       if (TREE_CODE (expr) == INTEGER_CST)
+-	return integer_zerop (expr) ? boolean_false_node : boolean_true_node;
++	return integer_zerop (expr) ? logical_false_node
++	  : logical_true_node;
+       else
+-        return fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++        return fold_build2_loc (input_location, NE_EXPR,
++				logical_type_node,
+ 				expr, build_int_cst (TREE_TYPE (expr), 0));
+ 
+     default:
 Index: gcc/fortran/primary.c
 ===================================================================
 --- a/src/gcc/fortran/primary.c	(.../tags/gcc_7_2_0_release)
@@ -20257,6 +22936,42 @@ Index: gcc/fortran/trans-intrinsic.c
 ===================================================================
 --- a/src/gcc/fortran/trans-intrinsic.c	(.../tags/gcc_7_2_0_release)
 +++ b/src/gcc/fortran/trans-intrinsic.c	(.../branches/gcc-7-branch)
+@@ -358,7 +358,7 @@
+ 
+   tmp = convert (argtype, intval);
+   cond = fold_build2_loc (input_location, up ? GE_EXPR : LE_EXPR,
+-			  boolean_type_node, tmp, arg);
++			  logical_type_node, tmp, arg);
+ 
+   tmp = fold_build2_loc (input_location, up ? PLUS_EXPR : MINUS_EXPR, type,
+ 			 intval, build_int_cst (type, 1));
+@@ -490,14 +490,14 @@
+   n = gfc_validate_kind (BT_INTEGER, kind, false);
+   mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE);
+   tmp = gfc_conv_mpfr_to_tree (huge, kind, 0);
+-  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, arg[0],
++  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node, arg[0],
+ 			  tmp);
+ 
+   mpfr_neg (huge, huge, GFC_RND_MODE);
+   tmp = gfc_conv_mpfr_to_tree (huge, kind, 0);
+-  tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, arg[0],
++  tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node, arg[0],
+ 			 tmp);
+-  cond = fold_build2_loc (input_location, TRUTH_AND_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, TRUTH_AND_EXPR, logical_type_node,
+ 			  cond, tmp);
+   itype = gfc_get_int_type (kind);
+ 
+@@ -885,7 +885,7 @@
+     return;
+ 
+   /* Compare the two string lengths.  */
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, a, b);
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, a, b);
+ 
+   /* Output the runtime-check.  */
+   name = gfc_build_cstring_const (intr_name);
 @@ -1872,12 +1872,21 @@
    gfc_init_se (&lhs_se, NULL);
    if (lhs_expr->rank == 0)
@@ -20285,6 +23000,950 @@ Index: gcc/fortran/trans-intrinsic.c
      }
    else if ((lhs_caf_attr.alloc_comp || lhs_caf_attr.pointer_comp)
  	   && lhs_caf_attr.codimension)
+@@ -1953,7 +1962,7 @@
+ 				    TYPE_SIZE_UNIT (
+ 				       gfc_typenode_for_spec (&lhs_expr->ts)),
+ 				    NULL_TREE);
+-	  tmp = fold_build2 (EQ_EXPR, boolean_type_node, scal_se.expr,
++	  tmp = fold_build2 (EQ_EXPR, logical_type_node, scal_se.expr,
+ 			     null_pointer_node);
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ 				 tmp, gfc_finish_block (&scal_se.pre),
+@@ -2245,14 +2254,14 @@
+      else if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+ 	{
+ 	  dim_arg = gfc_evaluate_now (dim_arg, &se->pre);
+-	  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  dim_arg,
+ 				  build_int_cst (TREE_TYPE (dim_arg), 1));
+ 	  tmp = gfc_rank_cst[GFC_TYPE_ARRAY_CORANK (TREE_TYPE (desc))];
+-	  tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 				 dim_arg, tmp);
+ 	  cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+-				  boolean_type_node, cond, tmp);
++				  logical_type_node, cond, tmp);
+ 	  gfc_trans_runtime_check (true, false, cond, &se->pre, &expr->where,
+ 			           gfc_msg_fault);
+ 	}
+@@ -2343,7 +2352,7 @@
+ 			  m, extent));
+ 
+   /* Exit condition:  if (i >= min_var) goto exit_label.  */
+-  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, loop_var,
++  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node, loop_var,
+ 		  min_var);
+   tmp = build1_v (GOTO_EXPR, exit_label);
+   tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp,
+@@ -2368,7 +2377,7 @@
+   /*  sub(co_dim) = (co_dim < corank) ? ml - m*extent + lcobound(dim_arg)
+ 				      : m + lcobound(corank) */
+ 
+-  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, dim_arg,
++  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node, dim_arg,
+ 			  build_int_cst (TREE_TYPE (dim_arg), corank));
+ 
+   lbound = gfc_conv_descriptor_lbound_get (desc,
+@@ -2406,7 +2415,7 @@
+     {
+       tree arg;
+       arg = gfc_evaluate_now (args[0], &se->pre);
+-      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			     fold_convert (integer_type_node, arg),
+ 			     integer_one_node);
+       tmp = fold_build3_loc (input_location, COND_EXPR, integer_type_node,
+@@ -2457,7 +2466,7 @@
+ 
+   lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[rank+corank-1]);
+   tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[corank-1], NULL);
+-  invalid_bound = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++  invalid_bound = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				 fold_convert (gfc_array_index_type, tmp),
+ 				 lbound);
+ 
+@@ -2466,16 +2475,16 @@
+       lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[codim]);
+       ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[codim]);
+       tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[codim-rank], NULL);
+-      cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			      fold_convert (gfc_array_index_type, tmp),
+ 			      lbound);
+       invalid_bound = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				       boolean_type_node, invalid_bound, cond);
+-      cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++				       logical_type_node, invalid_bound, cond);
++      cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			      fold_convert (gfc_array_index_type, tmp),
+ 			      ubound);
+       invalid_bound = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				       boolean_type_node, invalid_bound, cond);
++				       logical_type_node, invalid_bound, cond);
+     }
+ 
+   invalid_bound = gfc_unlikely (invalid_bound, PRED_FORTRAN_INVALID_BOUND);
+@@ -2535,11 +2544,11 @@
+   tmp = gfc_create_var (type, NULL);
+   gfc_add_modify (&se->pre, tmp, coindex);
+ 
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, tmp,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node, tmp,
+ 			  num_images);
+-  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR, logical_type_node,
+ 			  cond,
+-			  fold_convert (boolean_type_node, invalid_bound));
++			  fold_convert (logical_type_node, invalid_bound));
+   se->expr = fold_build3_loc (input_location, COND_EXPR, type, cond,
+ 			      build_int_cst (type, 0), tmp);
+ }
+@@ -2670,16 +2679,16 @@
+       if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+         {
+           bound = gfc_evaluate_now (bound, &se->pre);
+-          cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++          cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  bound, build_int_cst (TREE_TYPE (bound), 0));
+ 	  if (as && as->type == AS_ASSUMED_RANK)
+ 	    tmp = gfc_conv_descriptor_rank (desc);
+ 	  else
+ 	    tmp = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (TREE_TYPE (desc))];
+-          tmp = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++          tmp = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 				 bound, fold_convert(TREE_TYPE (bound), tmp));
+           cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+-				  boolean_type_node, cond, tmp);
++				  logical_type_node, cond, tmp);
+           gfc_trans_runtime_check (true, false, cond, &se->pre, &expr->where,
+ 				   gfc_msg_fault);
+         }
+@@ -2725,13 +2734,13 @@
+     {
+       tree stride = gfc_conv_descriptor_stride_get (desc, bound);
+ 
+-      cond1 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++      cond1 = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 			       ubound, lbound);
+-      cond3 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++      cond3 = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 			       stride, gfc_index_zero_node);
+       cond3 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-			       boolean_type_node, cond3, cond1);
+-      cond4 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++			       logical_type_node, cond3, cond1);
++      cond4 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 			       stride, gfc_index_zero_node);
+ 
+       if (upper)
+@@ -2738,14 +2747,14 @@
+ 	{
+ 	  tree cond5;
+ 	  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				  boolean_type_node, cond3, cond4);
+-	  cond5 = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++				  logical_type_node, cond3, cond4);
++	  cond5 = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				   gfc_index_one_node, lbound);
+ 	  cond5 = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				   boolean_type_node, cond4, cond5);
++				   logical_type_node, cond4, cond5);
+ 
+ 	  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				  boolean_type_node, cond, cond5);
++				  logical_type_node, cond, cond5);
+ 
+ 	  if (assumed_rank_lb_one)
+ 	    {
+@@ -2764,16 +2773,16 @@
+       else
+ 	{
+ 	  if (as->type == AS_ASSUMED_SIZE)
+-	    cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	    cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				    bound, build_int_cst (TREE_TYPE (bound),
+ 							  arg->expr->rank - 1));
+ 	  else
+-	    cond = boolean_false_node;
++	    cond = logical_false_node;
+ 
+ 	  cond1 = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				   boolean_type_node, cond3, cond4);
++				   logical_type_node, cond3, cond4);
+ 	  cond = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				  boolean_type_node, cond, cond1);
++				  logical_type_node, cond, cond1);
+ 
+ 	  se->expr = fold_build3_loc (input_location, COND_EXPR,
+ 				      gfc_array_index_type, cond,
+@@ -2863,13 +2872,13 @@
+       else if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+         {
+ 	  bound = gfc_evaluate_now (bound, &se->pre);
+-	  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  bound, build_int_cst (TREE_TYPE (bound), 1));
+ 	  tmp = gfc_rank_cst[GFC_TYPE_ARRAY_CORANK (TREE_TYPE (desc))];
+-	  tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 				 bound, tmp);
+ 	  cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+-				  boolean_type_node, cond, tmp);
++				  logical_type_node, cond, tmp);
+ 	  gfc_trans_runtime_check (true, false, cond, &se->pre, &expr->where,
+ 				   gfc_msg_fault);
+ 	}
+@@ -2938,7 +2947,7 @@
+ 
+       if (corank > 1)
+ 	{
+-	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				  bound,
+ 				  build_int_cst (TREE_TYPE (bound),
+ 						 arg->expr->rank + corank - 1));
+@@ -3127,16 +3136,16 @@
+       tmp = gfc_evaluate_now (se->expr, &se->pre);
+       if (!flag_signed_zeros)
+ 	{
+-	  test = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  test = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  args[0], zero);
+-	  test2 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  test2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				   args[1], zero);
+ 	  test2 = fold_build2_loc (input_location, TRUTH_XOR_EXPR,
+-				   boolean_type_node, test, test2);
+-	  test = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++				   logical_type_node, test, test2);
++	  test = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				  tmp, zero);
+ 	  test = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				  boolean_type_node, test, test2);
++				  logical_type_node, test, test2);
+ 	  test = gfc_evaluate_now (test, &se->pre);
+ 	  se->expr = fold_build3_loc (input_location, COND_EXPR, type, test,
+ 				      fold_build2_loc (input_location,
+@@ -3149,18 +3158,18 @@
+ 	  tree expr1, copysign, cscall;
+ 	  copysign = gfc_builtin_decl_for_float_kind (BUILT_IN_COPYSIGN,
+ 						      expr->ts.kind);
+-	  test = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  test = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				  args[0], zero);
+-	  test2 = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
++	  test2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
+ 				   args[1], zero);
+ 	  test2 = fold_build2_loc (input_location, TRUTH_XOR_EXPR,
+-				   boolean_type_node, test, test2);
++				   logical_type_node, test, test2);
+ 	  expr1 = fold_build3_loc (input_location, COND_EXPR, type, test2,
+ 				   fold_build2_loc (input_location,
+ 						    PLUS_EXPR,
+ 						    type, tmp, args[1]),
+ 				   tmp);
+-	  test = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  test = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				  tmp, zero);
+ 	  cscall = build_call_expr_loc (input_location, copysign, 2, zero,
+ 					args[1]);
+@@ -3216,12 +3225,12 @@
+   res = fold_build2_loc (input_location, BIT_IOR_EXPR, type, left, right);
+ 
+   /* Special cases.  */
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, shift,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, shift,
+ 			  build_int_cst (stype, 0));
+   res = fold_build3_loc (input_location, COND_EXPR, type, cond,
+ 			 dshiftl ? arg1 : arg2, res);
+ 
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, shift,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, shift,
+ 			  build_int_cst (stype, bitsize));
+   res = fold_build3_loc (input_location, COND_EXPR, type, cond,
+ 			 dshiftl ? arg2 : arg1, res);
+@@ -3248,7 +3257,7 @@
+   val = gfc_evaluate_now (val, &se->pre);
+ 
+   zero = gfc_build_const (type, integer_zero_node);
+-  tmp = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, val, zero);
++  tmp = fold_build2_loc (input_location, LE_EXPR, logical_type_node, val, zero);
+   se->expr = fold_build3_loc (input_location, COND_EXPR, type, tmp, zero, val);
+ }
+ 
+@@ -3281,7 +3290,7 @@
+ 	{
+ 	  tree cond, zero;
+ 	  zero = build_real_from_int_cst (TREE_TYPE (args[1]), integer_zero_node);
+-	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				  args[1], zero);
+ 	  se->expr = fold_build3_loc (input_location, COND_EXPR,
+ 				  TREE_TYPE (args[0]), cond,
+@@ -3402,7 +3411,7 @@
+   gfc_add_expr_to_block (&se->pre, tmp);
+ 
+   /* Free the temporary afterwards, if necessary.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  len, build_int_cst (TREE_TYPE (len), 0));
+   tmp = gfc_call_free (var);
+   tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -3441,7 +3450,7 @@
+   gfc_add_expr_to_block (&se->pre, tmp);
+ 
+   /* Free the temporary afterwards, if necessary.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  len, build_int_cst (TREE_TYPE (len), 0));
+   tmp = gfc_call_free (var);
+   tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -3651,7 +3660,7 @@
+   gfc_add_expr_to_block (&se->pre, tmp);
+ 
+   /* Free the temporary afterwards, if necessary.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  len, build_int_cst (TREE_TYPE (len), 0));
+   tmp = gfc_call_free (var);
+   tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -3715,7 +3724,7 @@
+ 	  && argexpr->expr->symtree->n.sym->attr.optional
+ 	  && TREE_CODE (val) == INDIRECT_REF)
+ 	cond = fold_build2_loc (input_location,
+-				NE_EXPR, boolean_type_node,
++				NE_EXPR, logical_type_node,
+ 				TREE_OPERAND (val, 0),
+ 			build_int_cst (TREE_TYPE (TREE_OPERAND (val, 0)), 0));
+       else
+@@ -3729,7 +3738,7 @@
+ 
+       thencase = build2_v (MODIFY_EXPR, mvar, convert (type, val));
+ 
+-      tmp = fold_build2_loc (input_location, op, boolean_type_node,
++      tmp = fold_build2_loc (input_location, op, logical_type_node,
+ 			     convert (type, val), mvar);
+ 
+       /* FIXME: When the IEEE_ARITHMETIC module is implemented, the call to
+@@ -3741,8 +3750,8 @@
+ 				       builtin_decl_explicit (BUILT_IN_ISNAN),
+ 				       1, mvar);
+ 	  tmp = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-				 boolean_type_node, tmp,
+-				 fold_convert (boolean_type_node, isnan));
++				 logical_type_node, tmp,
++				 fold_convert (logical_type_node, isnan));
+ 	}
+       tmp = build3_v (COND_EXPR, tmp, thencase,
+ 		      build_empty_stmt (input_location));
+@@ -3794,7 +3803,7 @@
+   gfc_add_expr_to_block (&se->pre, tmp);
+ 
+   /* Free the temporary afterwards, if necessary.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  len, build_int_cst (TREE_TYPE (len), 0));
+   tmp = gfc_call_free (var);
+   tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -3994,7 +4003,7 @@
+   gfc_conv_expr_val (&arrayse, actual->expr);
+ 
+   gfc_add_block_to_block (&body, &arrayse.pre);
+-  tmp = fold_build2_loc (input_location, op, boolean_type_node, arrayse.expr,
++  tmp = fold_build2_loc (input_location, op, logical_type_node, arrayse.expr,
+ 			 build_int_cst (TREE_TYPE (arrayse.expr), 0));
+   tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt (input_location));
+   gfc_add_expr_to_block (&body, tmp);
+@@ -4273,13 +4282,13 @@
+       gfc_add_modify (&ifblock3, resvar, res2);
+       res2 = gfc_finish_block (&ifblock3);
+ 
+-      cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			      absX, scale);
+       tmp = build3_v (COND_EXPR, cond, res1, res2);
+       gfc_add_expr_to_block (&ifblock1, tmp);
+       tmp = gfc_finish_block (&ifblock1);
+ 
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      arrayse.expr,
+ 			      gfc_build_const (type, integer_zero_node));
+ 
+@@ -4585,7 +4594,7 @@
+ 	  nonempty = gfc_conv_mpz_to_tree (asize, gfc_index_integer_kind);
+ 	  mpz_clear (asize);
+ 	  nonempty = fold_build2_loc (input_location, GT_EXPR,
+-				      boolean_type_node, nonempty,
++				      logical_type_node, nonempty,
+ 				      gfc_index_zero_node);
+ 	}
+       maskss = NULL;
+@@ -4649,7 +4658,7 @@
+ 
+   gcc_assert (loop.dimen == 1);
+   if (nonempty == NULL && maskss == NULL && loop.from[0] && loop.to[0])
+-    nonempty = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++    nonempty = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 				loop.from[0], loop.to[0]);
+ 
+   lab1 = NULL;
+@@ -4725,7 +4734,7 @@
+ 			     loop.loopvar[0], offset);
+       gfc_add_modify (&ifblock2, pos, tmp);
+       ifbody2 = gfc_finish_block (&ifblock2);
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pos,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, pos,
+ 			      gfc_index_zero_node);
+       tmp = build3_v (COND_EXPR, cond, ifbody2,
+ 		      build_empty_stmt (input_location));
+@@ -4746,9 +4755,9 @@
+       if (lab1)
+ 	cond = fold_build2_loc (input_location,
+ 				op == GT_EXPR ? GE_EXPR : LE_EXPR,
+-				boolean_type_node, arrayse.expr, limit);
++				logical_type_node, arrayse.expr, limit);
+       else
+-	cond = fold_build2_loc (input_location, op, boolean_type_node,
++	cond = fold_build2_loc (input_location, op, logical_type_node,
+ 				arrayse.expr, limit);
+ 
+       ifbody = build3_v (COND_EXPR, cond, ifbody,
+@@ -4819,7 +4828,7 @@
+ 
+       ifbody = gfc_finish_block (&ifblock);
+ 
+-      cond = fold_build2_loc (input_location, op, boolean_type_node,
++      cond = fold_build2_loc (input_location, op, logical_type_node,
+ 			      arrayse.expr, limit);
+ 
+       tmp = build3_v (COND_EXPR, cond, ifbody,
+@@ -5071,7 +5080,7 @@
+ 	  nonempty = gfc_conv_mpz_to_tree (asize, gfc_index_integer_kind);
+ 	  mpz_clear (asize);
+ 	  nonempty = fold_build2_loc (input_location, GT_EXPR,
+-				      boolean_type_node, nonempty,
++				      logical_type_node, nonempty,
+ 				      gfc_index_zero_node);
+ 	}
+       maskss = NULL;
+@@ -5105,7 +5114,7 @@
+ 
+   if (nonempty == NULL && maskss == NULL
+       && loop.dimen == 1 && loop.from[0] && loop.to[0])
+-    nonempty = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++    nonempty = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 				loop.from[0], loop.to[0]);
+   nonempty_var = NULL;
+   if (nonempty == NULL
+@@ -5112,8 +5121,8 @@
+       && (HONOR_INFINITIES (DECL_MODE (limit))
+ 	  || HONOR_NANS (DECL_MODE (limit))))
+     {
+-      nonempty_var = gfc_create_var (boolean_type_node, "nonempty");
+-      gfc_add_modify (&se->pre, nonempty_var, boolean_false_node);
++      nonempty_var = gfc_create_var (logical_type_node, "nonempty");
++      gfc_add_modify (&se->pre, nonempty_var, logical_false_node);
+       nonempty = nonempty_var;
+     }
+   lab = NULL;
+@@ -5127,8 +5136,8 @@
+ 	}
+       else
+ 	{
+-	  fast = gfc_create_var (boolean_type_node, "fast");
+-	  gfc_add_modify (&se->pre, fast, boolean_false_node);
++	  fast = gfc_create_var (logical_type_node, "fast");
++	  gfc_add_modify (&se->pre, fast, logical_false_node);
+ 	}
+     }
+ 
+@@ -5162,12 +5171,12 @@
+   gfc_init_block (&block2);
+ 
+   if (nonempty_var)
+-    gfc_add_modify (&block2, nonempty_var, boolean_true_node);
++    gfc_add_modify (&block2, nonempty_var, logical_true_node);
+ 
+   if (HONOR_NANS (DECL_MODE (limit)))
+     {
+       tmp = fold_build2_loc (input_location, op == GT_EXPR ? GE_EXPR : LE_EXPR,
+-			     boolean_type_node, arrayse.expr, limit);
++			     logical_type_node, arrayse.expr, limit);
+       if (lab)
+ 	ifbody = build1_v (GOTO_EXPR, lab);
+       else
+@@ -5176,7 +5185,7 @@
+ 
+ 	  gfc_init_block (&ifblock);
+ 	  gfc_add_modify (&ifblock, limit, arrayse.expr);
+-	  gfc_add_modify (&ifblock, fast, boolean_true_node);
++	  gfc_add_modify (&ifblock, fast, logical_true_node);
+ 	  ifbody = gfc_finish_block (&ifblock);
+ 	}
+       tmp = build3_v (COND_EXPR, tmp, ifbody,
+@@ -5189,7 +5198,7 @@
+ 	 signed zeros.  */
+       if (HONOR_SIGNED_ZEROS (DECL_MODE (limit)))
+ 	{
+-	  tmp = fold_build2_loc (input_location, op, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, op, logical_type_node,
+ 				 arrayse.expr, limit);
+ 	  ifbody = build2_v (MODIFY_EXPR, limit, arrayse.expr);
+ 	  tmp = build3_v (COND_EXPR, tmp, ifbody,
+@@ -5214,7 +5223,7 @@
+       if (HONOR_NANS (DECL_MODE (limit))
+ 	  || HONOR_SIGNED_ZEROS (DECL_MODE (limit)))
+ 	{
+-	  tmp = fold_build2_loc (input_location, op, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, op, logical_type_node,
+ 				 arrayse.expr, limit);
+ 	  ifbody = build2_v (MODIFY_EXPR, limit, arrayse.expr);
+ 	  ifbody = build3_v (COND_EXPR, tmp, ifbody,
+@@ -5277,7 +5286,7 @@
+       if (HONOR_NANS (DECL_MODE (limit))
+ 	  || HONOR_SIGNED_ZEROS (DECL_MODE (limit)))
+ 	{
+-	  tmp = fold_build2_loc (input_location, op, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, op, logical_type_node,
+ 				 arrayse.expr, limit);
+ 	  ifbody = build2_v (MODIFY_EXPR, limit, arrayse.expr);
+ 	  tmp = build3_v (COND_EXPR, tmp, ifbody,
+@@ -5367,7 +5376,7 @@
+   tmp = fold_build2_loc (input_location, LSHIFT_EXPR, type,
+ 			 build_int_cst (type, 1), args[1]);
+   tmp = fold_build2_loc (input_location, BIT_AND_EXPR, type, args[0], tmp);
+-  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
++  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, tmp,
+ 			 build_int_cst (type, 0));
+   type = gfc_typenode_for_spec (&expr->ts);
+   se->expr = convert (type, tmp);
+@@ -5395,7 +5404,7 @@
+     args[0] = fold_convert (TREE_TYPE (args[1]), args[0]);
+ 
+   /* Now, we compare them.  */
+-  se->expr = fold_build2_loc (input_location, op, boolean_type_node,
++  se->expr = fold_build2_loc (input_location, op, logical_type_node,
+ 			      args[0], args[1]);
+ }
+ 
+@@ -5496,7 +5505,7 @@
+      gcc requires a shift width < BIT_SIZE(I), so we have to catch this
+      special case.  */
+   num_bits = build_int_cst (TREE_TYPE (args[1]), TYPE_PRECISION (type));
+-  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 			  args[1], num_bits);
+ 
+   se->expr = fold_build3_loc (input_location, COND_EXPR, type, cond,
+@@ -5542,7 +5551,7 @@
+   rshift = fold_convert (type, fold_build2_loc (input_location, RSHIFT_EXPR,
+ 				    utype, convert (utype, args[0]), width));
+ 
+-  tmp = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, args[1],
++  tmp = fold_build2_loc (input_location, GE_EXPR, logical_type_node, args[1],
+ 			 build_int_cst (TREE_TYPE (args[1]), 0));
+   tmp = fold_build3_loc (input_location, COND_EXPR, type, tmp, lshift, rshift);
+ 
+@@ -5550,7 +5559,7 @@
+      gcc requires a shift width < BIT_SIZE(I), so we have to catch this
+      special case.  */
+   num_bits = build_int_cst (TREE_TYPE (args[1]), TYPE_PRECISION (type));
+-  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, width,
++  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node, width,
+ 			  num_bits);
+   se->expr = fold_build3_loc (input_location, COND_EXPR, type, cond,
+ 			      build_int_cst (type, 0), tmp);
+@@ -5634,12 +5643,12 @@
+   rrot = fold_build2_loc (input_location,RROTATE_EXPR, type, args[0], tmp);
+ 
+   zero = build_int_cst (TREE_TYPE (args[1]), 0);
+-  tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, args[1],
++  tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node, args[1],
+ 			 zero);
+   rrot = fold_build3_loc (input_location, COND_EXPR, type, tmp, lrot, rrot);
+ 
+   /* Do nothing if shift == 0.  */
+-  tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, args[1],
++  tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, args[1],
+ 			 zero);
+   se->expr = fold_build3_loc (input_location, COND_EXPR, type, tmp, args[0],
+ 			      rrot);
+@@ -5737,7 +5746,7 @@
+ 			      fold_convert (arg_type, ullmax), ullsize);
+       cond = fold_build2_loc (input_location, BIT_AND_EXPR, arg_type,
+ 			      arg, cond);
+-      cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			      cond, build_int_cst (arg_type, 0));
+ 
+       tmp1 = fold_build2_loc (input_location, RSHIFT_EXPR, arg_type,
+@@ -5761,7 +5770,7 @@
+   /* Build BIT_SIZE.  */
+   bit_size = build_int_cst (result_type, argsize);
+ 
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			  arg, build_int_cst (arg_type, 0));
+   se->expr = fold_build3_loc (input_location, COND_EXPR, result_type, cond,
+ 			      bit_size, leadz);
+@@ -5846,7 +5855,7 @@
+ 
+       cond = fold_build2_loc (input_location, BIT_AND_EXPR, arg_type, arg,
+ 			      fold_convert (arg_type, ullmax));
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, cond,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, cond,
+ 			      build_int_cst (arg_type, 0));
+ 
+       tmp1 = fold_build2_loc (input_location, RSHIFT_EXPR, arg_type,
+@@ -5870,7 +5879,7 @@
+   /* Build BIT_SIZE.  */
+   bit_size = build_int_cst (result_type, argsize);
+ 
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			  arg, build_int_cst (arg_type, 0));
+   se->expr = fold_build3_loc (input_location, COND_EXPR, result_type, cond,
+ 			      bit_size, trailz);
+@@ -6303,7 +6312,7 @@
+ 
+       /* Special case arg == 0, because SHIFT_EXPR wants a shift strictly
+ 	 smaller than type width.  */
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, arg,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, arg,
+ 			      build_int_cst (TREE_TYPE (arg), 0));
+       res = fold_build3_loc (input_location, COND_EXPR, utype, cond,
+ 			     build_int_cst (utype, 0), res);
+@@ -6317,7 +6326,7 @@
+ 
+       /* Special case agr == bit_size, because SHIFT_EXPR wants a shift
+ 	 strictly smaller than type width.  */
+-      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++      cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 			      arg, bitsize);
+       res = fold_build3_loc (input_location, COND_EXPR, utype,
+ 			     cond, allones, res);
+@@ -6438,7 +6447,7 @@
+   gfc_add_modify (&block, res, tmp);
+ 
+   /* Finish by building the IF statement for value zero.  */
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, arg,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, arg,
+ 			  build_real_from_int_cst (type, integer_zero_node));
+   tmp = build3_v (COND_EXPR, cond, build2_v (MODIFY_EXPR, res, tiny),
+ 		  gfc_finish_block (&block));
+@@ -6509,7 +6518,7 @@
+   stmt = gfc_finish_block (&block);
+ 
+   /* if (x != 0) */
+-  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, x,
++  cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node, x,
+ 			  build_real_from_int_cst (type, integer_zero_node));
+   tmp = build3_v (COND_EXPR, cond, stmt, build_empty_stmt (input_location));
+ 
+@@ -6639,7 +6648,7 @@
+ 	  argse.data_not_needed = 1;
+ 	  gfc_conv_expr (&argse, actual->expr);
+ 	  gfc_add_block_to_block (&se->pre, &argse.pre);
+-	  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				 argse.expr, null_pointer_node);
+ 	  tmp = gfc_evaluate_now (tmp, &se->pre);
+ 	  se->expr = fold_build3_loc (input_location, COND_EXPR,
+@@ -6808,7 +6817,7 @@
+ 		}
+ 	      exit:  */
+ 	  gfc_start_block (&body);
+-	  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
++	  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node,
+ 				  loop_var, tmp);
+ 	  tmp = build1_v (GOTO_EXPR, exit_label);
+ 	  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+@@ -7079,7 +7088,7 @@
+ 	  /* Clean up if it was repacked.  */
+ 	  gfc_init_block (&block);
+ 	  tmp = gfc_conv_array_data (argse.expr);
+-	  tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	  tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				 source, tmp);
+ 	  tmp = build3_v (COND_EXPR, tmp, stmt,
+ 			  build_empty_stmt (input_location));
+@@ -7304,7 +7313,7 @@
+       indirect = gfc_finish_block (&block);
+ 
+       /* Wrap it up with the condition.  */
+-      tmp = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, LE_EXPR, logical_type_node,
+ 			     dest_word_len, source_bytes);
+       tmp = build3_v (COND_EXPR, tmp, direct, indirect);
+       gfc_add_expr_to_block (&se->pre, tmp);
+@@ -7311,7 +7320,7 @@
+ 
+       /* Free the temporary string, if necessary.  */
+       free = gfc_call_free (tmpdecl);
+-      tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++      tmp = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			     dest_word_len, source_bytes);
+       tmp = build3_v (COND_EXPR, tmp, free, build_empty_stmt (input_location));
+       gfc_add_expr_to_block (&se->post, tmp);
+@@ -7453,7 +7462,7 @@
+ 	  tmp = gfc_conv_descriptor_data_get (arg1se.expr);
+ 	}
+ 
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, tmp,
+ 			     fold_convert (TREE_TYPE (tmp), null_pointer_node));
+     }
+   se->expr = convert (gfc_typenode_for_spec (&expr->ts), tmp);
+@@ -7521,7 +7530,7 @@
+         }
+       gfc_add_block_to_block (&se->pre, &arg1se.pre);
+       gfc_add_block_to_block (&se->post, &arg1se.post);
+-      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp2,
++      tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, tmp2,
+ 			     fold_convert (TREE_TYPE (tmp2), null_pointer_node));
+       se->expr = tmp;
+     }
+@@ -7534,7 +7543,7 @@
+       nonzero_charlen = NULL_TREE;
+       if (arg1->expr->ts.type == BT_CHARACTER)
+ 	nonzero_charlen = fold_build2_loc (input_location, NE_EXPR,
+-					   boolean_type_node,
++					   logical_type_node,
+ 					   arg1->expr->ts.u.cl->backend_decl,
+ 					   integer_zero_node);
+       if (scalar)
+@@ -7559,12 +7568,12 @@
+ 	  gfc_add_block_to_block (&se->post, &arg1se.post);
+ 	  gfc_add_block_to_block (&se->pre, &arg2se.pre);
+ 	  gfc_add_block_to_block (&se->post, &arg2se.post);
+-          tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++          tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				 arg1se.expr, arg2se.expr);
+-          tmp2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++          tmp2 = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				  arg1se.expr, null_pointer_node);
+           se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				      boolean_type_node, tmp, tmp2);
++				      logical_type_node, tmp, tmp2);
+         }
+       else
+         {
+@@ -7582,7 +7591,7 @@
+ 	    tmp = gfc_rank_cst[arg1->expr->rank - 1];
+ 	  tmp = gfc_conv_descriptor_stride_get (arg1se.expr, tmp);
+ 	  nonzero_arraylen = fold_build2_loc (input_location, NE_EXPR,
+-					      boolean_type_node, tmp,
++					      logical_type_node, tmp,
+ 					      build_int_cst (TREE_TYPE (tmp), 0));
+ 
+           /* A pointer to an array, call library function _gfor_associated.  */
+@@ -7596,9 +7605,9 @@
+           se->expr = build_call_expr_loc (input_location,
+ 				      gfor_fndecl_associated, 2,
+ 				      arg1se.expr, arg2se.expr);
+-	  se->expr = convert (boolean_type_node, se->expr);
++	  se->expr = convert (logical_type_node, se->expr);
+ 	  se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				      boolean_type_node, se->expr,
++				      logical_type_node, se->expr,
+ 				      nonzero_arraylen);
+         }
+ 
+@@ -7606,7 +7615,7 @@
+ 	 be associated.  */
+       if (nonzero_charlen != NULL_TREE)
+ 	se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				    boolean_type_node,
++				    logical_type_node,
+ 				    se->expr, nonzero_charlen);
+     }
+ 
+@@ -7634,7 +7643,7 @@
+   if (UNLIMITED_POLY (a))
+     {
+       tmp = gfc_class_vptr_get (a->symtree->n.sym->backend_decl);
+-      conda = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      conda = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       tmp, build_int_cst (TREE_TYPE (tmp), 0));
+     }
+ 
+@@ -7641,7 +7650,7 @@
+   if (UNLIMITED_POLY (b))
+     {
+       tmp = gfc_class_vptr_get (b->symtree->n.sym->backend_decl);
+-      condb = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++      condb = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			       tmp, build_int_cst (TREE_TYPE (tmp), 0));
+     }
+ 
+@@ -7667,16 +7676,16 @@
+   gfc_conv_expr (&se2, b);
+ 
+   tmp = fold_build2_loc (input_location, EQ_EXPR,
+-			 boolean_type_node, se1.expr,
++			 logical_type_node, se1.expr,
+ 			 fold_convert (TREE_TYPE (se1.expr), se2.expr));
+ 
+   if (conda)
+     tmp = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-			   boolean_type_node, conda, tmp);
++			   logical_type_node, conda, tmp);
+ 
+   if (condb)
+     tmp = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+-			   boolean_type_node, condb, tmp);
++			   logical_type_node, condb, tmp);
+ 
+   se->expr = convert (gfc_typenode_for_spec (&expr->ts), tmp);
+ }
+@@ -7802,7 +7811,7 @@
+   gfc_add_expr_to_block (&se->pre, tmp);
+ 
+   /* Free the temporary afterwards, if necessary.  */
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  len, build_int_cst (TREE_TYPE (len), 0));
+   tmp = gfc_call_free (var);
+   tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
+@@ -7836,7 +7845,7 @@
+   ncopies_type = TREE_TYPE (ncopies);
+ 
+   /* Check that NCOPIES is not negative.  */
+-  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, ncopies,
++  cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node, ncopies,
+ 			  build_int_cst (ncopies_type, 0));
+   gfc_trans_runtime_check (true, false, cond, &se->pre, &expr->where,
+ 			   "Argument NCOPIES of REPEAT intrinsic is negative "
+@@ -7846,7 +7855,7 @@
+   /* If the source length is zero, any non negative value of NCOPIES
+      is valid, and nothing happens.  */
+   n = gfc_create_var (ncopies_type, "ncopies");
+-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, slen,
++  cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, slen,
+ 			  build_int_cst (size_type_node, 0));
+   tmp = fold_build3_loc (input_location, COND_EXPR, ncopies_type, cond,
+ 			 build_int_cst (ncopies_type, 0), ncopies);
+@@ -7863,13 +7872,13 @@
+ 			  fold_convert (size_type_node, max), slen);
+   largest = TYPE_PRECISION (size_type_node) > TYPE_PRECISION (ncopies_type)
+ 	      ? size_type_node : ncopies_type;
+-  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
++  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+ 			  fold_convert (largest, ncopies),
+ 			  fold_convert (largest, max));
+-  tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, slen,
++  tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, slen,
+ 			 build_int_cst (size_type_node, 0));
+-  cond = fold_build3_loc (input_location, COND_EXPR, boolean_type_node, tmp,
+-			  boolean_false_node, cond);
++  cond = fold_build3_loc (input_location, COND_EXPR, logical_type_node, tmp,
++			  logical_false_node, cond);
+   gfc_trans_runtime_check (true, false, cond, &se->pre, &expr->where,
+ 			   "Argument NCOPIES of REPEAT intrinsic is too large");
+ 
+@@ -7892,7 +7901,7 @@
+   gfc_start_block (&body);
+ 
+   /* Exit the loop if count >= ncopies.  */
+-  cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, count,
++  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node, count,
+ 			  ncopies);
+   tmp = build1_v (GOTO_EXPR, exit_label);
+   TREE_USED (exit_label) = 1;
+@@ -8041,7 +8050,7 @@
+       if (arg->next->expr == NULL)
+ 	/* Only given one arg so generate a null and do a
+ 	   not-equal comparison against the first arg.  */
+-	se->expr = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++	se->expr = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 				    arg1se.expr,
+ 				    fold_convert (TREE_TYPE (arg1se.expr),
+ 						  null_pointer_node));
+@@ -8057,17 +8066,17 @@
+ 	  gfc_add_block_to_block (&se->post, &arg2se.post);
+ 
+ 	  /* Generate test to compare that the two args are equal.  */
+-	  eq_expr = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
++	  eq_expr = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+ 				     arg1se.expr, arg2se.expr);
+ 	  /* Generate test to ensure that the first arg is not null.  */
+ 	  not_null_expr = fold_build2_loc (input_location, NE_EXPR,
+-					   boolean_type_node,
++					   logical_type_node,
+ 					   arg1se.expr, null_pointer_node);
+ 
+ 	  /* Finally, the generated test must check that both arg1 is not
+ 	     NULL and that it is equal to the second arg.  */
+ 	  se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-				      boolean_type_node,
++				      logical_type_node,
+ 				      not_null_expr, eq_expr);
+ 	}
+     }
+@@ -8292,11 +8301,11 @@
+   isnormal = build_call_expr_loc (input_location,
+ 				  builtin_decl_explicit (BUILT_IN_ISNORMAL),
+ 				  1, arg);
+-  iszero = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, arg,
++  iszero = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, arg,
+ 			    build_real_from_int_cst (TREE_TYPE (arg),
+ 						     integer_zero_node));
+   se->expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+-			      boolean_type_node, isnormal, iszero);
++			      logical_type_node, isnormal, iszero);
+   se->expr = fold_convert (gfc_typenode_for_spec (&expr->ts), se->expr);
+ }
+ 
+@@ -8321,11 +8330,11 @@
+   signbit = build_call_expr_loc (input_location,
+ 				 builtin_decl_explicit (BUILT_IN_SIGNBIT),
+ 				 1, arg);
+-  signbit = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  signbit = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			     signbit, integer_zero_node);
+ 
+   se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+-			      boolean_type_node, signbit,
++			      logical_type_node, signbit,
+ 			      fold_build1_loc (input_location, TRUTH_NOT_EXPR,
+ 					       TREE_TYPE(isnan), isnan));
+ 
+@@ -8471,7 +8480,7 @@
+   sign = build_call_expr_loc (input_location,
+ 			      builtin_decl_explicit (BUILT_IN_SIGNBIT),
+ 			      1, args[1]);
+-  sign = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
++  sign = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
+ 			  sign, integer_zero_node);
+ 
+   /* Create a value of one, with the right sign.  */
+@@ -10537,7 +10546,7 @@
+ 
+       tmp = gfc_conv_descriptor_data_get (to_se.expr);
+       cond = fold_build2_loc (input_location, EQ_EXPR,
+-			      boolean_type_node, tmp,
++			      logical_type_node, tmp,
+ 			      fold_convert (TREE_TYPE (tmp),
+ 					    null_pointer_node));
+       tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all,
+Index: gcc/configure.ac
+===================================================================
+--- a/src/gcc/configure.ac	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/configure.ac	(.../branches/gcc-7-branch)
+@@ -4059,6 +4059,11 @@
+ 	;;
+     esac
+ 
++    gcc_GAS_CHECK_FEATURE([-xbrace_comment], gcc_cv_as_ix86_xbrace_comment,,
++      [-xbrace_comment=no], [.text],,
++      [AC_DEFINE(HAVE_AS_XBRACE_COMMENT_OPTION, 1,
++		[Define if your assembler supports -xbrace_comment option.])])
++
+     # Test if the assembler supports the section flag 'e' for specifying
+     # an excluded section.
+     gcc_GAS_CHECK_FEATURE([.section with e], gcc_cv_as_section_has_e,
 Index: gcc/langhooks.h
 ===================================================================
 --- a/src/gcc/langhooks.h	(.../tags/gcc_7_2_0_release)
@@ -323396,6 +327055,28 @@ Index: gcc/config/i386/i386.md
    "xor{b}\t{%2, %h0|%h0, %2}"
    [(set_attr "isa" "*,nox64")
     (set_attr "type" "alu")
+Index: gcc/config/i386/sol2.h
+===================================================================
+--- a/src/gcc/config/i386/sol2.h	(.../tags/gcc_7_2_0_release)
++++ b/src/gcc/config/i386/sol2.h	(.../branches/gcc-7-branch)
+@@ -65,8 +65,16 @@
+ #define ASM_CPU64_DEFAULT_SPEC "-xarch=generic64"
+ #endif
+ 
++/* Since Studio 12.6, as needs -xbrace_comment=no so its AVX512 syntax is
++   fully compatible with gas.  */
++#ifdef HAVE_AS_XBRACE_COMMENT_OPTION
++#define ASM_XBRACE_COMMENT_SPEC "-xbrace_comment=no"
++#else
++#define ASM_XBRACE_COMMENT_SPEC ""
++#endif
++
+ #undef ASM_CPU_SPEC
+-#define ASM_CPU_SPEC "%(asm_cpu_default)"
++#define ASM_CPU_SPEC "%(asm_cpu_default) " ASM_XBRACE_COMMENT_SPEC
+ 
+ /* Don't include ASM_PIC_SPEC.  While the Solaris 10+ assembler accepts -K PIC,
+    it gives many warnings: 
 Index: gcc/config/i386/predicates.md
 ===================================================================
 --- a/src/gcc/config/i386/predicates.md	(.../tags/gcc_7_2_0_release)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-7.git



More information about the Reproducible-commits mailing list