public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/gcc] rhel-f41-base: 12.0.0-0.3
Date: Mon, 29 Jun 2026 12:29:32 GMT	[thread overview]
Message-ID: <178273617297.1.9271392077375959065.rpms-gcc-cdf92292afdc@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/gcc
Branch : rhel-f41-base
Commit : cdf92292afdca58fae56c2e927cf4f3fa22d2789
Author : Jakub Jelinek <jakub@redhat.com>
Date   : 2022-01-08T12:35:44+01:00
Stats  : +5707/-7281 in 52 file(s)
URL    : https://src.fedoraproject.org/rpms/gcc/c/cdf92292afdca58fae56c2e927cf4f3fa22d2789?branch=rhel-f41-base

Log:
12.0.0-0.3

---
diff --git a/.gitignore b/.gitignore
index dbccc8a..0cb9ebd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,3 +54,4 @@
 /gcc-11.2.1-20211018.tar.xz
 /gcc-11.2.1-20211019.tar.xz
 /gcc-11.2.1-20211203.tar.xz
+/gcc-12.0.0-20220108.tar.xz

diff --git a/gcc.spec b/gcc.spec
index a310bcf..6fe59ed 100644
--- a/gcc.spec
+++ b/gcc.spec
@@ -1,10 +1,10 @@
-%global DATE 20211203
-%global gitrev e41308252e835ddedcabfd4a98240080c6583a43
-%global gcc_version 11.2.1
-%global gcc_major 11
+%global DATE 20220108
+%global gitrev 6bd6f878235efd1d0787892e7e2f73c5edf514cc
+%global gcc_version 12.0.0
+%global gcc_major 12
 # Note, gcc_release must be integer, if you want to add suffixes to
 # %%{release}, append them after %%{gcc_release} on Release: line.
-%global gcc_release 7
+%global gcc_release 0
 %global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
 %global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
 %global _unpackaged_files_terminate_build 0
@@ -119,7 +119,7 @@
 Summary: Various compilers (C, C++, Objective-C, ...)
 Name: gcc
 Version: %{gcc_version}
-Release: %{gcc_release}%{?dist}
+Release: %{gcc_release}.3%{?dist}
 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
 # GCC Runtime Exception.
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
@@ -199,6 +199,10 @@ BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.
 # Ada requires Ada to build
 BuildRequires: gcc-gnat >= 3.1, libgnat >= 3.1
 %endif
+%if %{build_d}
+# D requires D to build
+BuildRequires: gcc-gdc >= 11.0.0, libgphobos-static >= 11.0.0
+%endif
 %ifarch ia64
 BuildRequires: libunwind >= 0.98
 %endif
@@ -254,34 +258,28 @@ Provides: bundled(libbacktrace)
 Provides: bundled(libffi)
 Provides: gcc(major) = %{gcc_major}
 
-Patch0: gcc11-hack.patch
-Patch2: gcc11-sparc-config-detection.patch
-Patch3: gcc11-libgomp-omp_h-multilib.patch
-Patch4: gcc11-libtool-no-rpath.patch
-Patch5: gcc11-isl-dl.patch
-Patch6: gcc11-isl-dl2.patch
-Patch7: gcc11-libstdc++-docs.patch
-Patch8: gcc11-no-add-needed.patch
-Patch9: gcc11-foffload-default.patch
-Patch10: gcc11-Wno-format-security.patch
-Patch11: gcc11-rh1574936.patch
-Patch12: gcc11-d-shared-libphobos.patch
-Patch13: gcc11-pr99341-revert.patch
-Patch14: gcc11-libgcc-link.patch
-Patch15: gcc11-pr101786.patch
-Patch16: gcc11-stringify-__VA_OPT__.patch
-Patch17: gcc11-stringify-__VA_OPT__-2.patch
-
-Patch100: gcc11-fortran-fdec-duplicates.patch
-Patch101: gcc11-fortran-flogical-as-integer.patch
-Patch102: gcc11-fortran-fdec-ichar.patch
-Patch103: gcc11-fortran-fdec-non-integer-index.patch
-Patch104: gcc11-fortran-fdec-old-init.patch
-Patch105: gcc11-fortran-fdec-override-kind.patch
-Patch106: gcc11-fortran-fdec-non-logical-if.patch
-Patch107: gcc11-fortran-fdec-promotion.patch
-Patch108: gcc11-fortran-fdec-sequence.patch
-Patch109: gcc11-fortran-fdec-add-missing-indexes.patch
+Patch0: gcc12-hack.patch
+Patch2: gcc12-sparc-config-detection.patch
+Patch3: gcc12-libgomp-omp_h-multilib.patch
+Patch4: gcc12-libtool-no-rpath.patch
+Patch5: gcc12-isl-dl.patch
+Patch6: gcc12-isl-dl2.patch
+Patch7: gcc12-libstdc++-docs.patch
+Patch8: gcc12-no-add-needed.patch
+Patch9: gcc12-Wno-format-security.patch
+Patch10: gcc12-rh1574936.patch
+Patch11: gcc12-d-shared-libphobos.patch
+
+Patch100: gcc12-fortran-fdec-duplicates.patch
+Patch101: gcc12-fortran-flogical-as-integer.patch
+Patch102: gcc12-fortran-fdec-ichar.patch
+Patch103: gcc12-fortran-fdec-non-integer-index.patch
+Patch104: gcc12-fortran-fdec-old-init.patch
+Patch105: gcc12-fortran-fdec-override-kind.patch
+Patch106: gcc12-fortran-fdec-non-logical-if.patch
+Patch107: gcc12-fortran-fdec-promotion.patch
+Patch108: gcc12-fortran-fdec-sequence.patch
+Patch109: gcc12-fortran-fdec-add-missing-indexes.patch
 
 # On ARM EABI systems, we do want -gnueabi to be part of the
 # target triple.
@@ -303,7 +301,7 @@ Patch109: gcc11-fortran-fdec-add-missing-indexes.patch
 %if %{build_go}
 # Avoid stripping these libraries and binaries.
 %global __os_install_post \
-chmod 644 %{buildroot}%{_prefix}/%{_lib}/libgo.so.19.* \
+chmod 644 %{buildroot}%{_prefix}/%{_lib}/libgo.so.20.* \
 chmod 644 %{buildroot}%{_prefix}/bin/go.gcc \
 chmod 644 %{buildroot}%{_prefix}/bin/gofmt.gcc \
 chmod 644 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/cgo \
@@ -311,7 +309,7 @@ chmod 644 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}
 chmod 644 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/test2json \
 chmod 644 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/vet \
 %__os_install_post \
-chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgo.so.19.* \
+chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgo.so.20.* \
 chmod 755 %{buildroot}%{_prefix}/bin/go.gcc \
 chmod 755 %{buildroot}%{_prefix}/bin/gofmt.gcc \
 chmod 755 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/cgo \
@@ -322,11 +320,11 @@ chmod 755 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}
 %endif
 
 %description
-The gcc package contains the GNU Compiler Collection version 11.
+The gcc package contains the GNU Compiler Collection version 12.
 You'll need this package in order to compile C code.
 
 %package -n libgcc
-Summary: GCC version 11 shared support library
+Summary: GCC version 12 shared support library
 Autoreq: false
 %if !%{build_ada}
 Obsoletes: libgnat < %{version}-%{release}
@@ -787,19 +785,11 @@ to NVidia PTX capable devices if available.
 %patch7 -p0 -b .libstdc++-docs~
 %endif
 %patch8 -p0 -b .no-add-needed~
-%patch9 -p0 -b .foffload-default~
-%patch10 -p0 -b .Wno-format-security~
+%patch9 -p0 -b .Wno-format-security~
 %if 0%{?fedora} >= 29 || 0%{?rhel} > 7
-%patch11 -p0 -b .rh1574936~
-%endif
-%patch12 -p0 -b .d-shared-libphobos~
-%if 0%{?fedora} == 34
-%patch13 -p0 -b .pr99341-revert~
+%patch10 -p0 -b .rh1574936~
 %endif
-%patch14 -p0 -b .libgcc-link~
-%patch15 -p0 -b .pr101786~
-%patch16 -p0 -b .stringify-__VA_OPT__~
-%patch17 -p0 -b .stringify-__VA_OPT__-2~
+%patch11 -p0 -b .d-shared-libphobos~
 
 %if 0%{?rhel} >= 9
 %patch100 -p1 -b .fortran-fdec-duplicates~
@@ -817,6 +807,8 @@ to NVidia PTX capable devices if available.
 %ifarch %{arm}
 rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go
 %endif
+rm -f libphobos/testsuite/libphobos.gc/forkgc2.d
+#rm -rf libphobos/testsuite/libphobos.gc
 
 echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE
 
@@ -922,7 +914,7 @@ ISL_FLAG_PIC=-fPIC
 ISL_FLAG_PIC=-fpic
 %endif
 cd isl-build
-sed -i 's|libisl|libgcc11privateisl|g' \
+sed -i 's|libisl|libgcc12privateisl|g' \
   ../../isl-%{isl_version}/Makefile.{am,in}
 ../../isl-%{isl_version}/configure \
   CC=/usr/bin/gcc CXX=/usr/bin/g++ \
@@ -930,8 +922,8 @@ sed -i 's|libisl|libgcc11privateisl|g' \
 make %{?_smp_mflags}
 make install
 cd ../isl-install/lib
-rm libgcc11privateisl.so{,.15}
-mv libgcc11privateisl.so.15.3.0 libisl.so.15
+rm libgcc12privateisl.so{,.15}
+mv libgcc12privateisl.so.15.3.0 libisl.so.15
 ln -sf libisl.so.15 libisl.so
 cd ../..
 %endif
@@ -985,7 +977,7 @@ CONFIGURE_OPTS="\
 %endif
 %if %{build_offload_nvptx}
 	--enable-offload-targets=nvptx-none \
-	--without-cuda-driver \
+	--without-cuda-driver --enable-offload-defaulted \
 %endif
 %if 0%{?fedora} >= 21 || 0%{?rhel} >= 7
 %if %{attr_ifunc}
@@ -1184,7 +1176,7 @@ done)
 (cd libphobos; for i in ChangeLog*; do
 	cp -p $i ../rpm.doc/libphobos/$i.libphobos
 done
-cp -a src/LICENSE*.txt libdruntime/LICENSE ../rpm.doc/libphobos/)
+cp -a src/LICENSE*.txt libdruntime/LICENSE.txt ../rpm.doc/libphobos/)
 %endif
 %if %{build_libquadmath}
 (cd libquadmath; for i in ChangeLog* COPYING.LIB; do
@@ -1463,14 +1455,14 @@ ln -sf ../../../libstdc++.so.6.*[0-9] libstdc++.so
 ln -sf ../../../libgfortran.so.5.* libgfortran.so
 ln -sf ../../../libgomp.so.1.* libgomp.so
 %if %{build_go}
-ln -sf ../../../libgo.so.19.* libgo.so
+ln -sf ../../../libgo.so.20.* libgo.so
 %endif
 %if %{build_libquadmath}
 ln -sf ../../../libquadmath.so.0.* libquadmath.so
 %endif
 %if %{build_d}
-ln -sf ../../../libgdruntime.so.2.* libgdruntime.so
-ln -sf ../../../libgphobos.so.2.* libgphobos.so
+ln -sf ../../../libgdruntime.so.3.* libgdruntime.so
+ln -sf ../../../libgphobos.so.3.* libgphobos.so
 %endif
 %if %{build_libitm}
 ln -sf ../../../libitm.so.1.* libitm.so
@@ -1479,7 +1471,7 @@ ln -sf ../../../libitm.so.1.* libitm.so
 ln -sf ../../../libatomic.so.1.* libatomic.so
 %endif
 %if %{build_libasan}
-ln -sf ../../../libasan.so.6.* libasan.so
+ln -sf ../../../libasan.so.8.* libasan.so
 mv ../../../libasan_preinit.o libasan_preinit.o
 %endif
 %if %{build_libubsan}
@@ -1493,14 +1485,14 @@ ln -sf ../../../../%{_lib}/libstdc++.so.6.*[0-9] libstdc++.so
 ln -sf ../../../../%{_lib}/libgfortran.so.5.* libgfortran.so
 ln -sf ../../../../%{_lib}/libgomp.so.1.* libgomp.so
 %if %{build_go}
-ln -sf ../../../../%{_lib}/libgo.so.19.* libgo.so
+ln -sf ../../../../%{_lib}/libgo.so.20.* libgo.so
 %endif
 %if %{build_libquadmath}
 ln -sf ../../../../%{_lib}/libquadmath.so.0.* libquadmath.so
 %endif
 %if %{build_d}
-ln -sf ../../../../%{_lib}/libgdruntime.so.2.* libgdruntime.so
-ln -sf ../../../../%{_lib}/libgphobos.so.2.* libgphobos.so
+ln -sf ../../../../%{_lib}/libgdruntime.so.3.* libgdruntime.so
+ln -sf ../../../../%{_lib}/libgphobos.so.3.* libgphobos.so
 %endif
 %if %{build_libitm}
 ln -sf ../../../../%{_lib}/libitm.so.1.* libitm.so
@@ -1509,7 +1501,7 @@ ln -sf ../../../../%{_lib}/libitm.so.1.* libitm.so
 ln -sf ../../../../%{_lib}/libatomic.so.1.* libatomic.so
 %endif
 %if %{build_libasan}
-ln -sf ../../../../%{_lib}/libasan.so.6.* libasan.so
+ln -sf ../../../../%{_lib}/libasan.so.8.* libasan.so
 mv ../../../../%{_lib}/libasan_preinit.o libasan_preinit.o
 %endif
 %if %{build_libubsan}
@@ -1517,7 +1509,7 @@ ln -sf ../../../../%{_lib}/libubsan.so.1.* libubsan.so
 %endif
 %if %{build_libtsan}
 rm -f libtsan.so
-echo 'INPUT ( %{_prefix}/%{_lib}/'`echo ../../../../%{_lib}/libtsan.so.0.* | sed 's,^.*libt,libt,'`' )' > libtsan.so
+echo 'INPUT ( %{_prefix}/%{_lib}/'`echo ../../../../%{_lib}/libtsan.so.2.* | sed 's,^.*libt,libt,'`' )' > libtsan.so
 mv ../../../../%{_lib}/libtsan_preinit.o libtsan_preinit.o
 %endif
 %if %{build_liblsan}
@@ -1577,28 +1569,28 @@ mv -f $FULLPATH/ada{include,lib} $FULLLPATH/
 pushd $FULLLPATH/adalib
 if [ "%{_lib}" = "lib" ]; then
 ln -sf ../../../../../libgnarl-*.so libgnarl.so
-ln -sf ../../../../../libgnarl-*.so libgnarl-11.so
+ln -sf ../../../../../libgnarl-*.so libgnarl-12.so
 ln -sf ../../../../../libgnat-*.so libgnat.so
-ln -sf ../../../../../libgnat-*.so libgnat-11.so
+ln -sf ../../../../../libgnat-*.so libgnat-12.so
 else
 ln -sf ../../../../../../%{_lib}/libgnarl-*.so libgnarl.so
-ln -sf ../../../../../../%{_lib}/libgnarl-*.so libgnarl-11.so
+ln -sf ../../../../../../%{_lib}/libgnarl-*.so libgnarl-12.so
 ln -sf ../../../../../../%{_lib}/libgnat-*.so libgnat.so
-ln -sf ../../../../../../%{_lib}/libgnat-*.so libgnat-11.so
+ln -sf ../../../../../../%{_lib}/libgnat-*.so libgnat-12.so
 fi
 popd
 else
 pushd $FULLPATH/adalib
 if [ "%{_lib}" = "lib" ]; then
 ln -sf ../../../../libgnarl-*.so libgnarl.so
-ln -sf ../../../../libgnarl-*.so libgnarl-11.so
+ln -sf ../../../../libgnarl-*.so libgnarl-12.so
 ln -sf ../../../../libgnat-*.so libgnat.so
-ln -sf ../../../../libgnat-*.so libgnat-11.so
+ln -sf ../../../../libgnat-*.so libgnat-12.so
 else
 ln -sf ../../../../../%{_lib}/libgnarl-*.so libgnarl.so
-ln -sf ../../../../../%{_lib}/libgnarl-*.so libgnarl-11.so
+ln -sf ../../../../../%{_lib}/libgnarl-*.so libgnarl-12.so
 ln -sf ../../../../../%{_lib}/libgnat-*.so libgnat.so
-ln -sf ../../../../../%{_lib}/libgnat-*.so libgnat-11.so
+ln -sf ../../../../../%{_lib}/libgnat-*.so libgnat-12.so
 fi
 popd
 fi
@@ -1613,8 +1605,8 @@ ln -sf ../`echo ../../../../lib/libgfortran.so.5.* | sed s~/lib/~/lib64/~` 64/li
 ln -sf ../`echo ../../../../lib/libgomp.so.1.* | sed s~/lib/~/lib64/~` 64/libgomp.so
 %if %{build_go}
 rm -f libgo.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgo.so.19.* | sed 's,^.*libg,libg,'`' )' > libgo.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgo.so.19.* | sed 's,^.*libg,libg,'`' )' > 64/libgo.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgo.so.20.* | sed 's,^.*libg,libg,'`' )' > libgo.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgo.so.20.* | sed 's,^.*libg,libg,'`' )' > 64/libgo.so
 %endif
 %if %{build_libquadmath}
 rm -f libquadmath.so
@@ -1623,10 +1615,10 @@ echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libquadmath.so.0.* | sed '
 %endif
 %if %{build_d}
 rm -f libgdruntime.so libgphobos.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgdruntime.so.2.* | sed 's,^.*libg,libg,'`' )' > libgdruntime.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgdruntime.so.2.* | sed 's,^.*libg,libg,'`' )' > 64/libgdruntime.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgphobos.so.2.* | sed 's,^.*libg,libg,'`' )' > libgphobos.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgphobos.so.2.* | sed 's,^.*libg,libg,'`' )' > 64/libgphobos.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgdruntime.so.3.* | sed 's,^.*libg,libg,'`' )' > libgdruntime.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgdruntime.so.3.* | sed 's,^.*libg,libg,'`' )' > 64/libgdruntime.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libgphobos.so.3.* | sed 's,^.*libg,libg,'`' )' > libgphobos.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libgphobos.so.3.* | sed 's,^.*libg,libg,'`' )' > 64/libgphobos.so
 %endif
 %if %{build_libitm}
 rm -f libitm.so
@@ -1640,8 +1632,8 @@ echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libatomic.so.1.* | sed 's,
 %endif
 %if %{build_libasan}
 rm -f libasan.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libasan.so.6.* | sed 's,^.*liba,liba,'`' )' > libasan.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libasan.so.6.* | sed 's,^.*liba,liba,'`' )' > 64/libasan.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib/libasan.so.8.* | sed 's,^.*liba,liba,'`' )' > libasan.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib/libasan.so.8.* | sed 's,^.*liba,liba,'`' )' > 64/libasan.so
 mv ../../../../lib64/libasan_preinit.o 64/libasan_preinit.o
 %endif
 %if %{build_libubsan}
@@ -1712,8 +1704,8 @@ ln -sf ../`echo ../../../../lib64/libgfortran.so.5.* | sed s~/../lib64/~/~` 32/l
 ln -sf ../`echo ../../../../lib64/libgomp.so.1.* | sed s~/../lib64/~/~` 32/libgomp.so
 %if %{build_go}
 rm -f libgo.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgo.so.19.* | sed 's,^.*libg,libg,'`' )' > libgo.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgo.so.19.* | sed 's,^.*libg,libg,'`' )' > 32/libgo.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgo.so.20.* | sed 's,^.*libg,libg,'`' )' > libgo.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgo.so.20.* | sed 's,^.*libg,libg,'`' )' > 32/libgo.so
 %endif
 %if %{build_libquadmath}
 rm -f libquadmath.so
@@ -1722,10 +1714,10 @@ echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libquadmath.so.0.* | sed '
 %endif
 %if %{build_d}
 rm -f libgdruntime.so libgphobos.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgdruntime.so.2.* | sed 's,^.*libg,libg,'`' )' > libgdruntime.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgdruntime.so.2.* | sed 's,^.*libg,libg,'`' )' > 32/libgdruntime.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgphobos.so.2.* | sed 's,^.*libg,libg,'`' )' > libgphobos.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgphobos.so.2.* | sed 's,^.*libg,libg,'`' )' > 32/libgphobos.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgdruntime.so.3.* | sed 's,^.*libg,libg,'`' )' > libgdruntime.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgdruntime.so.3.* | sed 's,^.*libg,libg,'`' )' > 32/libgdruntime.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libgphobos.so.3.* | sed 's,^.*libg,libg,'`' )' > libgphobos.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libgphobos.so.3.* | sed 's,^.*libg,libg,'`' )' > 32/libgphobos.so
 %endif
 %if %{build_libitm}
 rm -f libitm.so
@@ -1739,8 +1731,8 @@ echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libatomic.so.1.* | sed 's,
 %endif
 %if %{build_libasan}
 rm -f libasan.so
-echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libasan.so.6.* | sed 's,^.*liba,liba,'`' )' > libasan.so
-echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libasan.so.6.* | sed 's,^.*liba,liba,'`' )' > 32/libasan.so
+echo 'INPUT ( %{_prefix}/lib64/'`echo ../../../../lib64/libasan.so.8.* | sed 's,^.*liba,liba,'`' )' > libasan.so
+echo 'INPUT ( %{_prefix}/lib/'`echo ../../../../lib64/libasan.so.8.* | sed 's,^.*liba,liba,'`' )' > 32/libasan.so
 mv ../../../../lib/libasan_preinit.o 32/libasan_preinit.o
 %endif
 %if %{build_libubsan}
@@ -1877,8 +1869,8 @@ chmod 755 %{buildroot}%{_prefix}/%{_lib}/libcc1.so.0.*
 chmod 755 %{buildroot}%{_prefix}/%{_lib}/libquadmath.so.0.*
 %endif
 %if %{build_d}
-chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgdruntime.so.2.*
-chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgphobos.so.2.*
+chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgdruntime.so.3.*
+chmod 755 %{buildroot}%{_prefix}/%{_lib}/libgphobos.so.3.*
 %endif
 %if %{build_libitm}
 chmod 755 %{buildroot}%{_prefix}/%{_lib}/libitm.so.1.*
@@ -1887,20 +1879,20 @@ chmod 755 %{buildroot}%{_prefix}/%{_lib}/libitm.so.1.*
 chmod 755 %{buildroot}%{_prefix}/%{_lib}/libatomic.so.1.*
 %endif
 %if %{build_libasan}
-chmod 755 %{buildroot}%{_prefix}/%{_lib}/libasan.so.6.*
+chmod 755 %{buildroot}%{_prefix}/%{_lib}/libasan.so.8.*
 %endif
 %if %{build_libubsan}
 chmod 755 %{buildroot}%{_prefix}/%{_lib}/libubsan.so.1.*
 %endif
 %if %{build_libtsan}
-chmod 755 %{buildroot}%{_prefix}/%{_lib}/libtsan.so.0.*
+chmod 755 %{buildroot}%{_prefix}/%{_lib}/libtsan.so.2.*
 %endif
 %if %{build_liblsan}
 chmod 755 %{buildroot}%{_prefix}/%{_lib}/liblsan.so.0.*
 %endif
 %if %{build_go}
 # Avoid stripping these libraries and binaries.
-chmod 644 %{buildroot}%{_prefix}/%{_lib}/libgo.so.19.*
+chmod 644 %{buildroot}%{_prefix}/%{_lib}/libgo.so.20.*
 chmod 644 %{buildroot}%{_prefix}/bin/go.gcc
 chmod 644 %{buildroot}%{_prefix}/bin/gofmt.gcc
 chmod 644 %{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/cgo
@@ -2276,6 +2268,8 @@ end
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/keylockerintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/avxvnniintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/mwaitintrin.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/avx512fp16intrin.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/avx512fp16vlintrin.h
 %endif
 %ifarch ia64
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/ia64intrin.h
@@ -2300,6 +2294,9 @@ end
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/tmmintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/smmintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/amo.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/nmmintrin.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/immintrin.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/x86gprintrin.h
 %endif
 %ifarch %{arm}
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/unwind-arm-common.h
@@ -2714,8 +2711,8 @@ end
 %doc rpm.doc/gdc/*
 
 %files -n libgphobos
-%{_prefix}/%{_lib}/libgdruntime.so.2*
-%{_prefix}/%{_lib}/libgphobos.so.2*
+%{_prefix}/%{_lib}/libgdruntime.so.3*
+%{_prefix}/%{_lib}/libgphobos.so.3*
 %doc rpm.doc/libphobos/*
 
 %files -n libgphobos-static
@@ -2920,7 +2917,7 @@ end
 
 %if %{build_libasan}
 %files -n libasan
-%{_prefix}/%{_lib}/libasan.so.6*
+%{_prefix}/%{_lib}/libasan.so.8*
 
 %files -n libasan-static
 %dir %{_prefix}/lib/gcc
@@ -2968,7 +2965,7 @@ end
 
 %if %{build_libtsan}
 %files -n libtsan
-%{_prefix}/%{_lib}/libtsan.so.0*
+%{_prefix}/%{_lib}/libtsan.so.2*
 
 %files -n libtsan-static
 %dir %{_prefix}/lib/gcc
@@ -3040,7 +3037,7 @@ end
 %doc rpm.doc/go/*
 
 %files -n libgo
-%attr(755,root,root) %{_prefix}/%{_lib}/libgo.so.19*
+%attr(755,root,root) %{_prefix}/%{_lib}/libgo.so.20*
 %doc rpm.doc/libgo/*
 
 %files -n libgo-devel
@@ -3148,688 +3145,5 @@ end
 %endif
 
 %changelog
-* Fri Dec  3 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-7
-- update from releases/gcc-11-branch
-  - PRs ada/100486, c++/70796, c++/92746, c++/93286, c++/94490, c++/102642,
-	c++/102786, debug/101378, debug/103046, debug/103315, fortran/87711,
-	fortran/87851, fortran/97896, fortran/99061, fortran/99348,
-	fortran/102521, fortran/102685, fortran/102715, fortran/102745,
-	fortran/102816, fortran/102817, fortran/102917, fortran/103137,
-	fortran/103138, fortran/103392, gcov-profile/100520, ipa/102714,
-	ipa/102762, ipa/103052, ipa/103246, ipa/103267, libstdc++/96416,
-	libstdc++/98421, libstdc++/100117, libstdc++/100153, libstdc++/100748,
-	libstdc++/101571, libstdc++/101608, libstdc++/102894,
-	libstdc++/103022, libstdc++/103086, libstdc++/103133,
-	libstdc++/103240, libstdc++/103381, middle-end/64888,
-	middle-end/101480, middle-end/102431, middle-end/102518,
-	middle-end/103059, middle-end/103181, middle-end/103248,
-	middle-end/103384, preprocessor/103130, rtl-optimization/102356,
-	rtl-optimization/102842, target/101985, target/102976, target/102991,
-	target/103205, target/103274, target/103275, testsuite/102690,
-	tree-optimization/100393, tree-optimization/102139,
-	tree-optimization/102505, tree-optimization/102572,
-	tree-optimization/102788, tree-optimization/102789,
-	tree-optimization/102798, tree-optimization/102970,
-	tree-optimization/103192, tree-optimization/103204,
-	tree-optimization/103237, tree-optimization/103255,
-	tree-optimization/103435
-- fix up #__VA_OPT__ handling (PR preprocessor/103415)
-
-* Tue Oct 19 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-6
-- update from releases/gcc-11-branch
-  - PRs target/100208, target/100316, target/102761
-- fix up libstdc++ docs build
-
-* Mon Oct 18 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-5
-- update from releases/gcc-11-branch
-  - PRs fortran/102716, libstdc++/65816, libstdc++/90787, libstdc++/99876,
-	libstdc++/100187, libstdc++/100237, libstdc++/100249,
-	libstdc++/100287, libstdc++/100606, libstdc++/100863,
-	libstdc++/101483, libstdc++/101583, libstdc++/101589,
-	libstdc++/101599, libstdc++/101761, libstdc++/101870,
-	libstdc++/101923, libstdc++/101960, libstdc++/102048,
-	libstdc++/102074, libstdc++/102270, libstdc++/102280,
-	libstdc++/102425, libstdc++/102592, libstdc++/102667,
-	rtl-optimization/102627, target/100340, target/102588
-- add mwaitintrin.h on x86 (#2013860)
-- disable LTO bootstrap on 32-bit arm, 6 days long build and counting
-  isn't acceptable, build boxes don't have enough memory and are too
-  slow
-
-* Tue Oct 12 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-4
-- update from releases/gcc-11-branch
-  - PRs ada/101970, c++/60318, c++/64697, c++/88578, c++/91292, c++/95567,
-	c++/98216, c++/98486, c++/99904, c++/100495, c++/101344, c++/101592,
-	c++/101803, c++/101883, c++/102163, c++/102295, c++/102305,
-	c++/102412, c++/102454, c++/102496, c++/102535, c++/102547,
-	c++/102548, c++/102640, d/102185, d/102574, debug/102373,
-	debug/102441, fortran/46691, fortran/82314, fortran/85130,
-	fortran/87737, fortran/98490, fortran/99819, fortran/100950,
-	fortran/101327, fortran/101349, fortran/102113, fortran/102287,
-	fortran/102311, fortran/102366, fortran/102458, fortran/102520,
-	ipa/97565, libgomp/96661, libstdc++/100180, libstdc++/100285,
-	libstdc++/100286, libstdc++/100351, libstdc++/100682,
-	libstdc++/101965, middle-end/101824, middle-end/101949,
-	rtl-optimization/102306, sanitizer/102515, target/94630, target/97142,
-	target/100734, target/101471, target/101472, target/101492,
-	target/101549, target/101849, target/101934, target/102035,
-	target/102107, target/102115, target/102166, target/102222,
-	target/102224, target/102498, tree-optimization/101925,
-	tree-optimization/102046, tree-optimization/102124,
-	tree-optimization/102400, tree-optimization/102451,
-	tree-optimization/102622
-- remove the PR libstdc++/99341 workaround for Fedora 35 and later,
-  the std::once_flag::_M_activate() and std::once_flag::_M_finish(bool)
-  symbols (mangled as _ZNSt9once_flag11_M_activateEv and
-  _ZNSt9once_flag9_M_finishEb) aren't part of upstream GCC 11 and were
-  present only because not all packaged have been successfully rebuilt
-  (#1961541)
-
-* Mon Aug 23 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-3
-- update from releases/gcc-11-branch
-  - PRs c++/100828, c++/101663, c++/101725, c++/101759, c/100150, c/101512,
-	d/96435, d/101127, d/101441, d/101490, d/101619, d/101640, d/101664,
-	debug/101905, fortran/99351, fortran/101084, fortran/101514,
-	fortran/101536, fortran/101564, gcov-profile/89961,
-	gcov-profile/100788, ipa/100600, ipa/101261, ipa/101726,
-	libstdc++/100139, libstdc++/101056, libstdc++/101258,
-	libstdc++/101510, libstdc++/101866, middle-end/101624,
-	preprocessor/101638, sanitizer/101749, target/94780, target/100952,
-	target/101132, target/101531, target/101723, testsuite/101969,
-	tree-optimization/101373, tree-optimization/101505,
-	tree-optimization/101868
-- add bundled(libbacktrace) and bundled(libffi) provides
-- build target shared libraries with -Wl,-z,relro,-z,now
-- improve generated code with extern thread_local constinit vars
-  with trivial dtors
-- add support for C++20 #__VA_OPT__
-- fix up %%ldconfig_scriptlets
-
-* Fri Jul 30 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-2
-- enable LTO profiledbootstrap on all arches, and also for RHEL9+
-
-* Wed Jul 28 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-1
-- update from releases/gcc-11-branch
-  - GCC 11.2 release
-  - PRs middle-end/101586, rtl-optimization/101562
-- enable LTO profiledbootstrap on x86_64, i?86, ppc64le and s390x for f35+
-
-* Mon Jul 26 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-7
-- update from releases/gcc-11-branch
-  - PRs ada/101094, analyzer/100244, analyzer/100615, analyzer/101082,
-	bootstrap/100246, c++/100138, c++/100752, c++/100838, c++/100918,
-	c++/101040, c++/101087, c++/101098, c++/101181, c++/101182,
-	c++/101194, c++/101210, c++/101233, c++/101247, c++/101361,
-	c++/101443, c++/101516, c++/86355, c++/95520, c++/97420, c++/98832,
-	c/101171, c/101176, d/101273, d/101282, debug/101266, driver/101383,
-	fortran/100227, fortran/100949, fortran/93524, go/101407, ipa/101066,
-	libstdc++/100387, libstdc++/101411, libstdc++/101427,
-	middle-end/100672, middle-end/101156, middle-end/101172,
-	middle-end/101291, middle-end/101423, middle-end/101535,
-	middle-end/94366, target/100152, target/100809, target/101023,
-	target/101129, target/101142, target/101175, target/101185,
-	target/101235, target/101377, target/101384, target/101395,
-	testsuite/100422, tree-optimization/100299, tree-optimization/100778,
-	tree-optimization/100923, tree-optimization/101014,
-	tree-optimization/101025, tree-optimization/101088,
-	tree-optimization/101105, tree-optimization/101148,
-	tree-optimization/101151, tree-optimization/101158,
-	tree-optimization/101173, tree-optimization/101223,
-	tree-optimization/101229, tree-optimization/101280,
-	tree-optimization/101394, tree-optimization/101445
-
-* Wed Jun 23 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-6
-- update from releases/gcc-11-branch
-  - PRs c++/100876, c++/100879, c++/101106, c/100619, c/100783, fortran/95501,
-	fortran/95502, fortran/100283, fortran/101123, inline-asm/100785,
-	libstdc++/91488, libstdc++/95833, libstdc++/100806, libstdc++/100940,
-	middle-end/100250, middle-end/100307, middle-end/100574,
-	middle-end/100684, middle-end/100732, middle-end/100876,
-	middle-end/101062, middle-end/101167, target/99842, target/99939,
-	target/100310, target/100777, target/100856, target/100871,
-	target/101016
-
-* Thu Jun 17 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-5
-- update from releases/gcc-11-branch
-  - PRs bootstrap/100731, c++/91706, c++/91859, c++/95719, c++/100065,
-	c++/100102, c++/100580, c++/100666, c++/100796, c++/100797,
-	c++/100862, c++/100946, c++/100963, c++/101029, c++/101078, c/100902,
-	c/100920, d/100882, d/100935, d/100964, d/100967, d/100999,
-	debug/100852, fortran/82376, fortran/98301, fortran/99839,
-	fortran/100965, ipa/100791, libstdc++/98842, libstdc++/100475,
-	libstdc++/100577, libstdc++/100631, libstdc++/100639,
-	libstdc++/100676, libstdc++/100690, libstdc++/100768,
-	libstdc++/100770, libstdc++/100824, libstdc++/100833,
-	libstdc++/100889, libstdc++/100894, libstdc++/100900,
-	libstdc++/100982, libstdc++/101034, libstdc++/101055,
-	middle-end/100576, middle-end/100898, middle-end/101009,
-	preprocessor/100646, rtl-optimization/100342, rtl-optimization/100590,
-	rtl-optimization/101008, target/100333, target/100885, target/100887,
-	target/101046, testsuite/100750, tree-optimization/100934,
-	tree-optimization/100981
-
-* Mon Jun 14 2021 Florian Weimer <fweimer@redhat.com> 11.1.1-4
-- NVR bump to enable rebuild in side tag
-
-* Mon May 31 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-3
-- update from releases/gcc-11-branch
-  - PRs bootstrap/100552, c++/100205, c++/100261, c++/100281, c++/100367,
-	c++/100372, c++/100489, c++/100502, c++/100634, c++/100644,
-	c++/100659, c/100550, fortran/98411, fortran/100551, fortran/100602,
-	fortran/100633, fortran/100656, ipa/100513, libstdc++/100361,
-	libstdc++/100479, libstdc++/100630, middle-end/100471,
-	middle-end/100508, middle-end/100509, preprocessor/100392,
-	target/94177, target/99725, target/99960, target/99977, target/100419,
-	target/100563, target/100626, target/100767, testsuite/96488,
-	tree-optimization/100492, tree-optimization/100519
-
-* Wed May 12 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-2
-- update from releases/gcc-11-branch
-  - PRs c++/98032, c++/100319, c++/100362, c/100450, fortran/100274,
-	ipa/100308, libgomp/100352, libstdc++/99006, libstdc++/99453,
-	libstdc++/100259, libstdc++/100298, libstdc++/100384,
-	rtl-optimization/84878, rtl-optimization/100225,
-	rtl-optimization/100230, rtl-optimization/100263,
-	rtl-optimization/100411, target/99988, target/100217, target/100232,
-	target/100236, target/100270, target/100305, target/100311,
-	target/100375, target/100402, tree-optimization/96513,
-	tree-optimization/100253, tree-optimization/100278,
-	tree-optimization/100329, tree-optimization/100414
-- fix build with removed linux/cyclades.h header (PR sanitizer/100379)
-- fix up mausezahn miscompilation (#1958887, PR tree-optimization/100566)
-
-* Wed Apr 28 2021 Jakub Jelinek <jakub@redhat.com> 11.1.1-1
-- update from releases/gcc-11-branch
-  - GCC 11.1 release
-  - PRs c++/93383, c++/95291, c++/96380, c++/99200, c++/99683, c++/100161,
-	debug/100255, fortran/100154, fortran/100218, libstdc++/100290,
-	rtl-optimization/100254, target/98952, target/100200,
-	tree-optimization/100239
-- fix ICE in aarch64_add_offset_1_temporaries (PR target/100302)
-
-* Fri Apr 23 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.7
-- update from trunk and releases/gcc-11 branch
-  - GCC 11.1-rc2
-  - PRs libstdc++/100179, target/100182
-
-* Thu Apr 22 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.6
-- update from trunk and releases/gcc-11 branch
-  - GCC 11.1-rc1
-  - PRs ada/99360, c++/97536, c/100143, d/98058, d/98457, d/98494, d/98584,
-	d/99794, demangler/100177, fortran/100110, libstdc++/95983,
-	libstdc++/100146, libstdc++/100164, preprocessor/100142,
-	rtl-optimization/99927, target/100108, testsuite/100176,
-	tree-optimization/100081
-- fix a cprop -fcompare-debug bug (PR rtl-optimization/100148)
-
-* Sun Apr 18 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.5
-- update from trunk
-  - PRs analyzer/98599, analyzer/99042, analyzer/99212, analyzer/99774,
-	analyzer/99886, analyzer/99906, analyzer/100011, c++/41723, c++/49951,
-	c++/52202, c++/52625, c++/58123, c++/80456, c++/83476, c++/88742,
-	c++/90215, c++/90479, c++/90674, c++/91241, c++/91849, c++/91933,
-	c++/92918, c++/93085, c++/93295, c++/93314, c++/93867, c++/94529,
-	c++/95317, c++/95486, c++/95870, c++/96311, c++/96673, c++/96873,
-	c++/97121, c++/97134, c++/97679, c++/97974, c++/98440, c++/98800,
-	c++/98852, c++/99008, c++/99066, c++/99118, c++/99180, c++/99201,
-	c++/99380, c++/99478, c++/99700, c++/99803, c++/99806, c++/99833,
-	c++/99844, c++/99850, c++/99859, c++/99874, c++/99885, c++/99899,
-	c++/99901, c++/99961, c++/99994, c++/100006, c++/100032, c++/100054,
-	c++/100078, c++/100079, c++/100091, c++/100101, c++/100111, c/98852,
-	c/99420, c/99972, c/99990, d/99812, d/99914, d/99917, debug/99830,
-	fortran/63797, fortran/99307, fortran/99817, fortran/100018,
-	fortran/100094, jit/100096, libfortran/78314, libgomp/99984,
-	libstdc++/96657, libstdc++/99402, libstdc++/99433, libstdc++/99805,
-	libstdc++/99985, libstdc++/99995, libstdc++/100044, libstdc++/100060,
-	lto/98599, lto/99849, lto/99857, middle-end/55288, middle-end/84877,
-	middle-end/84991, middle-end/84992, middle-end/86058,
-	middle-end/90779, middle-end/98088, middle-end/99883,
-	middle-end/99989, preprocessor/99446, rtl-optimization/98601,
-	rtl-optimization/98689, rtl-optimization/99596,
-	rtl-optimization/99905, rtl-optimization/99929,
-	rtl-optimization/100066, sanitizer/99877, sanitizer/100114,
-	target/87763, target/99246, target/99647, target/99648, target/99748,
-	target/99767, target/99781, target/99872, target/100028,
-	target/100048, target/100056, target/100067, target/100075,
-	testsuite/99955, testsuite/100071, testsuite/100073,
-	tree-optimization/82800, tree-optimization/97513,
-	tree-optimization/98736, tree-optimization/99873,
-	tree-optimization/99880, tree-optimization/99924,
-	tree-optimization/99947, tree-optimization/99954,
-	tree-optimization/100053
-- for %%{rhel} == 9, default to -march=z14 -mtune=z15 on s390x and
-  to -mcpu=power9 -mtune=power9 on ppc64le
-
-* Mon Apr  5 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.4
-- update from trunk
-  - PRs ada/99802, analyzer/93695, analyzer/99044, analyzer/99716,
-	analyzer/99771, bootstrap/98860, c++/90664, c++/91217, c++/91416,
-	c++/94751, c++/97900, c++/97938, c++/98352, c++/99331, c++/99445,
-	c++/99565, c++/99583, c++/99584, c++/99586, c++/99643, c++/99672,
-	c++/99705, c++/99745, c++/99790, c++/99815, c++/99831, c++/99869,
-	d/91595, d/99691, debug/99334, fortran/99369, fortran/99602,
-	fortran/99651, fortran/99818, fortran/99840, ipa/98265, ipa/99122,
-	ipa/99466, ipa/99751, libstdc++/99533, lto/99447, middle-end/65182,
-	rtl-optimization/97141, rtl-optimization/98726,
-	rtl-optimization/99863, target/96974, target/97653, target/98119,
-	target/98136, target/98209, target/99037, target/99133, target/99216,
-	target/99555, target/99718, target/99724, target/99727, target/99744,
-	target/99753, target/99766, target/99773, target/99786, target/99808,
-	target/99813, target/99820, target/99822, testsuite/98125,
-	tree-optimization/48483, tree-optimization/55060,
-	tree-optimization/59970, tree-optimization/61112,
-	tree-optimization/61677, tree-optimization/61869,
-	tree-optimization/96573, tree-optimization/96974,
-	tree-optimization/97009, tree-optimization/98268,
-	tree-optimization/99726, tree-optimization/99746,
-	tree-optimization/99777, tree-optimization/99807,
-	tree-optimization/99824, tree-optimization/99825,
-	tree-optimization/99856, tree-optimization/99863,
-	tree-optimization/99882
-
-* Wed Mar 24 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.3
-- update from trunk
-  - PRs analyzer/99614, c++/99239, c++/99283, c++/99318, c++/99425, c++/99456,
-	c++/99480, c++/99687, c/99588, fortran/93660, fortran/99688,
-	rtl-optimization/99680, target/97252, target/97926, target/98914,
-	target/99540, target/99581, target/99652, target/99660, target/99661,
-	target/99663, target/99679, target/99702, target/99704, target/99733,
-	tree-optimization/99296, tree-optimization/99656,
-	tree-optimization/99694, tree-optimization/99721
-
-* Fri Mar 19 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.2
-- update from trunk
-  - PRs c++/90448, c++/96268, c++/96749, c++/97973, c++/98480, c++/98704,
-	c++/99047, c++/99108, c++/99238, c++/99248, c++/99285, c++/99423,
-	c++/99436, c++/99459, c++/99472, c++/99496, c++/99500, c++/99507,
-	c++/99508, c++/99509, c++/99528, c++/99601, c++/99613, c++/99617,
-	fortran/49278, fortran/96983, fortran/97927, fortran/98858,
-	fortran/99125, fortran/99205, fortran/99345, fortran/99514,
-	fortran/99545, ipa/99517, libstdc++/99172, libstdc++/99341,
-	libstdc++/99413, libstdc++/99536, libstdc++/99537, middle-end/97631,
-	middle-end/98266, middle-end/99502, middle-end/99641, objc++/49070,
-	sanitizer/98920, target/98092, target/98959, target/99070,
-	target/99094, target/99102, target/99422, target/99437, target/99454,
-	target/99463, target/99464, target/99492, target/99504, target/99542,
-	target/99563, target/99592, target/99600, testsuite/97680,
-	testsuite/98245, testsuite/99292, testsuite/99498, testsuite/99626,
-	testsuite/99636, tree-optimization/98834, tree-optimization/99305,
-	tree-optimization/99489, tree-optimization/99510,
-	tree-optimization/99523, tree-optimization/99544
-  - fix ARM ICE in neon_output_shift_immediate (#1922599, PR target/99593)
-- avoid false positive aarch64 -Wpsabi notes in some cases (PR target/91710)
-- fix a -fcompare-debug failure caused by C FE bug (PR debug/99230)
-- fix up -gdwarf-5 -gsplit-dwarf ranges handling (PR debug/99490)
-- fix up handling of > 64 bit constants in dwarf2out (PR debug/99562,
-  PR debug/66728)
-- reject invalid C++ structured bindings that need reference to void
-  (PR c++/99650)
-- include private isl 0.18 in the package instead of relying on old
-  distro version
-
-* Sun Mar  7 2021 Jakub Jelinek <jakub@redhat.com> 11.0.1-0.1
-- update from trunk
-  - PRs ada/98996, ada/99020, ada/99095, ada/99264, analyzer/96374,
-	analyzer/99193, bootstrap/92002, bootstrap/98590, c++/82959,
-	c++/88146, c++/90333, c++/94521, c++/95451, c++/95615, c++/95616,
-	c++/95675, c++/95822, c++/96078, c++/96330, c++/96443, c++/96474,
-	c++/96960, c++/97034, c++/97587, c++/98118, c++/98318, c++/98810,
-	c++/98990, c++/99009, c++/99103, c++/99120, c++/99166, c++/99170,
-	c++/99176, c++/99213, c++/99245, c++/99251, c++/99287, c++/99294,
-	c++/99344, c++/99362, c++/99365, c++/99374, c++/99377, c++/99389,
-	c/99137, c/99275, c/99304, c/99323, c/99324, c/99325, c/99363,
-	d/99337, debug/66668, debug/99090, debug/99319, fortran/57871,
-	fortran/99300, fortran/99303, fortran/99355, gcov-profile/97461,
-	gcov-profile/99105, gcov-profile/99385, gcov-profile/99406, ipa/98078,
-	ipa/98338, libbacktrace/98818, libfortran/81986, libfortran/99218,
-	libgomp/98738, libstdc++/99265, libstdc++/99270, libstdc++/99301,
-	libstdc++/99382, libstdc++/99396, middle-end/93235, middle-end/94655,
-	middle-end/95757, middle-end/96963, middle-end/97172,
-	middle-end/97855, middle-end/99276, middle-end/99281,
-	middle-end/99295, middle-end/99322, other/99288,
-	rtl-optimization/99376, target/44107, target/48097, target/95798,
-	target/98996, target/99085, target/99234, target/99271, target/99279,
-	target/99313, target/99321, target/99381, testsuite/99233,
-	tree-optimization/80635, tree-optimization/99253
-- fix debug info for __fp16 constants (PR debug/99388)
-
-* Thu Feb 25 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.20
-- update from trunk
-  - PRs analyzer/94596, analyzer/98969, analyzer/99196, c++/94034, c++/94546,
-	c++/95468, c++/95888, c++/96251, c++/96926, c++/97246, c++/97582,
-	c++/97742, c++/98718, c++/98741, c++/98988, c++/99023, c++/99030,
-	c++/99031, c++/99033, c++/99035, c++/99039, c++/99040, c++/99062,
-	c++/99063, c++/99071, c++/99072, c++/99074, c++/99116, c++/99132,
-	c++/99150, c++/99153, c++/99174, c++/99208, c/97172, c/99055, c/99136,
-	c/99224, debug/96997, debug/98755, fortran/98342, fortran/98686,
-	fortran/98897, fortran/98979, fortran/99010, fortran/99027,
-	fortran/99043, fortran/99060, fortran/99111, fortran/99124,
-	fortran/99146, fortran/99171, fortran/99206, fortran/99226,
-	inline-asm/98096, inline-asm/99123, ipa/97346, ipa/99003, ipa/99029,
-	ipa/99034, jit/99126, libfortran/95647, libfortran/98825,
-	libgcc/99236, libstdc++/88881, libstdc++/97549, libstdc++/98389,
-	libstdc++/99058, libstdc++/99077, libstdc++/99096, libstdc++/99181,
-	libstdc++/99261, middle-end/38474, middle-end/99007, middle-end/99109,
-	middle-end/99122, preprocessor/96391, rtl-optimization/96264,
-	rtl-optimization/98439, rtl-optimization/98791,
-	rtl-optimization/98872, rtl-optimization/99054, sanitizer/99106,
-	sanitizer/99168, target/85074, target/96166, target/97417,
-	target/98491, target/98657, target/98931, target/98998, target/99025,
-	target/99041, target/99100, target/99104, target/99113, target/99134,
-	target/99157, testsuite/99173, translation/99167,
-	tree-optimization/38474, tree-optimization/92879,
-	tree-optimization/98772, tree-optimization/99002,
-	tree-optimization/99024, tree-optimization/99026,
-	tree-optimization/99079, tree-optimization/99142,
-	tree-optimization/99149, tree-optimization/99165,
-	tree-optimization/99204, tree-optimization/99220,
-	tree-optimization/99225
-
-* Wed Feb 10 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.19
-- update from trunk
-  - PRs analyzer/93355, analyzer/96374, analyzer/98575, analyzer/98918,
-	c++/20408, c++/84494, c++/90926, c++/95192, c++/96199, c++/96462,
-	c++/96905, c++/97804, c++/97878, c++/98295, c++/98326, c++/98355,
-	c++/98531, c++/98570, c++/98717, c++/98802, c++/98835, c++/98899,
-	c++/98926, c++/98929, c++/98944, c++/98947, c++/98951, c++/98994,
-	c/97882, c/97932, d/98910, d/98921, debug/98656, driver/98943,
-	fortran/91862, fortran/98913, libstdc++/70303, libstdc++/99021,
-	lto/96591, lto/98912, lto/98971, middle-end/97172, middle-end/97487,
-	middle-end/97971, middle-end/98465, middle-end/98974,
-	middle-end/99004, preprocessor/98882, rtl-optimization/96015,
-	target/97510, target/98172, target/98537, target/98743, target/98957,
-	testsuite/98243, testsuite/98325, tree-optimization/97960,
-	tree-optimization/98287, tree-optimization/98499,
-	tree-optimization/98848, tree-optimization/98855,
-	tree-optimization/98863, tree-optimization/98928,
-	tree-optimization/98937, tree-optimization/99017
-
-* Sat Jan 30 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.18
-- update from trunk
-  - PRs ada/98228, bootstrap/98839, c++/33661, c++/88548, c++/94775,
-	c++/96137, c++/97474, c++/97566, c++/97874, c++/98463, c++/98646,
-	c++/98770, c++/98841, c++/98843, c++/98847, d/98806, debug/98331,
-	debug/98811, fortran/67539, fortran/70070, fortran/86470,
-	fortran/93924, fortran/93925, fortran/96843, fortran/98472,
-	fortran/98517, libstdc++/66414, lto/85574, middle-end/98726,
-	middle-end/98807, rtl-optimization/80960, rtl-optimization/97684,
-	rtl-optimization/98144, rtl-optimization/98863, sanitizer/98828,
-	target/97701, target/98730, target/98799, target/98827, target/98833,
-	target/98849, target/98853, testsuite/98771, testsuite/98870,
-	tree-optimization/97260, tree-optimization/97627,
-	tree-optimization/98854, tree-optimization/98866
-
-* Sat Jan 23 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.17
-- update from trunk
-  - PRs ada/98740, c++/41437, c++/58993, c++/71879, c++/82613, c++/95434,
-	c++/96623, c++/97399, c++/97966, c++/98333, c++/98530, c++/98545,
-	c++/98624, c++/98659, c++/98744, fortran/96320, fortran/98476,
-	fortran/98565, fortran/98757, fortran/98763, gcov-profile/98739,
-	ipa/97673, ipa/98330, ipa/98690, middle-end/98664, middle-end/98773,
-	middle-end/98793, rtl-optimization/92294, rtl-optimization/98694,
-	rtl-optimization/98722, rtl-optimization/98777, sanitizer/95693,
-	target/79251, target/96372, target/96891, target/98065, target/98093,
-	target/98348, target/98636, testsuite/97301, testsuite/98241,
-	testsuite/98795, tree-optimization/47059, tree-optimization/90248,
-	tree-optimization/96674, tree-optimization/98255,
-	tree-optimization/98535, tree-optimization/98758,
-	tree-optimization/98766, tree-optimization/98786
-  - ensure for empty CUs -gdwarf-5 emits at least the required 0th directory
-    and filename entry in the .debug_line section (#1919243, PR debug/98796)
-- fix aarch64 bug where emitted ubfix insn can't be assembled
-  (PR target/98681)
-
-* Wed Jan 20 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.16
-- fix DWARF5 -g -flto -ffat-lto-objects, so that LTO sections can be stripped
-  off later (PR debug/98765)
-- fix GOMP_task caller stack corruption on s390x
-- libgccjit DWARF5 fixes (PR debug/98751)
-
-* Tue Jan 19 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.15
-- update from trunk
-  - PRs debug/98708, debug/98716, ipa/98222, libstdc++/98725, target/97847,
-	testsuite/97299, testsuite/97494, testsuite/97987,
-	tree-optimization/96271
-  - fix miscompilation of portable signed multiplication overflow check
-    (#1916576, PR tree-optimization/98727)
-  - switch to DWARF 5 by default
-- fix PRs c++/98672, c++/98687, c++/98742, middle-end/98638,
-	  tree-optimization/98721
-
-* Sat Jan 16 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.14
-- update from trunk
-  - PRs ada/98595, analyzer/98679, bootstrap/98696, c++/63707, c++/98231,
-	c++/98372, c++/98538, c++/98591, c++/98626, c++/98642, fortran/98661,
-	ipa/98652, jit/98586, libgomp/65099, libstdc++/98466, libstdc++/98471,
-	preprocessor/95253, target/70454, target/71233, target/88836,
-	target/95905, target/96938, target/98667, target/98671, target/98676,
-	testsuite/96098, testsuite/96147, tree-optimization/92645,
-	tree-optimization/96376, tree-optimization/96669,
-	tree-optimization/96681, tree-optimization/96688,
-	tree-optimization/96691, tree-optimization/98455,
-	tree-optimization/98597, tree-optimization/98640,
-	tree-optimization/98674, tree-optimization/98685
-  - fix up pmovzx permutation SSE4.1 patterns (#1916240, PR target/98670)
-
-* Wed Jan 13 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.13
-- update from trunk
-  - PRs analyzer/98628, c++/97284, c++/98481, c++/98556, c++/98611, c++/98620,
-	c/98592, debug/97714, jit/98615, libstdc++/98613,
-	rtl-optimization/98603, target/97875, target/97969, target/98612,
-	testsuite/98225, testsuite/98602, tree-optimization/91403,
-	tree-optimization/95731, tree-optimization/95852,
-	tree-optimization/95867, tree-optimization/98526,
-	tree-optimization/98550, tree-optimization/98629
-  - fix ICEs in print_mem_ref (#1915400, #1915437, #1915781, PR c/98597)
-
-* Sat Jan  9 2021 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.12
-- update from trunk
-  - PRs analyzer/97072, analyzer/97074, analyzer/98073, analyzer/98223,
-	analyzer/98293, analyzer/98564, analyzer/98580, bootstrap/98324,
-	bootstrap/98506, c++/82099, c++/95768, c++/96045, c++/96504,
-	c++/97597, c++/98206, c++/98305, c++/98316, c++/98329, c++/98332,
-	c++/98353, c++/98413, c++/98441, c++/98469, c++/98515, c++/98551,
-	c/98029, d/98427, fortran/83118, fortran/93701, fortran/93794,
-	fortran/93833, fortran/97612, fortran/97694, fortran/97723,
-	fortran/98022, fortran/98458, libstdc++/98384, middle-end/98160,
-	middle-end/98578, other/98437, rtl-optimization/97144,
-	rtl-optimization/97978, rtl-optimization/98214,
-	rtl-optimization/98334, rtl-optimization/98403, target/89057,
-	target/96793, target/97269, target/98461, target/98482, target/98495,
-	target/98521, target/98522, target/98567, target/98585,
-	testsuite/98489, testsuite/98566, tree-optimization/56719,
-	tree-optimization/94785, tree-optimization/94802,
-	tree-optimization/94994, tree-optimization/95401,
-	tree-optimization/95582, tree-optimization/95771,
-	tree-optimization/96239, tree-optimization/96782,
-	tree-optimization/96928, tree-optimization/96930,
-	tree-optimization/98282, tree-optimization/98291,
-	tree-optimization/98302, tree-optimization/98308,
-	tree-optimization/98371, tree-optimization/98381,
-	tree-optimization/98393, tree-optimization/98428,
-	tree-optimization/98464, tree-optimization/98474,
-	tree-optimization/98513, tree-optimization/98514,
-	tree-optimization/98516, tree-optimization/98544,
-	tree-optimization/98560, tree-optimization/98568
-
-* Wed Dec 23 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.11
-- update from trunk
-  - PRs bootstrap/98300, bootstrap/98380, bootstrap/98412, c++/67343,
-	c++/93480, c++/96840, c++/98340, c++/98343, c++/98353, c++/98383,
-	c/98047, c/98260, d/98067, fortran/83118, fortran/92587,
-	fortran/96012, fortran/98284, fortran/98307, go/98402,
-	libstdc++/46447, libstdc++/93151, libstdc++/96083, libstdc++/98319,
-	libstdc++/98344, libstdc++/98370, libstdc++/98374, libstdc++/98377,
-	middle-end/98366, other/98400, other/98409, rtl-optimization/98271,
-	rtl-optimization/98276, rtl-optimization/98289,
-	rtl-optimization/98347, sanitizer/97868, target/96793, target/98146,
-	target/98177, target/98280, tree-optimization/96239,
-	tree-optimization/97750, tree-optimization/98272,
-	tree-optimization/98279, tree-optimization/98378,
-	tree-optimization/98407
-
-* Thu Dec 17 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.10
-- apply workaround for profiledbootstrap x86_64 failure
-- put g++-mapper-server into the right directory
-
-* Wed Dec 16 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.8
-- update from trunk
-  - PRs ada/98230, bootstrap/98188, c++/57111, c++/59238, c++/68451,
-	c++/78173, c++/91506, c++/93083, c++/96299, c++/97093, c++/97517,
-	c++/98043, c++/98103, c++/98122, c++/98126, c++/98130, c++/98187,
-	c++/98193, c/97981, c/98200, d/98277, fortran/90207, fortran/98016,
-	fortran/98022, gcov-profile/98273, libstdc++/98108, libstdc++/98226,
-	lto/98275, middle-end/94600, middle-end/98160, middle-end/98166,
-	middle-end/98183, middle-end/98190, middle-end/98205,
-	middle-end/98264, rtl-optimization/97092, rtl-optimization/97421,
-	rtl-optimization/98212, rtl-optimization/98229, sanitizer/98204,
-	target/58901, target/66791, target/92469, target/94440, target/95294,
-	target/96226, target/96470, target/97865, target/97872, target/98100,
-	target/98147, target/98152, target/98161, target/98162, target/98219,
-	target/98274, testsuite/95900, testsuite/98123, testsuite/98156,
-	testsuite/98239, testsuite/98240, testsuite/98242, testsuite/98244,
-	tree-optimization/95582, tree-optimization/96094,
-	tree-optimization/96232, tree-optimization/96272,
-	tree-optimization/96344, tree-optimization/96685,
-	tree-optimization/97559, tree-optimization/97929,
-	tree-optimization/98069, tree-optimization/98113,
-	tree-optimization/98117, tree-optimization/98137,
-	tree-optimization/98169, tree-optimization/98174,
-	tree-optimization/98180, tree-optimization/98182,
-	tree-optimization/98191, tree-optimization/98192,
-	tree-optimization/98199, tree-optimization/98211,
-	tree-optimization/98213, tree-optimization/98235,
-	tree-optimization/98256
-  - C++20 modules support
-  - fix up __patchable_function_entries handling when gcc is configured
-    against recent binutils (#1907945)
-- fix up handling of non-memory VIEW_CONVERT_EXPRs in PRE
-  (PR tree-optimization/98282)
-
-* Fri Dec  4 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.7
-- update from trunk
-  - PRs bootstrap/97983, c++/80780, c++/90629, c++/93093, c++/97187,
-	c++/97947, c++/97975, c++/97993, c++/98019, c++/98054, c++/98072,
-	c++/98104, c++/98107, c++/98115, c++/98116, c/65455, c/92935, c/97880,
-	c/98087, d/87788, d/87818, d/98025, debug/97989, fortran/95342,
-	fortran/98010, fortran/98011, fortran/98013, ipa/88702, ipa/98057,
-	ipa/98075, jit/97867, libgcc/97543, libgcc/97643, libstdc++/65480,
-	libstdc++/68735, libstdc++/93121, libstdc++/98001, libstdc++/98003,
-	middle-end/89428, middle-end/92936, middle-end/92940,
-	middle-end/93195, middle-end/93197, middle-end/94527,
-	middle-end/97373, middle-end/97595, middle-end/98070,
-	middle-end/98082, middle-end/98099, other/98027, plugins/98059,
-	preprocessor/97602, rtl-optimization/97459, rtl-optimization/97777,
-	rtl-optimization/97954, rtl-optimization/98037, target/96607,
-	target/96906, target/97642, target/97770, target/97939, target/98063,
-	target/98079, target/98086, testsuite/98002, testsuite/98036,
-	testsuite/98085, tree-optimization/14799, tree-optimization/88702,
-	tree-optimization/96679, tree-optimization/96708,
-	tree-optimization/97630, tree-optimization/97953,
-	tree-optimization/97979, tree-optimization/97997,
-	tree-optimization/98024, tree-optimization/98048,
-	tree-optimization/98064, tree-optimization/98066,
-	tree-optimization/98084
-
-* Thu Nov 26 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.6
-- update from trunk
-  - PRs bootstrap/94982, bootstrap/97622, bootstrap/97933, c++/97899, c/97958,
-	fortran/85796, libstdc++/67791, libstdc++/97935, libstdc++/97936,
-	libstdc++/97944, middle-end/97943, middle-end/97956,
-	rtl-optimization/95862, target/91816, target/97534, target/97950,
-	tree-optimization/96929, tree-optimization/97849,
-	tree-optimization/97964
-
-* Tue Nov 24 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.5
-- update from trunk
-  - PRs c++/94695, c++/97427, c++/97839, c++/97846, c++/97881, c++/97904,
-	c/95630, d/97889, libstdc++/97948, tree-optimization/95853
-
-* Sat Nov 21 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.4
-- update from trunk
-  - PRs ada/97805, ada/97859, analyzer/97668, analyzer/97893, bootstrap/57076,
-	bootstrap/97666, bootstrap/97857, c++/25814, c++/52830, c++/63287,
-	c++/67453, c++/78209, c++/81660, c++/87765, c++/88115, c++/88982,
-	c++/89565, c++/90799, c++/91318, c++/93107, c++/93907, c++/95808,
-	c++/97388, c++/97412, c++/97453, c++/97479, c++/97518, c++/97523,
-	c++/97632, c++/97663, c++/97670, c++/97675, c++/97762, c++/97790,
-	c++/97871, c++/97877, c++/97895, c++/97905, c++/97918, c/90628,
-	c/97748, c/97860, d/97644, d/97842, d/97843, debug/97060, debug/97599,
-	debug/97718, driver/97574, fortran/90111, fortran/92793,
-	fortran/94358, fortran/95847, fortran/97652, fortran/97655,
-	fortran/97768, fortran/97782, ipa/97578, ipa/97660, ipa/97695,
-	ipa/97698, ipa/97816, jit/87291, libstdc++/55394, libstdc++/66146,
-	libstdc++/83938, libstdc++/84323, libstdc++/88101, libstdc++/92285,
-	libstdc++/92546, libstdc++/93421, libstdc++/93456, libstdc++/94971,
-	libstdc++/95989, libstdc++/96269, libstdc++/96958, libstdc++/97415,
-	libstdc++/97600, libstdc++/97613, libstdc++/97719, libstdc++/97729,
-	libstdc++/97731, libstdc++/97758, libstdc++/97798, libstdc++/97828,
-	libstdc++/97869, lto/97290, lto/97508, middle-end/85811,
-	middle-end/95673, middle-end/97267, middle-end/97556,
-	middle-end/97579, middle-end/97840, middle-end/97862,
-	middle-end/97879, objc/77404, objc/90707, objc/97854, other/97911,
-	pch/86674, pch/97593, preprocessor/97858, rtl-optimization/92180,
-	rtl-optimization/97705, sanitizer/95634, target/31799, target/85486,
-	target/91489, target/93449, target/96307, target/96770, target/96791,
-	target/96933, target/96967, target/96998, target/97140, target/97194,
-	target/97205, target/97326, target/97528, target/97532, target/97540,
-	target/97638, target/97682, target/97685, target/97715, target/97726,
-	target/97727, target/97730, target/97870, target/97873,
-	testsuite/80219, testsuite/85303, testsuite/97117, testsuite/97688,
-	testsuite/97788, testsuite/97797, testsuite/97803,
-	tree-optimization/80928, tree-optimization/83072,
-	tree-optimization/91029, tree-optimization/93781,
-	tree-optimization/94406, tree-optimization/96671,
-	tree-optimization/96789, tree-optimization/97223,
-	tree-optimization/97424, tree-optimization/97558,
-	tree-optimization/97609, tree-optimization/97623,
-	tree-optimization/97626, tree-optimization/97633,
-	tree-optimization/97650, tree-optimization/97678,
-	tree-optimization/97690, tree-optimization/97693,
-	tree-optimization/97706, tree-optimization/97709,
-	tree-optimization/97721, tree-optimization/97725,
-	tree-optimization/97732, tree-optimization/97733,
-	tree-optimization/97736, tree-optimization/97737,
-	tree-optimization/97741, tree-optimization/97746,
-	tree-optimization/97753, tree-optimization/97760,
-	tree-optimization/97761, tree-optimization/97764,
-	tree-optimization/97765, tree-optimization/97767,
-	tree-optimization/97769, tree-optimization/97780,
-	tree-optimization/97806, tree-optimization/97812,
-	tree-optimization/97830, tree-optimization/97835,
-	tree-optimization/97838, tree-optimization/97886,
-	tree-optimization/97888, tree-optimization/97897,
-	tree-optimization/97901
-- add BuildRequires: make and Requires: make, the latter for -flto reasons
-
-* Thu Oct 29 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.3
-- update from trunk
-  - PRs ada/97504, analyzer/96608, analyzer/97489, analyzer/97514,
-	analyzer/97568, analyzer/97608, bootstrap/97451, c++/82239, c++/86773,
-	c++/91741, c++/94799, c++/95132, c++/96241, c++/96575, c++/96675,
-	c++/96742, c++/97328, c++/97438, c++/97511, c++/97573, c/94722,
-	c/97463, fortran/45516, fortran/97454, gcov-profile/97461, ipa/97445,
-	ipa/97576, ipa/97586, libstdc++/94268, libstdc++/95592,
-	libstdc++/95609, libstdc++/95917, libstdc++/96713, libstdc++/97512,
-	libstdc++/97570, lto/96680, lto/97524, middle-end/92942,
-	middle-end/97521, middle-end/97552, rtl-optimization/97249,
-	rtl-optimization/97439, rtl-optimization/97497, sanitizer/97414,
-	target/87767, target/95151, target/95458, target/97360, target/97502,
-	target/97506, target/97535, testsuite/81690, testsuite/97590,
-	tree-optimization/66552, tree-optimization/97164,
-	tree-optimization/97360, tree-optimization/97456,
-	tree-optimization/97457, tree-optimization/97466,
-	tree-optimization/97467, tree-optimization/97486,
-	tree-optimization/97488, tree-optimization/97496,
-	tree-optimization/97500, tree-optimization/97501,
-	tree-optimization/97503, tree-optimization/97505,
-	tree-optimization/97515, tree-optimization/97520,
-	tree-optimization/97538, tree-optimization/97539,
-	tree-optimization/97546, tree-optimization/97555,
-	tree-optimization/97560, tree-optimization/97567,
-	tree-optimization/97615
-- for ELN default to -march=x86-64-v2 for x86 64-bit compilation and
-  for s390x to -march=z13 -mtune=arch13
-
-* Mon Oct 19 2020 Jakub Jelinek <jakub@redhat.com> 11.0.0-0.2
+* Sat Jan  8 2022 Jakub Jelinek <jakub@redhat.com> 12.0.0-0.3
 - new package

diff --git a/gcc11-Wno-format-security.patch b/gcc11-Wno-format-security.patch
deleted file mode 100644
index 974ea44..0000000
--- a/gcc11-Wno-format-security.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-2017-02-25  Jakub Jelinek  <jakub@redhat.com>
-
-	* configure.ac: When adding -Wno-format, also add -Wno-format-security.
-	* configure: Regenerated.
-
---- gcc/configure.ac.jj	2017-02-13 12:20:53.000000000 +0100
-+++ gcc/configure.ac	2017-02-25 12:42:32.859175403 +0100
-@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
-   AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
-   [],[enable_build_format_warnings=yes])
- AS_IF([test $enable_build_format_warnings = no],
--      [wf_opt=-Wno-format],[wf_opt=])
-+      [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
- ACX_PROG_CXX_WARNING_OPTS(
- 	m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
- 		       [-Wcast-qual -Wno-error=format-diag $wf_opt])),
---- gcc/configure.jj	2017-02-13 12:20:52.000000000 +0100
-+++ gcc/configure	2017-02-25 12:42:50.041946391 +0100
-@@ -6647,7 +6647,7 @@ else
- fi
- 
- if test $enable_build_format_warnings = no; then :
--  wf_opt=-Wno-format
-+  wf_opt="-Wno-format -Wno-format-security"
- else
-   wf_opt=
- fi

diff --git a/gcc11-d-shared-libphobos.patch b/gcc11-d-shared-libphobos.patch
deleted file mode 100644
index 6384bbb..0000000
--- a/gcc11-d-shared-libphobos.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-2019-01-17  Jakub Jelinek  <jakub@redhat.com>
-
-	* d-spec.cc (lang_specific_driver): Make -shared-libphobos
-	the default rather than -static-libphobos.
-
---- gcc/d/d-spec.cc.jj	2019-01-01 12:37:49.502444257 +0100
-+++ gcc/d/d-spec.cc	2019-01-17 17:09:45.364949246 +0100
-@@ -408,9 +408,9 @@ lang_specific_driver (cl_decoded_option
-   /* Add `-lgphobos' if we haven't already done so.  */
-   if (phobos_library != PHOBOS_NOLINK)
-     {
--      /* Default to static linking.  */
--      if (phobos_library != PHOBOS_DYNAMIC)
--	phobos_library = PHOBOS_STATIC;
-+      /* Default to shared linking.  */
-+      if (phobos_library != PHOBOS_STATIC)
-+	phobos_library = PHOBOS_DYNAMIC;
- 
- #ifdef HAVE_LD_STATIC_DYNAMIC
-       if (phobos_library == PHOBOS_STATIC && !static_link)

diff --git a/gcc11-foffload-default.patch b/gcc11-foffload-default.patch
deleted file mode 100644
index d1aae64..0000000
--- a/gcc11-foffload-default.patch
+++ /dev/null
@@ -1,116 +0,0 @@
-2019-01-17  Jakub Jelinek  <jakub@redhat.com>
-
-	* gcc.c (offload_targets_default): New variable.
-	(process_command): Set it if -foffload is defaulted.
-	(driver::maybe_putenv_OFFLOAD_TARGETS): Add OFFLOAD_TARGET_DEFAULT=1
-	into environment if -foffload has been defaulted.
-	* lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define.
-	(compile_offload_image): If OFFLOAD_TARGET_DEFAULT
-	is in the environment, don't fail if corresponding mkoffload
-	can't be found.
-	(compile_images_for_offload_targets): Likewise.  Free and clear
-	offload_names if no valid offload is found.
-libgomp/
-	* target.c (gomp_load_plugin_for_device): If a plugin can't be
-	dlopened, assume it has no devices silently.
-
---- gcc/gcc.c.jj	2017-01-17 10:28:40.000000000 +0100
-+++ gcc/gcc.c	2017-01-20 16:26:29.649962902 +0100
-@@ -319,6 +319,10 @@ static const char *spec_host_machine = D
- 
- static char *offload_targets = NULL;
- 
-+/* Set to true if -foffload has not been used and offload_targets
-+   is set to the configured in default.  */
-+static bool offload_targets_default;
-+
- /* Nonzero if cross-compiling.
-    When -b is used, the value comes from the `specs' file.  */
- 
-@@ -4828,7 +4832,10 @@ process_command (unsigned int decoded_op
-   /* If the user didn't specify any, default to all configured offload
-      targets.  */
-   if (ENABLE_OFFLOADING && offload_targets == NULL)
--    handle_foffload_option (OFFLOAD_TARGETS);
-+    {
-+      handle_foffload_option (OFFLOAD_TARGETS);
-+      offload_targets_default = true;
-+    }
- 
-   /* Handle -gtoggle as it would later in toplev.c:process_options to
-      make the debug-level-gt spec function work as expected.  */
-@@ -8494,6 +8501,8 @@ driver::maybe_putenv_OFFLOAD_TARGETS ()
-       obstack_grow (&collect_obstack, offload_targets,
- 		    strlen (offload_targets) + 1);
-       xputenv (XOBFINISH (&collect_obstack, char *));
-+      if (offload_targets_default)
-+	xputenv ("OFFLOAD_TARGET_DEFAULT=1");
-     }
- 
-   free (offload_targets);
---- gcc/lto-wrapper.c.jj	2017-01-01 12:45:34.000000000 +0100
-+++ gcc/lto-wrapper.c	2017-01-20 16:34:18.294016997 +0100
-@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
- /* Environment variable, used for passing the names of offload targets from GCC
-    driver to lto-wrapper.  */
- #define OFFLOAD_TARGET_NAMES_ENV	"OFFLOAD_TARGET_NAMES"
-+#define OFFLOAD_TARGET_DEFAULT_ENV	"OFFLOAD_TARGET_DEFAULT"
- 
- /* By default there is no special suffix for target executables.  */
- #ifdef TARGET_EXECUTABLE_SUFFIX
-@@ -906,6 +907,12 @@ compile_offload_image (const char *targe
- 	break;
-       }
- 
-+  if (!compiler && getenv (OFFLOAD_TARGET_DEFAULT_ENV))
-+    {
-+      free_array_of_ptrs ((void **) paths, n_paths);
-+      return NULL;
-+    }
-+
-   if (!compiler)
-     fatal_error (input_location,
- 		 "could not find %s in %s (consider using %<-B%>)",
-@@ -975,6 +982,7 @@ compile_images_for_offload_targets (unsi
-   if (!target_names)
-     return;
-   unsigned num_targets = parse_env_var (target_names, &names, NULL);
-+  int next_name_entry = 0;
- 
-   const char *compiler_path = getenv ("COMPILER_PATH");
-   if (!compiler_path)
-@@ -985,13 +993,19 @@ compile_images_for_offload_targets (unsi
-   offload_names = XCNEWVEC (char *, num_targets + 1);
-   for (unsigned i = 0; i < num_targets; i++)
-     {
--      offload_names[i]
-+      offload_names[next_name_entry]
- 	= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
- 				 compiler_opts, compiler_opt_count,
- 				 linker_opts, linker_opt_count);
--      if (!offload_names[i])
--	fatal_error (input_location,
--		     "problem with building target image for %s", names[i]);
-+      if (!offload_names[next_name_entry])
-+	continue;
-+      next_name_entry++;
-+    }
-+
-+  if (next_name_entry == 0)
-+    {
-+      free (offload_names);
-+      offload_names = NULL;
-     }
- 
-  out:
---- libgomp/target.c.jj	2017-01-01 12:45:52.000000000 +0100
-+++ libgomp/target.c	2017-01-20 20:12:13.756710875 +0100
-@@ -2356,7 +2356,7 @@ gomp_load_plugin_for_device (struct gomp
- 
-   void *plugin_handle = dlopen (plugin_name, RTLD_LAZY);
-   if (!plugin_handle)
--    goto dl_fail;
-+    return 0;
- 
-   /* Check if all required functions are available in the plugin and store
-      their handlers.  None of the symbols can legitimately be NULL,

diff --git a/gcc11-fortran-fdec-add-missing-indexes.patch b/gcc11-fortran-fdec-add-missing-indexes.patch
deleted file mode 100644
index d707b94..0000000
--- a/gcc11-fortran-fdec-add-missing-indexes.patch
+++ /dev/null
@@ -1,181 +0,0 @@
-From 7001d522d0273658d9e1fb12ca104d56bfcae34d Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 15:06:08 +0000
-Subject: [PATCH 10/10] Fill in missing array dimensions using the lower bound
-
-Use -fdec-add-missing-indexes to enable feature. Also enabled by fdec.
----
- gcc/fortran/lang.opt                  |  8 ++++++++
- gcc/fortran/options.c                 |  1 +
- gcc/fortran/resolve.c                 | 24 ++++++++++++++++++++++++
- gcc/testsuite/gfortran.dg/array_6.f90 | 23 +++++++++++++++++++++++
- gcc/testsuite/gfortran.dg/array_7.f90 | 23 +++++++++++++++++++++++
- gcc/testsuite/gfortran.dg/array_8.f90 | 23 +++++++++++++++++++++++
- 6 files changed, 102 insertions(+)
- create mode 100644 gcc/testsuite/gfortran.dg/array_6.f90
- create mode 100644 gcc/testsuite/gfortran.dg/array_7.f90
- create mode 100644 gcc/testsuite/gfortran.dg/array_8.f90
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 019c798cf09..f27de88ea3f 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -281,6 +281,10 @@ Wmissing-include-dirs
- Fortran
- ; Documented in C/C++
- 
-+Wmissing-index
-+Fortran Var(warn_missing_index) Warning LangEnabledBy(Fortran,Wall)
-+Warn that the lower bound of a missing index will be used.
-+
- Wuse-without-only
- Fortran Var(warn_use_without_only) Warning
- Warn about USE statements that have no ONLY qualifier.
-@@ -460,6 +464,10 @@ fdec
- Fortran Var(flag_dec)
- Enable all DEC language extensions.
- 
-+fdec-add-missing-indexes
-+Fortran Var(flag_dec_add_missing_indexes)
-+Enable the addition of missing indexes using their lower bounds.
-+
- fdec-blank-format-item
- Fortran Var(flag_dec_blank_format_item)
- Enable the use of blank format items in format strings.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index 050f56fdc25..c3b2822685d 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -84,6 +84,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_non_logical_if, value, value);
-   SET_BITFLAG (flag_dec_promotion, value, value);
-   SET_BITFLAG (flag_dec_sequence, value, value);
-+  SET_BITFLAG (flag_dec_add_missing_indexes, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
-index fe7d0cc5944..0efeedab46e 100644
---- a/gcc/fortran/resolve.c
-+++ b/gcc/fortran/resolve.c
-@@ -4806,6 +4806,30 @@ compare_spec_to_ref (gfc_array_ref *ar)
-   if (ar->type == AR_FULL)
-     return true;
- 
-+  if (flag_dec_add_missing_indexes && as->rank > ar->dimen)
-+    {
-+      /* Add in the missing dimensions, assuming they are the lower bound
-+	 of that dimension if not specified.  */
-+      int j;
-+      if (warn_missing_index)
-+	{
-+	  gfc_warning (OPT_Wmissing_index, "Using the lower bound for "
-+		       "unspecified dimensions in array reference at %L",
-+		       &ar->where);
-+	}
-+      /* Other parts of the code iterate ar->start and ar->end from 0 to
-+	 ar->dimen, so it is safe to assume slots from ar->dimen upwards
-+	 are unused (i.e. there are no gaps; the specified indexes are
-+	 contiguous and start at zero.  */
-+      for(j = ar->dimen; j <= as->rank; j++)
-+	{
-+	  ar->start[j] = gfc_copy_expr (as->lower[j]);
-+	  ar->end[j]   = gfc_copy_expr (as->lower[j]);
-+	  ar->dimen_type[j] = DIMEN_ELEMENT;
-+	}
-+      ar->dimen = as->rank;
-+    }
-+
-   if (as->rank != ar->dimen)
-     {
-       gfc_error ("Rank mismatch in array reference at %L (%d/%d)",
-diff --git a/gcc/testsuite/gfortran.dg/array_6.f90 b/gcc/testsuite/gfortran.dg/array_6.f90
-new file mode 100644
-index 00000000000..5c26e18ab3e
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/array_6.f90
-@@ -0,0 +1,23 @@
-+! { dg-do run }
-+! { dg-options "-fdec -Wmissing-index" }!
-+! Checks that under-specified arrays (referencing arrays with fewer
-+! dimensions than the array spec) generates a warning.
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
-+!
-+
-+program under_specified_array
-+    integer chessboard(8,8)
-+    integer chessboard3d(8,8,3:5)
-+    chessboard(3,1) = 5
-+    chessboard(3,2) = 55
-+    chessboard3d(4,1,3) = 6
-+    chessboard3d(4,1,4) = 66
-+    chessboard3d(4,4,3) = 7
-+    chessboard3d(4,4,4) = 77
-+  
-+    if (chessboard(3).ne.5) stop 1  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+    if (chessboard3d(4).ne.6) stop 2  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+end program
-diff --git a/gcc/testsuite/gfortran.dg/array_7.f90 b/gcc/testsuite/gfortran.dg/array_7.f90
-new file mode 100644
-index 00000000000..5588a5bd02d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/array_7.f90
-@@ -0,0 +1,23 @@
-+! { dg-do run }
-+! { dg-options "-fdec-add-missing-indexes -Wmissing-index" }!
-+! Checks that under-specified arrays (referencing arrays with fewer
-+! dimensions than the array spec) generates a warning.
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
-+!
-+
-+program under_specified_array
-+    integer chessboard(8,8)
-+    integer chessboard3d(8,8,3:5)
-+    chessboard(3,1) = 5
-+    chessboard(3,2) = 55
-+    chessboard3d(4,1,3) = 6
-+    chessboard3d(4,1,4) = 66
-+    chessboard3d(4,4,3) = 7
-+    chessboard3d(4,4,4) = 77
-+  
-+    if (chessboard(3).ne.5) stop 1  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+    if (chessboard3d(4).ne.6) stop 2  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
-+end program
-diff --git a/gcc/testsuite/gfortran.dg/array_8.f90 b/gcc/testsuite/gfortran.dg/array_8.f90
-new file mode 100644
-index 00000000000..f0d2ef5e37d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/array_8.f90
-@@ -0,0 +1,23 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-add-missing-indexes" }!
-+! Checks that under-specified arrays (referencing arrays with fewer
-+! dimensions than the array spec) generates a warning.
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
-+!
-+
-+program under_specified_array
-+    integer chessboard(8,8)
-+    integer chessboard3d(8,8,3:5)
-+    chessboard(3,1) = 5
-+    chessboard(3,2) = 55
-+    chessboard3d(4,1,3) = 6
-+    chessboard3d(4,1,4) = 66
-+    chessboard3d(4,4,3) = 7
-+    chessboard3d(4,4,4) = 77
-+  
-+    if (chessboard(3).ne.5) stop 1  ! { dg-error "Rank mismatch" }
-+    if (chessboard3d(4).ne.6) stop 2  ! { dg-error "Rank mismatch" }
-+    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-error "Rank mismatch" }
-+end program
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-duplicates.patch b/gcc11-fortran-fdec-duplicates.patch
deleted file mode 100644
index b5d1104..0000000
--- a/gcc11-fortran-fdec-duplicates.patch
+++ /dev/null
@@ -1,215 +0,0 @@
-From 23b1fcb104c666429451ffaf936f8da5fcd3d43a Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 12:29:47 +0000
-Subject: [PATCH 01/10] Allow duplicate declarations.
-
-Enabled by -fdec-duplicates and -fdec.
-
-Some fixes by Jim MacArthur <jim.macarthur@codethink.co.uk>
-Addition of -fdec-duplicates by Mark Eggleston <mark.eggleston@codethink.com>
----
- gcc/fortran/lang.opt                          |  4 ++++
- gcc/fortran/options.c                         |  1 +
- gcc/fortran/symbol.c                          | 21 +++++++++++++++++--
- .../gfortran.dg/duplicate_type_4.f90          | 13 ++++++++++++
- .../gfortran.dg/duplicate_type_5.f90          | 13 ++++++++++++
- .../gfortran.dg/duplicate_type_6.f90          | 13 ++++++++++++
- .../gfortran.dg/duplicate_type_7.f90          | 13 ++++++++++++
- .../gfortran.dg/duplicate_type_8.f90          | 12 +++++++++++
- .../gfortran.dg/duplicate_type_9.f90          | 12 +++++++++++
- 9 files changed, 100 insertions(+), 2 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_4.f90
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_5.f90
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_6.f90
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_7.f90
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_8.f90
- create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_9.f90
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 2b1977c523b..52bd522051e 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -469,6 +469,10 @@ Fortran Var(flag_dec_char_conversions)
- Enable the use of character literals in assignments and data statements
- for non-character variables.
- 
-+fdec-duplicates
-+Fortran Var(flag_dec_duplicates)
-+Allow varibles to be duplicated in the type specification matches.
-+
- fdec-include
- Fortran Var(flag_dec_include)
- Enable legacy parsing of INCLUDE as statement.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index 3a0b98bf1ec..f19ba87f8a0 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -77,6 +77,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_format_defaults, value, value);
-   SET_BITFLAG (flag_dec_blank_format_item, value, value);
-   SET_BITFLAG (flag_dec_char_conversions, value, value);
-+  SET_BITFLAG (flag_dec_duplicates, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
-index 3b988d1be22..9843175cc2a 100644
---- a/gcc/fortran/symbol.c
-+++ b/gcc/fortran/symbol.c
-@@ -1995,6 +1995,8 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
-   if (sym->attr.result && type == BT_UNKNOWN && sym->ns->proc_name)
-     type = sym->ns->proc_name->ts.type;
- 
-+  flavor = sym->attr.flavor;
-+
-   if (type != BT_UNKNOWN && !(sym->attr.function && sym->attr.implicit_type)
-       && !(gfc_state_stack->previous && gfc_state_stack->previous->previous
- 	   && gfc_state_stack->previous->previous->state == COMP_SUBMODULE)
-@@ -2007,6 +2009,23 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
-       else if (sym->attr.function && sym->attr.result)
- 	gfc_error ("Symbol %qs at %L already has basic type of %s",
- 		   sym->ns->proc_name->name, where, gfc_basic_typename (type));
-+      else if (flag_dec_duplicates)
-+	{
-+	  /* Ignore temporaries and class/procedure names */
-+	  if (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS
-+	      || sym->ts.type == BT_PROCEDURE)
-+	    return false;
-+
-+	  if (gfc_compare_types (&sym->ts, ts)
-+	      && (flavor == FL_UNKNOWN || flavor == FL_VARIABLE
-+	      || flavor == FL_PROCEDURE))
-+	    {
-+	      return gfc_notify_std (GFC_STD_LEGACY,
-+				     "Symbol '%qs' at %L already has "
-+				     "basic type of %s", sym->name, where,
-+				     gfc_basic_typename (type));
-+	    }
-+	}
-       else
- 	gfc_error ("Symbol %qs at %L already has basic type of %s", sym->name,
- 		   where, gfc_basic_typename (type));
-@@ -2020,8 +2039,6 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
-       return false;
-     }
- 
--  flavor = sym->attr.flavor;
--
-   if (flavor == FL_PROGRAM || flavor == FL_BLOCK_DATA || flavor == FL_MODULE
-       || flavor == FL_LABEL
-       || (flavor == FL_PROCEDURE && sym->attr.subroutine)
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_4.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
-new file mode 100644
-index 00000000000..cdd29ea8846
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
-@@ -0,0 +1,13 @@
-+! { dg-do compile }
-+! { dg-options "-std=f95" }
-+
-+! PR fortran/30239
-+! Check for errors when a symbol gets declared a type twice, even if it
-+! is the same.
-+
-+INTEGER FUNCTION foo ()
-+  IMPLICIT NONE
-+  INTEGER :: x
-+  INTEGER :: x ! { dg-error "basic type of" }
-+  x = 42
-+END FUNCTION foo
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_5.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_5.f90
-new file mode 100644
-index 00000000000..00f931809aa
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_5.f90
-@@ -0,0 +1,13 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+program test
-+  implicit none
-+  integer :: x
-+  integer :: x
-+  x = 42
-+  if (x /= 42) stop 1
-+end program test
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_6.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_6.f90
-new file mode 100644
-index 00000000000..f0df27e323c
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_6.f90
-@@ -0,0 +1,13 @@
-+! { dg-do run }
-+! { dg-options "-std=legacy -fdec-duplicates" }
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+program test
-+  implicit none
-+  integer :: x
-+  integer :: x
-+  x = 42
-+  if (x /= 42) stop 1
-+end program test
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_7.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_7.f90
-new file mode 100644
-index 00000000000..f32472ff586
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_7.f90
-@@ -0,0 +1,13 @@
-+! { dg-do run }
-+! { dg-options "-fdec-duplicates" }
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+program test
-+  implicit none
-+  integer :: x
-+  integer :: x! { dg-warning "Legacy Extension" }
-+  x = 42
-+  if (x /= 42) stop 1
-+end program test
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_8.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_8.f90
-new file mode 100644
-index 00000000000..23c94add179
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_8.f90
-@@ -0,0 +1,12 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-duplicates" }
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+integer function foo ()
-+  implicit none
-+  integer :: x
-+  integer :: x ! { dg-error "basic type of" }
-+  x = 42
-+end function foo
-diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_9.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_9.f90
-new file mode 100644
-index 00000000000..d5edee4d8ee
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/duplicate_type_9.f90
-@@ -0,0 +1,12 @@
-+! { dg-do compile }
-+! { dg-options "-fdec-duplicates -fno-dec-duplicates" }
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+integer function foo ()
-+  implicit none
-+  integer :: x
-+  integer :: x ! { dg-error "basic type of" }
-+  x = 42
-+end function foo
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-ichar.patch b/gcc11-fortran-fdec-ichar.patch
deleted file mode 100644
index e7b0522..0000000
--- a/gcc11-fortran-fdec-ichar.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From f883ac209b0feea860354cb4ef7ff06dc8063fab Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 12:53:35 +0000
-Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
-
-Use -fdec to enable.
----
- gcc/fortran/check.c                           |  2 +-
- gcc/fortran/simplify.c                        |  4 ++--
- .../gfortran.dg/dec_ichar_with_string_1.f     | 21 +++++++++++++++++++
- 3 files changed, 24 insertions(+), 3 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
-
-diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
-index 82db8e4e1b2..623c1cc470e 100644
---- a/gcc/fortran/check.c
-+++ b/gcc/fortran/check.c
-@@ -3157,7 +3157,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
-   else
-     return true;
- 
--  if (i != 1)
-+  if (i != 1 && !flag_dec)
-     {
-       gfc_error ("Argument of %s at %L must be of length one",
- 		 gfc_current_intrinsic, &c->where);
-diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
-index 23317a2e2d9..9900572424f 100644
---- a/gcc/fortran/simplify.c
-+++ b/gcc/fortran/simplify.c
-@@ -3261,7 +3261,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
-   if (e->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
--  if (e->value.character.length != 1)
-+  if (e->value.character.length != 1 && !flag_dec)
-     {
-       gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
-       return &gfc_bad_expr;
-@@ -3459,7 +3459,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
-   if (e->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
--  if (e->value.character.length != 1)
-+  if (e->value.character.length != 1 && !flag_dec)
-     {
-       gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
-       return &gfc_bad_expr;
-diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
-new file mode 100644
-index 00000000000..85efccecc0f
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
-@@ -0,0 +1,21 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test ICHAR and IACHAR with more than one character as argument
-+!
-+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM ichar_more_than_one_character
-+          CHARACTER*4 st/'Test'/
-+          INTEGER i
-+
-+          i = ICHAR(st)
-+          if (i.NE.84) STOP 1
-+          i = IACHAR(st)
-+          if (i.NE.84) STOP 2
-+          i = ICHAR('Test')
-+          if (i.NE.84) STOP 3
-+          i = IACHAR('Test')
-+          if (i.NE.84) STOP 4
-+        END
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-non-integer-index.patch b/gcc11-fortran-fdec-non-integer-index.patch
deleted file mode 100644
index 074df3b..0000000
--- a/gcc11-fortran-fdec-non-integer-index.patch
+++ /dev/null
@@ -1,158 +0,0 @@
-From 67aef262311d6a746786ee0f59748ccaa7e1e711 Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 13:09:54 +0000
-Subject: [PATCH 04/10] Allow non-integer substring indexes
-
-Use -fdec-non-integer-index compiler flag to enable. Also enabled by -fdec.
----
- gcc/fortran/lang.opt                          |  4 ++++
- gcc/fortran/options.c                         |  1 +
- gcc/fortran/resolve.c                         | 20 +++++++++++++++++++
- .../dec_not_integer_substring_indexes_1.f     | 18 +++++++++++++++++
- .../dec_not_integer_substring_indexes_2.f     | 18 +++++++++++++++++
- .../dec_not_integer_substring_indexes_3.f     | 18 +++++++++++++++++
- 6 files changed, 79 insertions(+)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index c4da248f07c..d527c106bd6 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -489,6 +489,10 @@ fdec-math
- Fortran Var(flag_dec_math)
- Enable legacy math intrinsics for compatibility.
- 
-+fdec-non-integer-index
-+Fortran Var(flag_dec_non_integer_index)
-+Enable support for non-integer substring indexes.
-+
- fdec-structure
- Fortran Var(flag_dec_structure)
- Enable support for DEC STRUCTURE/RECORD.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index f19ba87f8a0..9a042f64881 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -78,6 +78,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_blank_format_item, value, value);
-   SET_BITFLAG (flag_dec_char_conversions, value, value);
-   SET_BITFLAG (flag_dec_duplicates, value, value);
-+  SET_BITFLAG (flag_dec_non_integer_index, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
-index 4b90cb59902..bc0df0fdb99 100644
---- a/gcc/fortran/resolve.c
-+++ b/gcc/fortran/resolve.c
-@@ -5131,6 +5131,16 @@ gfc_resolve_substring (gfc_ref *ref, bool *equal_length)
-       if (!gfc_resolve_expr (ref->u.ss.start))
- 	return false;
- 
-+      /* In legacy mode, allow non-integer string indexes by converting */
-+      if (flag_dec_non_integer_index && ref->u.ss.start->ts.type != BT_INTEGER
-+	  && gfc_numeric_ts (&ref->u.ss.start->ts))
-+	{
-+	  gfc_typespec t;
-+	  t.type = BT_INTEGER;
-+	  t.kind = ref->u.ss.start->ts.kind;
-+	  gfc_convert_type_warn (ref->u.ss.start, &t, 2, 1);
-+	}
-+
-       if (ref->u.ss.start->ts.type != BT_INTEGER)
- 	{
- 	  gfc_error ("Substring start index at %L must be of type INTEGER",
-@@ -5160,6 +5170,16 @@ gfc_resolve_substring (gfc_ref *ref, bool *equal_length)
-       if (!gfc_resolve_expr (ref->u.ss.end))
- 	return false;
- 
-+      /* Non-integer string index endings, as for start */
-+      if (flag_dec_non_integer_index && ref->u.ss.end->ts.type != BT_INTEGER
-+	  && gfc_numeric_ts (&ref->u.ss.end->ts))
-+	{
-+	  gfc_typespec t;
-+	  t.type = BT_INTEGER;
-+	  t.kind = ref->u.ss.end->ts.kind;
-+	  gfc_convert_type_warn (ref->u.ss.end, &t, 2, 1);
-+	}
-+
-       if (ref->u.ss.end->ts.type != BT_INTEGER)
- 	{
- 	  gfc_error ("Substring end index at %L must be of type INTEGER",
-diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
-new file mode 100644
-index 00000000000..0be28abaa4b
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
-@@ -0,0 +1,18 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test not integer substring indexes
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM not_integer_substring_indexes
-+          CHARACTER*5 st/'Tests'/
-+          REAL ir/1.0/
-+          REAL ir2/4.0/
-+
-+          if (st(ir:4).ne.'Test') stop 1
-+          if (st(1:ir2).ne.'Test') stop 2
-+          if (st(1.0:4).ne.'Test') stop 3
-+          if (st(1:4.0).ne.'Test') stop 4
-+          if (st(2.5:4).ne.'est') stop 5
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
-new file mode 100644
-index 00000000000..3cf05296d0c
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
-@@ -0,0 +1,18 @@
-+! { dg-do run }
-+! { dg-options "-fdec-non-integer-index" }
-+!
-+! Test not integer substring indexes
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM not_integer_substring_indexes
-+          CHARACTER*5 st/'Tests'/
-+          REAL ir/1.0/
-+          REAL ir2/4.0/
-+
-+          if (st(ir:4).ne.'Test') stop 1
-+          if (st(1:ir2).ne.'Test') stop 2
-+          if (st(1.0:4).ne.'Test') stop 3
-+          if (st(1:4.0).ne.'Test') stop 4
-+          if (st(2.5:4).ne.'est') stop 5
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
-new file mode 100644
-index 00000000000..703de995897
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
-@@ -0,0 +1,18 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-non-integer-index" }
-+!
-+! Test not integer substring indexes
-+!
-+! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM not_integer_substring_indexes
-+          CHARACTER*5 st/'Tests'/
-+          REAL ir/1.0/
-+          REAL ir2/4.0/
-+
-+          if (st(ir:4).ne.'Test') stop 1 ! { dg-error "Substring start index" }
-+          if (st(1:ir2).ne.'Test') stop 2 ! { dg-error "Substring end index" }
-+          if (st(1.0:4).ne.'Test') stop 3 ! { dg-error "Substring start index" }
-+          if (st(1:4.0).ne.'Test') stop 4 ! { dg-error "Substring end index" }
-+          if (st(2.5:4).ne.'est') stop 5 ! { dg-error "Substring start index" }
-+        END
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-non-logical-if.patch b/gcc11-fortran-fdec-non-logical-if.patch
deleted file mode 100644
index 0133d23..0000000
--- a/gcc11-fortran-fdec-non-logical-if.patch
+++ /dev/null
@@ -1,378 +0,0 @@
-From cc87ddb841017bb0976b05091733609ee17d7f05 Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 13:15:17 +0000
-Subject: [PATCH 07/10] Allow non-logical expressions in IF statements
-
-Use -fdec-non-logical-if to enable feature. Also enabled using -fdec.
----
- gcc/fortran/lang.opt                          |  4 ++
- gcc/fortran/options.c                         |  1 +
- gcc/fortran/resolve.c                         | 60 ++++++++++++++++---
- ...gical_expressions_if_statements_blocks_1.f | 25 ++++++++
- ...gical_expressions_if_statements_blocks_2.f | 25 ++++++++
- ...gical_expressions_if_statements_blocks_3.f | 25 ++++++++
- ...gical_expressions_if_statements_blocks_4.f | 45 ++++++++++++++
- ...gical_expressions_if_statements_blocks_5.f | 45 ++++++++++++++
- ...gical_expressions_if_statements_blocks_6.f | 45 ++++++++++++++
- 9 files changed, 266 insertions(+), 9 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 4a269ebb22d..d886c2f33ed 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -497,6 +497,10 @@ fdec-override-kind
- Fortran Var(flag_dec_override_kind)
- Enable support for per variable kind specification.
- 
-+fdec-non-logical-if
-+Fortran Var(flag_dec_non_logical_if)
-+Enable support for non-logical expressions in if statements.
-+
- fdec-old-init
- Fortran Var(flag_dec_old_init)
- Enable support for old style initializers in derived types.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index edbab483b36..a946c86790a 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -81,6 +81,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_non_integer_index, value, value);
-   SET_BITFLAG (flag_dec_old_init, value, value);
-   SET_BITFLAG (flag_dec_override_kind, value, value);
-+  SET_BITFLAG (flag_dec_non_logical_if, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
-index bc0df0fdb99..07dd039f3bf 100644
---- a/gcc/fortran/resolve.c
-+++ b/gcc/fortran/resolve.c
-@@ -10789,10 +10789,31 @@ gfc_resolve_blocks (gfc_code *b, gfc_namespace *ns)
-       switch (b->op)
- 	{
- 	case EXEC_IF:
--	  if (t && b->expr1 != NULL
--	      && (b->expr1->ts.type != BT_LOGICAL || b->expr1->rank != 0))
--	    gfc_error ("IF clause at %L requires a scalar LOGICAL expression",
--		       &b->expr1->where);
-+	  if (t && b->expr1 != NULL)
-+	    {
-+	      if (flag_dec_non_logical_if && b->expr1->ts.type != BT_LOGICAL)
-+		{
-+		  gfc_expr* cast;
-+		  cast = gfc_ne (b->expr1,
-+				 gfc_get_int_expr (1, &gfc_current_locus, 0),
-+				 INTRINSIC_NE);
-+		  if (cast == NULL)
-+		    gfc_internal_error ("gfc_resolve_blocks(): Failed to cast "
-+					"to LOGICAL in IF");
-+		  b->expr1 = cast;
-+		  if (warn_conversion_extra)
-+		    {
-+		      gfc_warning (OPT_Wconversion_extra, "Non-LOGICAL type in"
-+				   " IF statement condition %L will be true if"
-+				   " it evaluates to nonzero",
-+				   &b->expr1->where);
-+		    }
-+		}
-+
-+	      if ((b->expr1->ts.type != BT_LOGICAL || b->expr1->rank != 0))
-+		gfc_error ("IF clause at %L requires a scalar LOGICAL "
-+			   "expression", &b->expr1->where);
-+	    }
- 	  break;
- 
- 	case EXEC_WHERE:
-@@ -12093,11 +12114,32 @@ start:
- 	  break;
- 
- 	case EXEC_IF:
--	  if (t && code->expr1 != NULL
--	      && (code->expr1->ts.type != BT_LOGICAL
--		  || code->expr1->rank != 0))
--	    gfc_error ("IF clause at %L requires a scalar LOGICAL expression",
--		       &code->expr1->where);
-+	  if (t && code->expr1 != NULL)
-+	    {
-+	      if (flag_dec_non_logical_if
-+		  && code->expr1->ts.type != BT_LOGICAL)
-+		{
-+		  gfc_expr* cast;
-+		  cast = gfc_ne (code->expr1,
-+				 gfc_get_int_expr (1, &gfc_current_locus, 0),
-+				 INTRINSIC_NE);
-+		  if (cast == NULL)
-+		    gfc_internal_error ("gfc_resolve_code(): Failed to cast "
-+					"to LOGICAL in IF");
-+		  code->expr1 = cast;
-+		  if (warn_conversion_extra)
-+		    {
-+		      gfc_warning (OPT_Wconversion_extra, "Non-LOGICAL type in"
-+				   " IF statement condition %L will be true if"
-+				   " it evaluates to nonzero",
-+				   &code->expr1->where);
-+		    }
-+		}
-+
-+	      if (code->expr1->ts.type != BT_LOGICAL || code->expr1->rank != 0)
-+		gfc_error ("IF clause at %L requires a scalar LOGICAL "
-+			   "expression", &code->expr1->where);
-+	    }
- 	  break;
- 
- 	case EXEC_CALL:
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
-new file mode 100644
-index 00000000000..0101db893ca
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
-@@ -0,0 +1,25 @@
-+! { dg-do run }
-+! { dg-options "-fdec -Wconversion-extra" }
-+!
-+! Allow logical expressions in if statements and blocks
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM logical_exp_if_st_bl
-+          INTEGER ipos/1/
-+          INTEGER ineg/0/
-+
-+          ! Test non logical variables
-+          if (ineg) STOP 1 ! { dg-warning "if it evaluates to nonzero" }
-+          if (0) STOP 2 ! { dg-warning "if it evaluates to nonzero" }
-+
-+          ! Test non logical expressions in if statements
-+          if (MOD(ipos, 1)) STOP 3 ! { dg-warning "if it evaluates to nonzero" }
-+
-+          ! Test non logical expressions in if blocks
-+          if (MOD(2 * ipos, 2)) then ! { dg-warning "if it evaluates to nonzero" }
-+            STOP 4
-+          endif
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
-new file mode 100644
-index 00000000000..876f4e09508
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
-@@ -0,0 +1,25 @@
-+! { dg-do run }
-+! { dg-options "-fdec-non-logical-if -Wconversion-extra" }
-+!
-+! Allow logical expressions in if statements and blocks
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM logical_exp_if_st_bl
-+          INTEGER ipos/1/
-+          INTEGER ineg/0/
-+
-+          ! Test non logical variables
-+          if (ineg) STOP 1 ! { dg-warning "if it evaluates to nonzero" }
-+          if (0) STOP 2 ! { dg-warning "if it evaluates to nonzero" }
-+
-+          ! Test non logical expressions in if statements
-+          if (MOD(ipos, 1)) STOP 3 ! { dg-warning "if it evaluates to nonzero" }
-+
-+          ! Test non logical expressions in if blocks
-+          if (MOD(2 * ipos, 2)) then ! { dg-warning "if it evaluates to nonzero" }
-+            STOP 4
-+          endif
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
-new file mode 100644
-index 00000000000..35cb4c51b8d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
-@@ -0,0 +1,25 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-non-logical-if" }
-+!
-+! Allow logical expressions in if statements and blocks
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM logical_exp_if_st_bl
-+          INTEGER ipos/1/
-+          INTEGER ineg/0/
-+
-+          ! Test non logical variables
-+          if (ineg) STOP 1 ! { dg-error "IF clause at" }
-+          if (0) STOP 2 ! { dg-error "IF clause at" }
-+
-+          ! Test non logical expressions in if statements
-+          if (MOD(ipos, 1)) STOP 3 ! { dg-error "IF clause at" }
-+
-+          ! Test non logical expressions in if blocks
-+          if (MOD(2 * ipos, 2)) then ! { dg-error "IF clause at" }
-+            STOP 4
-+          endif
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
-new file mode 100644
-index 00000000000..7b60b60827f
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
-@@ -0,0 +1,45 @@
-+! { dg-do run }
-+! { dg-options "-fdec -Wconversion-extra" }
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+       function othersub1()
-+        integer*4 othersub1
-+        othersub1 = 9
-+       end
-+
-+       function othersub2()
-+        integer*4 othersub2
-+        othersub2 = 0
-+       end
-+
-+       program MAIN
-+        integer*4 othersub1
-+        integer*4 othersub2
-+        integer a /1/
-+        integer b /2/        
-+ 
-+        if (othersub1()) then ! { dg-warning "if it evaluates to nonzero" }
-+           write(*,*) "OK"
-+        else
-+           stop 1
-+        end if
-+        if (othersub2()) then ! { dg-warning "if it evaluates to nonzero" }
-+           stop 2
-+        else
-+           write(*,*) "OK"
-+        end if
-+        if (a-b) then ! { dg-warning "if it evaluates to nonzero" }
-+           write(*,*) "OK"
-+        else
-+           stop 3
-+        end if
-+        if (b-(a+1)) then ! { dg-warning "if it evaluates to nonzero" }
-+           stop 3
-+        else
-+           write(*,*) "OK"
-+        end if
-+       end
-+
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
-new file mode 100644
-index 00000000000..80336f48ca1
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
-@@ -0,0 +1,45 @@
-+! { dg-do run }
-+! { dg-options "-fdec-non-logical-if -Wconversion-extra" }
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+       function othersub1()
-+        integer*4 othersub1
-+        othersub1 = 9
-+       end
-+
-+       function othersub2()
-+        integer*4 othersub2
-+        othersub2 = 0
-+       end
-+
-+       program MAIN
-+        integer*4 othersub1
-+        integer*4 othersub2
-+        integer a /1/
-+        integer b /2/        
-+ 
-+        if (othersub1()) then ! { dg-warning "Non-LOGICAL type in IF statement" }
-+           write(*,*) "OK"
-+        else
-+           stop 1
-+        end if
-+        if (othersub2()) then ! { dg-warning "Non-LOGICAL type in IF statement" }
-+           stop 2
-+        else
-+           write(*,*) "OK"
-+        end if
-+        if (a-b) then ! { dg-warning "Non-LOGICAL type in IF statement" }
-+           write(*,*) "OK"
-+        else
-+           stop 3
-+        end if
-+        if (b-(a+1)) then ! { dg-warning "Non-LOGICAL type in IF statement" }
-+           stop 3
-+        else
-+           write(*,*) "OK"
-+        end if
-+       end
-+
-diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
-new file mode 100644
-index 00000000000..e1125ca717a
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
-@@ -0,0 +1,45 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-non-logical-if" }
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+       function othersub1()
-+        integer*4 othersub1
-+        othersub1 = 9
-+       end
-+
-+       function othersub2()
-+        integer*4 othersub2
-+        othersub2 = 0
-+       end
-+
-+       program MAIN
-+        integer*4 othersub1
-+        integer*4 othersub2
-+        integer a /1/
-+        integer b /2/        
-+ 
-+        if (othersub1()) then ! { dg-error "IF clause at" }
-+           write(*,*) "OK"
-+        else
-+           stop 1
-+        end if
-+        if (othersub2()) then ! { dg-error "IF clause at" }
-+           stop 2
-+        else
-+           write(*,*) "OK"
-+        end if
-+        if (a-b) then ! { dg-error "IF clause at" }
-+           write(*,*) "OK"
-+        else
-+           stop 3
-+        end if
-+        if (b-(a+1)) then ! { dg-error "IF clause at" }
-+           stop 3
-+        else
-+           write(*,*) "OK"
-+        end if
-+       end
-+
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-old-init.patch b/gcc11-fortran-fdec-old-init.patch
deleted file mode 100644
index 8554f2e..0000000
--- a/gcc11-fortran-fdec-old-init.patch
+++ /dev/null
@@ -1,185 +0,0 @@
-From 8bcc0f85ed1718c0dd9033ad4a34df181aabaffe Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 13:11:06 +0000
-Subject: [PATCH 05/10] Allow old-style initializers in derived types
-
-This allows simple declarations in derived types and structures, such as:
-    LOGICAL*1      NIL      /0/
-Only single value expressions are allowed at the moment.
-
-Use -fdec-old-init to enable. Also enabled by -fdec.
----
- gcc/fortran/decl.c                            | 27 +++++++++++++++----
- gcc/fortran/lang.opt                          |  4 +++
- gcc/fortran/options.c                         |  1 +
- ...ec_derived_types_initialised_old_style_1.f | 25 +++++++++++++++++
- ...ec_derived_types_initialised_old_style_2.f | 25 +++++++++++++++++
- ...ec_derived_types_initialised_old_style_3.f | 26 ++++++++++++++++++
- 6 files changed, 103 insertions(+), 5 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
-
-diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
-index 723915822f3..5c8c1b7981b 100644
---- a/gcc/fortran/decl.c
-+++ b/gcc/fortran/decl.c
-@@ -2827,12 +2827,29 @@ variable_decl (int elem)
-          but not components of derived types.  */
-       else if (gfc_current_state () == COMP_DERIVED)
- 	{
--	  gfc_error ("Invalid old style initialization for derived type "
--		     "component at %C");
--	  m = MATCH_ERROR;
--	  goto cleanup;
-+	  if (flag_dec_old_init)
-+	    {
-+	      /* Attempt to match an old-style initializer which is a simple
-+		 integer or character expression; this will not work with
-+		 multiple values. */
-+	      m = gfc_match_init_expr (&initializer);
-+	      if (m == MATCH_ERROR)
-+		goto cleanup;
-+	      else if (m == MATCH_YES)
-+		{
-+		  m = gfc_match ("/");
-+		  if (m != MATCH_YES)
-+		    goto cleanup;
-+		}
-+	    }
-+	  else
-+	    {
-+	      gfc_error ("Invalid old style initialization for derived type "
-+			 "component at %C");
-+	      m = MATCH_ERROR;
-+	      goto cleanup;
-+	    }
- 	}
--
-       /* For structure components, read the initializer as a special
-          expression and let the rest of this function apply the initializer
-          as usual.  */
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index d527c106bd6..25cc948699b 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -493,6 +493,10 @@ fdec-non-integer-index
- Fortran Var(flag_dec_non_integer_index)
- Enable support for non-integer substring indexes.
- 
-+fdec-old-init
-+Fortran Var(flag_dec_old_init)
-+Enable support for old style initializers in derived types.
-+
- fdec-structure
- Fortran Var(flag_dec_structure)
- Enable support for DEC STRUCTURE/RECORD.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index 9a042f64881..d6bd36c3a8a 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -79,6 +79,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_char_conversions, value, value);
-   SET_BITFLAG (flag_dec_duplicates, value, value);
-   SET_BITFLAG (flag_dec_non_integer_index, value, value);
-+  SET_BITFLAG (flag_dec_old_init, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
-new file mode 100644
-index 00000000000..eac4f9bfcf1
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
-@@ -0,0 +1,25 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test old style initializers in derived types
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM spec_in_var
-+          TYPE STRUCT1
-+            INTEGER*4      ID       /8/
-+            INTEGER*4      TYPE     /5/
-+            INTEGER*8      DEFVAL   /0/
-+            CHARACTER*(5)  NAME     /'tests'/
-+            LOGICAL*1      NIL      /0/
-+          END TYPE STRUCT1
-+
-+          TYPE (STRUCT1) SINST
-+
-+          IF(SINST%ID.NE.8) STOP 1
-+          IF(SINST%TYPE.NE.5) STOP 2
-+          IF(SINST%DEFVAL.NE.0) STOP 3
-+          IF(SINST%NAME.NE.'tests') STOP 4
-+          IF(SINST%NIL) STOP 5
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
-new file mode 100644
-index 00000000000..d904c8b2974
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
-@@ -0,0 +1,25 @@
-+! { dg-do run }
-+! { dg-options "-std=legacy -fdec-old-init" }
-+!
-+! Test old style initializers in derived types
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM spec_in_var
-+          TYPE STRUCT1
-+            INTEGER*4      ID       /8/
-+            INTEGER*4      TYPE     /5/
-+            INTEGER*8      DEFVAL   /0/
-+            CHARACTER*(5)  NAME     /'tests'/
-+            LOGICAL*1      NIL      /0/
-+          END TYPE STRUCT1
-+
-+          TYPE (STRUCT1) SINST
-+
-+          IF(SINST%ID.NE.8) STOP 1
-+          IF(SINST%TYPE.NE.5) STOP 2
-+          IF(SINST%DEFVAL.NE.0) STOP 3
-+          IF(SINST%NAME.NE.'tests') STOP 4
-+          IF(SINST%NIL) STOP 5
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
-new file mode 100644
-index 00000000000..58c2b4b66cf
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
-@@ -0,0 +1,26 @@
-+! { dg-do compile }
-+! { dg-options "-std=legacy -fdec -fno-dec-old-init" }
-+!
-+! Test old style initializers in derived types
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+
-+        PROGRAM spec_in_var
-+          TYPE STRUCT1
-+            INTEGER*4      ID       /8/ ! { dg-error "Invalid old style initialization" }
-+            INTEGER*4      TYPE     /5/ ! { dg-error "Invalid old style initialization" }
-+            INTEGER*8      DEFVAL   /0/ ! { dg-error "Invalid old style initialization" }
-+            CHARACTER*(5)  NAME     /'tests'/ ! { dg-error "Invalid old style initialization" }
-+            LOGICAL*1      NIL      /0/ ! { dg-error "Invalid old style initialization" }
-+          END TYPE STRUCT1
-+
-+          TYPE (STRUCT1) SINST
-+
-+          IF(SINST%ID.NE.8) STOP 1 ! { dg-error "'id' at \\(1\\) is not a member" }
-+          IF(SINST%TYPE.NE.5) STOP 2 ! { dg-error "'type' at \\(1\\) is not a member" }
-+          IF(SINST%DEFVAL.NE.0) STOP 3  ! { dg-error "'defval' at \\(1\\) is not a member" }
-+          IF(SINST%NAME.NE.'tests') STOP 4 ! { dg-error "'name' at \\(1\\) is not a member" }
-+          IF(SINST%NIL) STOP 5 ! { dg-error "'nil' at \\(1\\) is not a member" }
-+        END
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-override-kind.patch b/gcc11-fortran-fdec-override-kind.patch
deleted file mode 100644
index e1c7b83..0000000
--- a/gcc11-fortran-fdec-override-kind.patch
+++ /dev/null
@@ -1,588 +0,0 @@
-From 786869fd62813e80da9b6545a295d53c36275c19 Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 13:12:14 +0000
-Subject: [PATCH 06/10] Allow string length and kind to be specified on a per
- variable basis.
-
-This allows kind/length to be mixed with array specification in
-declarations.
-
-e.g.
-
-      INTEGER*4 x*2, y*8
-      CHARACTER names*20(10)
-      REAL v(100)*8, vv*4(50)
-
-The per-variable size overrides the kind or length specified for the type.
-
-Use -fdec-override-kind to enable. Also enabled by -fdec.
-
-Note: this feature is a merger of two previously separate features.
-
-Now accepts named constants as kind parameters:
-
-      INTEGER A
-      PARAMETER (A=2)
-      INTEGER B*(A)
-
-Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-
-Now rejects invalid kind parameters and prints error messages:
-
-      INTEGER X*3
-
-caused an internal compiler error.
-
-Contributed by Mark Eggleston <mark.eggleston@codethink.com>
----
- gcc/fortran/decl.c                            | 156 ++++++++++++++----
- gcc/fortran/lang.opt                          |   4 +
- gcc/fortran/options.c                         |   1 +
- .../dec_mixed_char_array_declaration_1.f      |  13 ++
- .../dec_mixed_char_array_declaration_2.f      |  13 ++
- .../dec_mixed_char_array_declaration_3.f      |  13 ++
- .../gfortran.dg/dec_spec_in_variable_1.f      |  31 ++++
- .../gfortran.dg/dec_spec_in_variable_2.f      |  31 ++++
- .../gfortran.dg/dec_spec_in_variable_3.f      |  31 ++++
- .../gfortran.dg/dec_spec_in_variable_4.f      |  14 ++
- .../gfortran.dg/dec_spec_in_variable_5.f      |  19 +++
- .../gfortran.dg/dec_spec_in_variable_6.f      |  19 +++
- .../gfortran.dg/dec_spec_in_variable_7.f      |  15 ++
- .../gfortran.dg/dec_spec_in_variable_8.f      |  14 ++
- 14 files changed, 340 insertions(+), 34 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
-
-diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
-index 5c8c1b7981b..f7dc9d8263d 100644
---- a/gcc/fortran/decl.c
-+++ b/gcc/fortran/decl.c
-@@ -1213,6 +1213,54 @@ syntax:
-   return MATCH_ERROR;
- }
- 
-+/* This matches the nonstandard kind given after a variable name, like:
-+   INTEGER x*2, y*4
-+   The per-variable kind will override any kind given in the type
-+   declaration.
-+*/
-+
-+static match
-+match_per_symbol_kind (int *length)
-+{
-+  match m;
-+  gfc_expr *expr = NULL;
-+
-+  m = gfc_match_char ('*');
-+  if (m != MATCH_YES)
-+    return m;
-+
-+  m = gfc_match_small_literal_int (length, NULL);
-+  if (m == MATCH_YES || m == MATCH_ERROR)
-+    return m;
-+
-+  if (gfc_match_char ('(') == MATCH_NO)
-+    return MATCH_ERROR;
-+
-+  m = gfc_match_expr (&expr);
-+  if (m == MATCH_YES)
-+    {
-+      m = MATCH_ERROR; // Assume error
-+      if (gfc_expr_check_typed (expr, gfc_current_ns, false))
-+	{
-+	  if ((expr->expr_type == EXPR_CONSTANT)
-+	      && (expr->ts.type == BT_INTEGER))
-+	    {
-+	      *length = mpz_get_si(expr->value.integer);
-+	      m = MATCH_YES;
-+	    }
-+	}
-+
-+	if (m == MATCH_YES)
-+	  {
-+	    if (gfc_match_char (')') == MATCH_NO)
-+	       m = MATCH_ERROR;
-+  }
-+     }
-+
-+  if (expr != NULL)
-+     gfc_free_expr (expr);
-+  return m;
-+}
- 
- /* Special subroutine for finding a symbol.  Check if the name is found
-    in the current name space.  If not, and we're compiling a function or
-@@ -2443,6 +2491,35 @@ check_function_name (char *name)
- }
- 
- 
-+static match
-+match_character_length_clause (gfc_charlen **cl, bool *cl_deferred, int elem)
-+{
-+  gfc_expr* char_len;
-+  char_len = NULL;
-+
-+  match m = match_char_length (&char_len, cl_deferred, false);
-+  if (m == MATCH_YES)
-+    {
-+      *cl = gfc_new_charlen (gfc_current_ns, NULL);
-+      (*cl)->length = char_len;
-+    }
-+  else if (m == MATCH_NO)
-+    {
-+      if (elem > 1
-+	  && (current_ts.u.cl->length == NULL
-+	      || current_ts.u.cl->length->expr_type != EXPR_CONSTANT))
-+	{
-+	  *cl = gfc_new_charlen (gfc_current_ns, NULL);
-+	  (*cl)->length = gfc_copy_expr (current_ts.u.cl->length);
-+	}
-+      else
-+      *cl = current_ts.u.cl;
-+
-+      *cl_deferred = current_ts.deferred;
-+    }
-+  return m;
-+}
-+
- /* Match a variable name with an optional initializer.  When this
-    subroutine is called, a variable is expected to be parsed next.
-    Depending on what is happening at the moment, updates either the
-@@ -2453,7 +2530,7 @@ variable_decl (int elem)
- {
-   char name[GFC_MAX_SYMBOL_LEN + 1];
-   static unsigned int fill_id = 0;
--  gfc_expr *initializer, *char_len;
-+  gfc_expr *initializer;
-   gfc_array_spec *as;
-   gfc_array_spec *cp_as; /* Extra copy for Cray Pointees.  */
-   gfc_charlen *cl;
-@@ -2462,11 +2539,15 @@ variable_decl (int elem)
-   match m;
-   bool t;
-   gfc_symbol *sym;
-+  match cl_match;
-+  match kind_match;
-+  int overridden_kind;
-   char c;
- 
-   initializer = NULL;
-   as = NULL;
-   cp_as = NULL;
-+  kind_match = MATCH_NO;
- 
-   /* When we get here, we've just matched a list of attributes and
-      maybe a type and a double colon.  The next thing we expect to see
-@@ -2519,6 +2600,28 @@ variable_decl (int elem)
- 
-   var_locus = gfc_current_locus;
- 
-+
-+  cl = NULL;
-+  cl_deferred = false;
-+  cl_match = MATCH_NO;
-+
-+  /* Check for a character length clause before an array clause */
-+  if (flag_dec_override_kind)
-+    {
-+      if (current_ts.type == BT_CHARACTER)
-+	{
-+	  cl_match = match_character_length_clause (&cl, &cl_deferred, elem);
-+	  if (cl_match == MATCH_ERROR)
-+	    goto cleanup;
-+	}
-+      else
-+	{
-+	  kind_match = match_per_symbol_kind (&overridden_kind);
-+	  if (kind_match == MATCH_ERROR)
-+	    goto cleanup;
-+	}
-+    }
-+
-   /* Now we could see the optional array spec. or character length.  */
-   m = gfc_match_array_spec (&as, true, true);
-   if (m == MATCH_ERROR)
-@@ -2667,40 +2770,12 @@ variable_decl (int elem)
- 	}
-     }
- 
--  char_len = NULL;
--  cl = NULL;
--  cl_deferred = false;
--
--  if (current_ts.type == BT_CHARACTER)
-+  /* Second chance for a character length clause */
-+  if (cl_match == MATCH_NO && current_ts.type == BT_CHARACTER)
-     {
--      switch (match_char_length (&char_len, &cl_deferred, false))
--	{
--	case MATCH_YES:
--	  cl = gfc_new_charlen (gfc_current_ns, NULL);
--
--	  cl->length = char_len;
--	  break;
--
--	/* Non-constant lengths need to be copied after the first
--	   element.  Also copy assumed lengths.  */
--	case MATCH_NO:
--	  if (elem > 1
--	      && (current_ts.u.cl->length == NULL
--		  || current_ts.u.cl->length->expr_type != EXPR_CONSTANT))
--	    {
--	      cl = gfc_new_charlen (gfc_current_ns, NULL);
--	      cl->length = gfc_copy_expr (current_ts.u.cl->length);
--	    }
--	  else
--	    cl = current_ts.u.cl;
--
--	  cl_deferred = current_ts.deferred;
--
--	  break;
--
--	case MATCH_ERROR:
--	  goto cleanup;
--	}
-+      m = match_character_length_clause (&cl, &cl_deferred, elem);
-+      if (m == MATCH_ERROR)
-+	goto cleanup;
-     }
- 
-   /* The dummy arguments and result of the abreviated form of MODULE
-@@ -2802,6 +2877,19 @@ variable_decl (int elem)
-       goto cleanup;
-     }
- 
-+  if (kind_match == MATCH_YES)
-+    {
-+      gfc_find_symbol (name, gfc_current_ns, 1, &sym);
-+      /* sym *must* be found at this point */
-+      sym->ts.kind = overridden_kind;
-+      if (gfc_validate_kind (sym->ts.type, sym->ts.kind, true) < 0)
-+	{
-+	  gfc_error ("Kind %d not supported for type %s at %C",
-+		     sym->ts.kind, gfc_basic_typename (sym->ts.type));
-+	  return MATCH_ERROR;
-+	}
-+    }
-+
-   if (!check_function_name (name))
-     {
-       m = MATCH_ERROR;
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 25cc948699b..4a269ebb22d 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -493,6 +493,10 @@ fdec-non-integer-index
- Fortran Var(flag_dec_non_integer_index)
- Enable support for non-integer substring indexes.
- 
-+fdec-override-kind
-+Fortran Var(flag_dec_override_kind)
-+Enable support for per variable kind specification.
-+
- fdec-old-init
- Fortran Var(flag_dec_old_init)
- Enable support for old style initializers in derived types.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index d6bd36c3a8a..edbab483b36 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -80,6 +80,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_duplicates, value, value);
-   SET_BITFLAG (flag_dec_non_integer_index, value, value);
-   SET_BITFLAG (flag_dec_old_init, value, value);
-+  SET_BITFLAG (flag_dec_override_kind, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
-new file mode 100644
-index 00000000000..706ea4112a4
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
-@@ -0,0 +1,13 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test character declaration with mixed string length and array specification
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+       PROGRAM character_declaration
-+          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/
-+          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
-+          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
-new file mode 100644
-index 00000000000..26d2acf01de
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
-@@ -0,0 +1,13 @@
-+! { dg-do run }
-+! { dg-options "-fdec-override-kind" }
-+!
-+! Test character declaration with mixed string length and array specification
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM character_declaration
-+          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/
-+          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
-+          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
-new file mode 100644
-index 00000000000..76e4f0bdb93
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
-@@ -0,0 +1,13 @@
-+! { dg-do compile }
-+! { dg-options "-fdec-override-kind -fno-dec-override-kind" }
-+!
-+! Test character declaration with mixed string length and array specification
-+!
-+! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        PROGRAM character_declaration
-+          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/ ! { dg-error "Syntax error" }
-+          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
-+          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1 ! { dg-error " Operands of comparison operator" }
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
-new file mode 100644
-index 00000000000..edd0f5874b7
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
-@@ -0,0 +1,31 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test kind specification in variable not in type
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer*8  ai*1, bi*4, ci
-+          real*4 ar*4, br*8, cr
-+
-+          ai = 1
-+          ar = 1.0
-+          bi = 2
-+          br = 2.0
-+          ci = 3
-+          cr = 3.0
-+
-+          if (ai .ne. 1) stop 1
-+          if (abs(ar - 1.0) > 1.0D-6) stop 2
-+          if (bi .ne. 2) stop 3
-+          if (abs(br - 2.0) > 1.0D-6) stop 4
-+          if (ci .ne. 3) stop 5
-+          if (abs(cr - 3.0) > 1.0D-6) stop 6
-+          if (kind(ai) .ne. 1) stop 7
-+          if (kind(ar) .ne. 4) stop 8
-+          if (kind(bi) .ne. 4) stop 9
-+          if (kind(br) .ne. 8) stop 10
-+          if (kind(ci) .ne. 8) stop 11
-+          if (kind(cr) .ne. 4) stop 12
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
-new file mode 100644
-index 00000000000..bfaba584dbb
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
-@@ -0,0 +1,31 @@
-+! { dg-do run }
-+! { dg-options "-fdec-override-kind" }
-+!
-+! Test kind specification in variable not in type
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer*8  ai*1, bi*4, ci
-+          real*4 ar*4, br*8, cr
-+
-+          ai = 1
-+          ar = 1.0
-+          bi = 2
-+          br = 2.0
-+          ci = 3
-+          cr = 3.0
-+
-+          if (ai .ne. 1) stop 1
-+          if (abs(ar - 1.0) > 1.0D-6) stop 2
-+          if (bi .ne. 2) stop 3
-+          if (abs(br - 2.0) > 1.0D-6) stop 4
-+          if (ci .ne. 3) stop 5
-+          if (abs(cr - 3.0) > 1.0D-6) stop 6
-+          if (kind(ai) .ne. 1) stop 7
-+          if (kind(ar) .ne. 4) stop 8
-+          if (kind(bi) .ne. 4) stop 9
-+          if (kind(br) .ne. 8) stop 10
-+          if (kind(ci) .ne. 8) stop 11
-+          if (kind(cr) .ne. 4) stop 12
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
-new file mode 100644
-index 00000000000..5ff434e7466
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
-@@ -0,0 +1,31 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-override-kind" }
-+!
-+! Test kind specification in variable not in type
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer*8  ai*1, bi*4, ci ! { dg-error "Syntax error" }
-+          real*4 ar*4, br*8, cr ! { dg-error "Syntax error" }
-+
-+          ai = 1
-+          ar = 1.0
-+          bi = 2
-+          br = 2.0
-+          ci = 3
-+          cr = 3.0
-+
-+          if (ai .ne. 1) stop 1
-+          if (abs(ar - 1.0) > 1.0D-6) stop 2
-+          if (bi .ne. 2) stop 3
-+          if (abs(br - 2.0) > 1.0D-6) stop 4
-+          if (ci .ne. 3) stop 5
-+          if (abs(cr - 3.0) > 1.0D-6) stop 6
-+          if (kind(ai) .ne. 1) stop 7
-+          if (kind(ar) .ne. 4) stop 8
-+          if (kind(bi) .ne. 4) stop 9
-+          if (kind(br) .ne. 8) stop 10
-+          if (kind(ci) .ne. 8) stop 11
-+          if (kind(cr) .ne. 4) stop 12
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
-new file mode 100644
-index 00000000000..c01980e8b9d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
-@@ -0,0 +1,14 @@
-+! { dg-do compile }
-+!
-+! Test kind specification in variable not in type. The per variable
-+! kind specification is not enabled so these should fail
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer a
-+          parameter(a=2)
-+          integer b*(a) ! { dg-error "Syntax error" }
-+          real c*(8)    ! { dg-error "Syntax error" }
-+          logical d*1_1 ! { dg-error "Syntax error" }
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
-new file mode 100644
-index 00000000000..e2f39da3f4f
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
-@@ -0,0 +1,19 @@
-+! { dg-do run }
-+! { dg-options "-fdec-override-kind" }
-+!
-+! Test kind specification in variable not in type
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer a
-+          parameter(a=2)
-+          integer b*(a)
-+          real c*(8)
-+          logical d*(1_1)
-+          character e*(a)
-+          if (kind(b).ne.2) stop 1
-+          if (kind(c).ne.8) stop 2
-+          if (kind(d).ne.1) stop 3
-+          if (len(e).ne.2) stop 4
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
-new file mode 100644
-index 00000000000..569747874e3
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
-@@ -0,0 +1,19 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test kind specification in variable not in type
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer a
-+          parameter(a=2)
-+          integer b*(a)
-+          real c*(8)
-+          logical d*(1_1)
-+          character e*(a)
-+          if (kind(b).ne.2) stop 1
-+          if (kind(c).ne.8) stop 2
-+          if (kind(d).ne.1) stop 3
-+          if (len(e).ne.2) stop 4
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
-new file mode 100644
-index 00000000000..b975bfd15c5
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
-@@ -0,0 +1,15 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-override-kind" }
-+!
-+! Test kind specification in variable not in type as the per variable
-+! kind specification is not enables these should fail
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer a
-+          parameter(a=2)
-+          integer b*(a) ! { dg-error "Syntax error" }
-+          real c*(8)    ! { dg-error "Syntax error" }
-+          logical d*1_1 ! { dg-error "Syntax error" }
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
-new file mode 100644
-index 00000000000..85732e0bd85
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
-@@ -0,0 +1,14 @@
-+! { dg-do compile }
-+! { dg-options "-fdec" }
-+!
-+! Check that invalid kind values are rejected.
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        program spec_in_var
-+          integer a
-+          parameter(a=3)
-+          integer b*(a) ! { dg-error "Kind 3 not supported" }
-+          real c*(78)   ! { dg-error "Kind 78 not supported" }
-+          logical d*(*) ! { dg-error "Invalid character" }
-+        end
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-promotion.patch b/gcc11-fortran-fdec-promotion.patch
deleted file mode 100644
index 36e0ff0..0000000
--- a/gcc11-fortran-fdec-promotion.patch
+++ /dev/null
@@ -1,2093 +0,0 @@
-From 7a27318818e359a277f2fa5f7dc3932d0fb950f5 Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 14:58:07 +0000
-Subject: [PATCH 08/10] Support type promotion in calls to intrinsics
-
-Use -fdec-promotion or -fdec to enable this feature.
-
-Merged 2 commits: worked on by Ben Brewer <ben.brewer@codethink.co.uk>,
-Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> and
-Jeff Law <law@redhat.com>
-
-Re-worked by Mark Eggleston <mark.eggleston@codethink.com>
----
- gcc/fortran/check.c                           |  71 +++++-
- gcc/fortran/intrinsic.c                       |   5 +
- gcc/fortran/iresolve.c                        |  91 ++++---
- gcc/fortran/lang.opt                          |   4 +
- gcc/fortran/options.c                         |   1 +
- gcc/fortran/simplify.c                        | 240 ++++++++++++++----
- ...trinsic_int_real_array_const_promotion_1.f |  18 ++
- ...trinsic_int_real_array_const_promotion_2.f |  18 ++
- ...trinsic_int_real_array_const_promotion_3.f |  18 ++
- ...dec_intrinsic_int_real_const_promotion_1.f |  90 +++++++
- ...dec_intrinsic_int_real_const_promotion_2.f |  90 +++++++
- ...dec_intrinsic_int_real_const_promotion_3.f |  92 +++++++
- .../dec_intrinsic_int_real_promotion_1.f      | 130 ++++++++++
- .../dec_intrinsic_int_real_promotion_2.f      | 130 ++++++++++
- .../dec_intrinsic_int_real_promotion_3.f      | 130 ++++++++++
- .../dec_intrinsic_int_real_promotion_4.f      | 118 +++++++++
- .../dec_intrinsic_int_real_promotion_5.f      | 118 +++++++++
- .../dec_intrinsic_int_real_promotion_6.f      | 118 +++++++++
- .../dec_intrinsic_int_real_promotion_7.f      | 118 +++++++++
- .../gfortran.dg/dec_kind_promotion-1.f        |  40 +++
- .../gfortran.dg/dec_kind_promotion-2.f        |  40 +++
- .../gfortran.dg/dec_kind_promotion-3.f        |  39 +++
- 22 files changed, 1639 insertions(+), 80 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
-
-diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
-index 623c1cc470e..e20a834a860 100644
---- a/gcc/fortran/check.c
-+++ b/gcc/fortran/check.c
-@@ -1396,12 +1396,40 @@ gfc_check_allocated (gfc_expr *array)
- }
- 
- 
-+/* Check function where both arguments must be real or integer
-+   and warn if they are different types.  */
-+
-+bool
-+check_int_real_promotion (gfc_expr *a, gfc_expr *b)
-+{
-+  gfc_expr *i;
-+
-+  if (!int_or_real_check (a, 0))
-+    return false;
-+
-+  if (!int_or_real_check (b, 1))
-+    return false;
-+
-+  if (a->ts.type != b->ts.type)
-+    {
-+      i = (a->ts.type != BT_REAL ? a : b);
-+      gfc_warning_now (OPT_Wconversion, "Conversion from INTEGER to REAL "
-+		       "at %L might lose precision", &i->where);
-+    }
-+
-+  return true;
-+}
-+
-+
- /* Common check function where the first argument must be real or
-    integer and the second argument must be the same as the first.  */
- 
- bool
- gfc_check_a_p (gfc_expr *a, gfc_expr *p)
- {
-+  if (flag_dec_promotion)
-+    return check_int_real_promotion (a, p);
-+
-   if (!int_or_real_check (a, 0))
-     return false;
- 
-@@ -3724,6 +3752,41 @@ check_rest (bt type, int kind, gfc_actual_arglist *arglist)
- }
- 
- 
-+/* Check function where all arguments of an argument list must be real
-+   or integer.  */
-+
-+static bool
-+check_rest_int_real (gfc_actual_arglist *arglist)
-+{
-+  gfc_actual_arglist *arg, *tmp;
-+  gfc_expr *x;
-+  int m, n;
-+
-+  if (!min_max_args (arglist))
-+    return false;
-+
-+  for (arg = arglist, n=1; arg; arg = arg->next, n++)
-+    {
-+      x = arg->expr;
-+      if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
-+	{
-+	  gfc_error ("%<a%d%> argument of %qs intrinsic at %L must be "
-+		     "INTEGER or REAL", n, gfc_current_intrinsic, &x->where);
-+	  return false;
-+	}
-+
-+      for (tmp = arglist, m=1; tmp != arg; tmp = tmp->next, m++)
-+	if (!gfc_check_conformance (tmp->expr, x,
-+				    "arguments 'a%d' and 'a%d' for "
-+				    "intrinsic '%s'", m, n,
-+				    gfc_current_intrinsic))
-+	  return false;
-+    }
-+
-+  return true;
-+}
-+
-+
- bool
- gfc_check_min_max (gfc_actual_arglist *arg)
- {
-@@ -3748,7 +3811,10 @@ gfc_check_min_max (gfc_actual_arglist *arg)
-       return false;
-     }
- 
--  return check_rest (x->ts.type, x->ts.kind, arg);
-+  if (flag_dec_promotion && x->ts.type != BT_CHARACTER)
-+    return check_rest_int_real (arg);
-+  else
-+    return check_rest (x->ts.type, x->ts.kind, arg);
- }
- 
- 
-@@ -5121,6 +5187,9 @@ gfc_check_shift (gfc_expr *i, gfc_expr *shift)
- bool
- gfc_check_sign (gfc_expr *a, gfc_expr *b)
- {
-+  if (flag_dec_promotion)
-+    return check_int_real_promotion (a, b);
-+
-   if (!int_or_real_check (a, 0))
-     return false;
- 
-diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
-index e68eff8bdbb..81b3a24c2be 100644
---- a/gcc/fortran/intrinsic.c
-+++ b/gcc/fortran/intrinsic.c
-@@ -4467,6 +4467,11 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym,
-       if (ts.kind == 0)
- 	ts.kind = actual->expr->ts.kind;
- 
-+      /* If kind promotion is allowed don't check for kind if it is smaller */
-+      if (flag_dec_promotion && ts.type == BT_INTEGER)
-+	if (actual->expr->ts.kind < ts.kind)
-+	  ts.kind = actual->expr->ts.kind;
-+
-       if (!gfc_compare_types (&ts, &actual->expr->ts))
- 	{
- 	  if (error_flag)
-diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
-index e17fe45f080..b9cdaff2499 100644
---- a/gcc/fortran/iresolve.c
-+++ b/gcc/fortran/iresolve.c
-@@ -817,19 +817,22 @@ gfc_resolve_dble (gfc_expr *f, gfc_expr *a)
- void
- gfc_resolve_dim (gfc_expr *f, gfc_expr *a, gfc_expr *p)
- {
--  f->ts.type = a->ts.type;
-   if (p != NULL)
--    f->ts.kind = gfc_kind_max (a,p);
--  else
--    f->ts.kind = a->ts.kind;
--
--  if (p != NULL && a->ts.kind != p->ts.kind)
-     {
--      if (a->ts.kind == gfc_kind_max (a,p))
--	gfc_convert_type (p, &a->ts, 2);
-+      f->ts.kind = gfc_kind_max (a,p);
-+      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
-+	f->ts.type = BT_REAL;
-       else
--	gfc_convert_type (a, &p->ts, 2);
-+	f->ts.type = BT_INTEGER;
-+
-+      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
-+	gfc_convert_type (a, &f->ts, 2);
-+
-+      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
-+	gfc_convert_type (p, &f->ts, 2);
-     }
-+  else
-+    f->ts = a->ts;
- 
-   f->value.function.name
-     = gfc_get_string ("__dim_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
-@@ -1606,14 +1609,17 @@ gfc_resolve_minmax (const char *name, gfc_expr *f, gfc_actual_arglist *args)
-   /* Find the largest type kind.  */
-   for (a = args->next; a; a = a->next)
-     {
-+      if (a->expr-> ts.type == BT_REAL)
-+	f->ts.type = BT_REAL;
-+
-       if (a->expr->ts.kind > f->ts.kind)
- 	f->ts.kind = a->expr->ts.kind;
-     }
- 
--  /* Convert all parameters to the required kind.  */
-+  /* Convert all parameters to the required type and/or kind.  */
-   for (a = args; a; a = a->next)
-     {
--      if (a->expr->ts.kind != f->ts.kind)
-+      if (a->expr->ts.type != f->ts.type || a->expr->ts.kind != f->ts.kind)
- 	gfc_convert_type (a->expr, &f->ts, 2);
-     }
- 
-@@ -2106,19 +2112,22 @@ gfc_resolve_minval (gfc_expr *f, gfc_expr *array, gfc_expr *dim,
- void
- gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
- {
--  f->ts.type = a->ts.type;
-   if (p != NULL)
--    f->ts.kind = gfc_kind_max (a,p);
--  else
--    f->ts.kind = a->ts.kind;
--
--  if (p != NULL && a->ts.kind != p->ts.kind)
-     {
--      if (a->ts.kind == gfc_kind_max (a,p))
--	gfc_convert_type (p, &a->ts, 2);
-+      f->ts.kind = gfc_kind_max (a,p);
-+      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
-+	f->ts.type = BT_REAL;
-       else
--	gfc_convert_type (a, &p->ts, 2);
-+	f->ts.type = BT_INTEGER;
-+
-+      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
-+	gfc_convert_type (a, &f->ts, 2);
-+
-+      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
-+	gfc_convert_type (p, &f->ts, 2);
-     }
-+  else
-+    f->ts = a->ts;
- 
-   f->value.function.name
-     = gfc_get_string ("__mod_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
-@@ -2128,19 +2137,22 @@ gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
- void
- gfc_resolve_modulo (gfc_expr *f, gfc_expr *a, gfc_expr *p)
- {
--  f->ts.type = a->ts.type;
-   if (p != NULL)
--    f->ts.kind = gfc_kind_max (a,p);
--  else
--    f->ts.kind = a->ts.kind;
--
--  if (p != NULL && a->ts.kind != p->ts.kind)
-     {
--      if (a->ts.kind == gfc_kind_max (a,p))
--	gfc_convert_type (p, &a->ts, 2);
-+      f->ts.kind = gfc_kind_max (a,p);
-+      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
-+	f->ts.type = BT_REAL;
-       else
--	gfc_convert_type (a, &p->ts, 2);
-+	f->ts.type = BT_INTEGER;
-+
-+      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
-+	gfc_convert_type (a, &f->ts, 2);
-+
-+      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
-+	gfc_convert_type (p, &f->ts, 2);
-     }
-+  else
-+    f->ts = a->ts;
- 
-   f->value.function.name
-     = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f->ts.type),
-@@ -2515,9 +2527,26 @@ gfc_resolve_shift (gfc_expr *f, gfc_expr *i, gfc_expr *shift ATTRIBUTE_UNUSED)
- 
- 
- void
--gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b ATTRIBUTE_UNUSED)
-+gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b)
- {
--  f->ts = a->ts;
-+  if (b != NULL)
-+    {
-+      f->ts.kind = gfc_kind_max (a, b);
-+      if (a->ts.type == BT_REAL || b->ts.type == BT_REAL)
-+	f->ts.type = BT_REAL;
-+      else
-+	f->ts.type = BT_INTEGER;
-+
-+      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
-+	gfc_convert_type (a, &f->ts, 2);
-+
-+      if (b->ts.kind != f->ts.kind || b->ts.type != f->ts.type)
-+	gfc_convert_type (b, &f->ts, 2);
-+    }
-+  else
-+    {
-+      f->ts = a->ts;
-+    }
-   f->value.function.name
-     = gfc_get_string ("__sign_%c%d", gfc_type_letter (a->ts.type), a->ts.kind);
- }
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index d886c2f33ed..4ca2f93f2df 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -505,6 +505,10 @@ fdec-old-init
- Fortran Var(flag_dec_old_init)
- Enable support for old style initializers in derived types.
- 
-+fdec-promotion
-+Fortran Var(flag_dec_promotion)
-+Add support for type promotion in intrinsic arguments.
-+
- fdec-structure
- Fortran Var(flag_dec_structure)
- Enable support for DEC STRUCTURE/RECORD.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index a946c86790a..15079c7e95a 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -82,6 +82,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_old_init, value, value);
-   SET_BITFLAG (flag_dec_override_kind, value, value);
-   SET_BITFLAG (flag_dec_non_logical_if, value, value);
-+  SET_BITFLAG (flag_dec_promotion, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
-index 9900572424f..3419e06fec2 100644
---- a/gcc/fortran/simplify.c
-+++ b/gcc/fortran/simplify.c
-@@ -2333,39 +2333,79 @@ gfc_simplify_digits (gfc_expr *x)
- }
- 
- 
-+/* Simplify function which sets the floating-point value of ar from
-+   the value of a independently if a is integer of real.  */
-+
-+static void
-+simplify_int_real_promotion (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar)
-+{
-+  if (a->ts.type == BT_REAL)
-+    {
-+      mpfr_init2 (*ar, (a->ts.kind * 8));
-+      mpfr_set (*ar, a->value.real, GFC_RND_MODE);
-+    }
-+  else
-+    {
-+      mpfr_init2 (*ar, (b->ts.kind * 8));
-+      mpfr_set_z (*ar, a->value.integer, GFC_RND_MODE);
-+    }
-+}
-+
-+
-+/* Simplify function which promotes a and b arguments from integer to real if
-+   required in ar and br floating-point values. This function returns true if
-+   a or b are reals and false otherwise. */
-+
-+static bool
-+simplify_int_real_promotion2 (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar,
-+			      mpfr_t *br)
-+{
-+  if (a->ts.type != BT_REAL && b->ts.type != BT_REAL)
-+    return false;
-+
-+  simplify_int_real_promotion (a, b, ar);
-+  simplify_int_real_promotion (b, a, br);
-+
-+  return true;
-+}
-+
-+
- gfc_expr *
- gfc_simplify_dim (gfc_expr *x, gfc_expr *y)
- {
-   gfc_expr *result;
-   int kind;
- 
-+  mpfr_t xr;
-+  mpfr_t yr;
-+
-   if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
--  kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
--  result = gfc_get_constant_expr (x->ts.type, kind, &x->where);
--
--  switch (x->ts.type)
-+  if ((x->ts.type != BT_REAL && x->ts.type != BT_INTEGER)
-+      || (y->ts.type != BT_REAL && y->ts.type != BT_INTEGER))
-     {
--      case BT_INTEGER:
--	if (mpz_cmp (x->value.integer, y->value.integer) > 0)
--	  mpz_sub (result->value.integer, x->value.integer, y->value.integer);
--	else
--	  mpz_set_ui (result->value.integer, 0);
--
--	break;
--
--      case BT_REAL:
--	if (mpfr_cmp (x->value.real, y->value.real) > 0)
--	  mpfr_sub (result->value.real, x->value.real, y->value.real,
--		    GFC_RND_MODE);
--	else
--	  mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
-+      gfc_internal_error ("gfc_simplify_dim(): Bad arguments");
-+      return NULL;
-+    }
- 
--	break;
-+  kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
- 
--      default:
--	gfc_internal_error ("gfc_simplify_dim(): Bad type");
-+  if (simplify_int_real_promotion2 (x, y, &xr, &yr))
-+    {
-+      result = gfc_get_constant_expr (BT_REAL, kind, &x->where);
-+      if (mpfr_cmp (xr, yr) > 0)
-+	mpfr_sub (result->value.real, xr, yr, GFC_RND_MODE);
-+      else
-+	mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
-+    }
-+  else
-+    {
-+      result = gfc_get_constant_expr (BT_INTEGER, kind, &x->where);
-+      if (mpz_cmp (x->value.integer, y->value.integer) > 0)
-+	mpz_sub (result->value.integer, x->value.integer, y->value.integer);
-+      else
-+	mpz_set_ui (result->value.integer, 0);
-     }
- 
-   return range_check (result, "DIM");
-@@ -4953,6 +4993,76 @@ min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign, bool back_val)
- {
-   int ret;
- 
-+  mpfr_t *arp;
-+  mpfr_t *erp;
-+  mpfr_t ar;
-+  mpfr_t er;
-+
-+  if (arg->ts.type != extremum->ts.type)
-+    {
-+      if (arg->ts.type == BT_REAL)
-+	{
-+	  arp = &arg->value.real;
-+	}
-+      else
-+	{
-+	  mpfr_init2 (ar, (arg->ts.kind * 8));
-+	  mpfr_set_z (ar, arg->value.integer, GFC_RND_MODE);
-+	  arp = &ar;
-+	}
-+
-+      if (extremum->ts.type == BT_REAL)
-+	{
-+	  erp = &extremum->value.real;
-+	}
-+      else
-+	{
-+	  mpfr_init2 (er, (extremum->ts.kind * 8));
-+	  mpfr_set_z (er, extremum->value.integer, GFC_RND_MODE);
-+	  erp = &er;
-+	}
-+
-+      if (mpfr_nan_p (*erp))
-+	{
-+	  ret = 1;
-+	  extremum->ts.type = arg->ts.type;
-+	  extremum->ts.kind = arg->ts.kind;
-+	  if (arg->ts.type == BT_INTEGER)
-+	    {
-+	      mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
-+	      mpz_set (extremum->value.integer, arg->value.integer);
-+	    }
-+	  else
-+	    {
-+	      mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
-+	      mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
-+	    }
-+	}
-+      else if (mpfr_nan_p (*arp))
-+	ret = -1;
-+      else
-+	{
-+	  ret = mpfr_cmp (*arp, *erp) * sign;
-+	  if (ret > 0)
-+	    {
-+	      extremum->ts.type = arg->ts.type;
-+	      extremum->ts.kind = arg->ts.kind;
-+	      if (arg->ts.type == BT_INTEGER)
-+		{
-+		  mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
-+		  mpz_set (extremum->value.integer, arg->value.integer);
-+		}
-+	      else
-+		{
-+		  mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
-+		  mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
-+		}
-+	    }
-+	}
-+
-+      return ret;
-+    }
-+
-   switch (arg->ts.type)
-     {
-       case BT_INTEGER:
-@@ -5912,7 +6022,9 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
-   gfc_expr *result;
-   int kind;
- 
--  /* First check p.  */
-+  mpfr_t ar;
-+  mpfr_t pr;
-+
-   if (p->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
-@@ -5942,16 +6054,24 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
-   if (a->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
-+  if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
-+    {
-+      gfc_internal_error ("gfc_simplify_mod(): Bad arguments");
-+      return NULL;
-+    }
-+
-   kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
--  result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
- 
--  if (a->ts.type == BT_INTEGER)
--    mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
--  else
-+  if (simplify_int_real_promotion2 (a, p, &ar, &pr))
-     {
-+      result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
-       gfc_set_model_kind (kind);
--      mpfr_fmod (result->value.real, a->value.real, p->value.real,
--		 GFC_RND_MODE);
-+      mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
-+    }
-+  else
-+    {
-+      result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
-+      mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
-     }
- 
-   return range_check (result, "MOD");
-@@ -5964,7 +6084,9 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
-   gfc_expr *result;
-   int kind;
- 
--  /* First check p.  */
-+  mpfr_t ar;
-+  mpfr_t pr;
-+
-   if (p->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
-@@ -5991,28 +6113,36 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
- 	gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
-     }
- 
-+  if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
-+    {
-+      gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
-+      return NULL;
-+    }
-+
-   if (a->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
-   kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
--  result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
- 
--  if (a->ts.type == BT_INTEGER)
--	mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
--  else
-+  if (simplify_int_real_promotion2 (a, p, &ar, &pr))
-     {
-+      result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
-       gfc_set_model_kind (kind);
--      mpfr_fmod (result->value.real, a->value.real, p->value.real,
--                 GFC_RND_MODE);
-+      mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
-       if (mpfr_cmp_ui (result->value.real, 0) != 0)
--        {
--          if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real))
--            mpfr_add (result->value.real, result->value.real, p->value.real,
--                      GFC_RND_MODE);
--	    }
--	  else
--        mpfr_copysign (result->value.real, result->value.real,
--                       p->value.real, GFC_RND_MODE);
-+	{
-+	  if (mpfr_signbit (ar) != mpfr_signbit (pr))
-+	    mpfr_add (result->value.real, result->value.real, pr,
-+		      GFC_RND_MODE);
-+	}
-+      else
-+	mpfr_copysign (result->value.real, result->value.real, pr,
-+		       GFC_RND_MODE);
-+    }
-+  else
-+    {
-+      result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
-+      mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
-     }
- 
-   return range_check (result, "MODULO");
-@@ -7578,27 +7708,41 @@ gfc_expr *
- gfc_simplify_sign (gfc_expr *x, gfc_expr *y)
- {
-   gfc_expr *result;
-+  bool neg;
- 
-   if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
-     return NULL;
- 
-   result = gfc_get_constant_expr (x->ts.type, x->ts.kind, &x->where);
- 
-+  switch (y->ts.type)
-+    {
-+      case BT_INTEGER:
-+	neg = (mpz_sgn (y->value.integer) < 0);
-+	break;
-+
-+      case BT_REAL:
-+	neg = (mpfr_sgn (y->value.real) < 0);
-+	break;
-+
-+      default:
-+	gfc_internal_error ("Bad type in gfc_simplify_sign");
-+    }
-+
-   switch (x->ts.type)
-     {
-       case BT_INTEGER:
- 	mpz_abs (result->value.integer, x->value.integer);
--	if (mpz_sgn (y->value.integer) < 0)
-+	if (neg)
- 	  mpz_neg (result->value.integer, result->value.integer);
- 	break;
- 
-       case BT_REAL:
--	if (flag_sign_zero)
-+	if (flag_sign_zero && y->ts.type == BT_REAL)
- 	  mpfr_copysign (result->value.real, x->value.real, y->value.real,
--			GFC_RND_MODE);
-+			 GFC_RND_MODE);
- 	else
--	  mpfr_setsign (result->value.real, x->value.real,
--			mpfr_sgn (y->value.real) < 0 ? 1 : 0, GFC_RND_MODE);
-+	  mpfr_setsign (result->value.real, x->value.real, neg, GFC_RND_MODE);
- 	break;
- 
-       default:
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
-new file mode 100644
-index 00000000000..25763852139
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
-@@ -0,0 +1,18 @@
-+! { dg-do compile }
-+! { dg-options "-fdec" }
-+!
-+! Test promotion between integers and reals for mod and modulo where
-+! A is a constant array and P is zero.
-+!
-+! Compilation errors are expected
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program promotion_int_real_array_const
-+          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "shall not be zero" }
-+          a = mod([12.0, 34.0], 0)*4          ! { dg-error "shall not be zero" }
-+          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
-+          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "shall not be zero" }
-+      end program
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
-new file mode 100644
-index 00000000000..b78a46054f4
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
-@@ -0,0 +1,18 @@
-+! { dg-do compile }
-+! { dg-options "-fdec-promotion" }
-+!
-+! Test promotion between integers and reals for mod and modulo where
-+! A is a constant array and P is zero.
-+!
-+! Compilation errors are expected
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program promotion_int_real_array_const
-+          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "shall not be zero" }
-+          a = mod([12.0, 34.0], 0)*4          ! { dg-error "shall not be zero" }
-+          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
-+          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "shall not be zero" }
-+      end program
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
-new file mode 100644
-index 00000000000..318ab5db97e
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
-@@ -0,0 +1,18 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-promotion" }
-+!
-+! Test promotion between integers and reals for mod and modulo where
-+! A is a constant array and P is zero.
-+!
-+! Compilation errors are expected
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program promotion_int_real_array_const
-+          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "'a' and 'p' arguments of 'mod'" }
-+          a = mod([12.0, 34.0], 0)*4          ! { dg-error "'a' and 'p' arguments of 'mod'" }
-+          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "'a' and 'p' arguments of 'modulo'" }
-+          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "'a' and 'p' arguments of 'modulo'" }
-+      end program
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
-new file mode 100644
-index 00000000000..27eb2582bb2
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
-@@ -0,0 +1,90 @@
-+! { dg-do run }
-+! { dg-options "-fdec -finit-real=snan" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real_const
-+        ! array_nan 4th position value is NAN
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(4, 3)
-+        if (m_i .ne. 1) STOP 1
-+        m_r = MOD(4.0, 3.0)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
-+        m_r = MOD(4, 3.0)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(4.0, 3)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+
-+        md_i = MODULO(4, 3)
-+        if (md_i .ne. 1) STOP 5
-+        md_r = MODULO(4.0, 3.0)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
-+        md_r = MODULO(4, 3.0)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
-+        md_r = MODULO(4.0, 3)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
-+
-+        d_i = DIM(4, 3)
-+        if (d_i .ne. 1) STOP 9
-+        d_r = DIM(4.0, 3.0)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
-+        d_r = DIM(4.0, 3)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
-+        d_r = DIM(3, 4.0)
-+        if (abs(d_r) > 1.0D-6) STOP 12
-+
-+        s_i = SIGN(-4, 3)
-+        if (s_i .ne. 4) STOP 13
-+        s_r = SIGN(4.0, -3.0)
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
-+        s_r = SIGN(4.0, -3)
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
-+        s_r = SIGN(-4, 3.0)
-+        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
-+
-+        mx_i = MAX(-4, -3, 2, 1)
-+        if (mx_i .ne. 2) STOP 17
-+        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
-+        mx_r = MAX(-4, -3.0, 2.0, 1)
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 20
-+
-+        mn_i = MIN(-4, -3, 2, 1)
-+        if (mn_i .ne. -4) STOP 21
-+        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
-+        mn_r = MIN(-4, -3.0, 2.0, 1)
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 24
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
-new file mode 100644
-index 00000000000..bdd017b7280
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
-@@ -0,0 +1,90 @@
-+! { dg-do run }
-+! { dg-options "-fdec-promotion -finit-real=snan" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real_const
-+        ! array_nan 4th position value is NAN
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(4, 3)
-+        if (m_i .ne. 1) STOP 1
-+        m_r = MOD(4.0, 3.0)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
-+        m_r = MOD(4, 3.0)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(4.0, 3)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+
-+        md_i = MODULO(4, 3)
-+        if (md_i .ne. 1) STOP 5
-+        md_r = MODULO(4.0, 3.0)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
-+        md_r = MODULO(4, 3.0)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
-+        md_r = MODULO(4.0, 3)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
-+
-+        d_i = DIM(4, 3)
-+        if (d_i .ne. 1) STOP 9
-+        d_r = DIM(4.0, 3.0)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
-+        d_r = DIM(4.0, 3)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
-+        d_r = DIM(3, 4.0)
-+        if (abs(d_r) > 1.0D-6) STOP 12
-+
-+        s_i = SIGN(-4, 3)
-+        if (s_i .ne. 4) STOP 13
-+        s_r = SIGN(4.0, -3.0)
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
-+        s_r = SIGN(4.0, -3)
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
-+        s_r = SIGN(-4, 3.0)
-+        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
-+
-+        mx_i = MAX(-4, -3, 2, 1)
-+        if (mx_i .ne. 2) STOP 17
-+        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
-+        mx_r = MAX(-4, -3.0, 2.0, 1)
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 20
-+
-+        mn_i = MIN(-4, -3, 2, 1)
-+        if (mn_i .ne. -4) STOP 21
-+        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
-+        mn_r = MIN(-4, -3.0, 2.0, 1)
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 24
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
-new file mode 100644
-index 00000000000..ce90a5667d6
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
-@@ -0,0 +1,92 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-promotion -finit-real=snan" }
-+!
-+! Test that there is no promotion between integers and reals in
-+! intrinsic operations.
-+!
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real_const
-+        ! array_nan 4th position value is NAN
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(4, 3)
-+        if (m_i .ne. 1) STOP 1
-+        m_r = MOD(4.0, 3.0)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
-+        m_r = MOD(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+
-+        md_i = MODULO(4, 3)
-+        if (md_i .ne. 1) STOP 5
-+        md_r = MODULO(4.0, 3.0)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
-+        md_r = MODULO(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
-+        md_r = MODULO(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
-+
-+        d_i = DIM(4, 3)
-+        if (d_i .ne. 1) STOP 9
-+        d_r = DIM(4.0, 3.0)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
-+        d_r = DIM(4.0, 3) ! { dg-error "'x' and 'y' arguments" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
-+        d_r = DIM(3, 4.0) ! { dg-error "'x' and 'y' arguments" }
-+        if (abs(d_r) > 1.0D-6) STOP 12
-+
-+        s_i = SIGN(-4, 3)
-+        if (s_i .ne. 4) STOP 13
-+        s_r = SIGN(4.0, -3.0)
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
-+        s_r = SIGN(4.0, -3) ! { dg-error "'b' argument" }
-+        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
-+        s_r = SIGN(-4, 3.0) ! { dg-error "'b' argument" }
-+        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
-+
-+        mx_i = MAX(-4, -3, 2, 1)
-+        if (mx_i .ne. 2) STOP 17
-+        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
-+        mx_r = MAX(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
-+        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 20
-+
-+        mn_i = MIN(-4, -3, 2, 1)
-+        if (mn_i .ne. -4) STOP 21
-+        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
-+        mn_r = MIN(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
-+        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 24
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
-new file mode 100644
-index 00000000000..5c2cd931a4b
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
-@@ -0,0 +1,130 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        INTEGER a_i/4/
-+        INTEGER*4 a2_i/4/
-+        INTEGER b_i/3/
-+        INTEGER*8 b2_i/3/
-+        INTEGER x_i/2/
-+        INTEGER y_i/1/
-+        REAL a_r/4.0/
-+        REAL*4 a2_r/4.0/
-+        REAL b_r/3.0/
-+        REAL*8 b2_r/3.0/
-+        REAL x_r/2.0/
-+        REAL y_r/1.0/
-+
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        ! array_nan 4th position value is NAN
-+        array_nan(4) = 0/l
-+
-+        m_i = MOD(a_i, b_i)
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_i, b2_i)
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_r, b_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_r, b2_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_i, b_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_r, b_i)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_i, b_i)
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_i, b2_i)
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_r, b_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_r, b2_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_i, b_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_r, b_i)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_i, b_i)
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_i, b2_i)
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_r, b_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_r, b2_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_r, b_i)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_i, a_r)
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_i, b_i)
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_i, b2_i)
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_r, -b_r)
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
-+        s_r = SIGN(a2_r, -b2_r)
-+        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
-+        s_r = SIGN(a_r, -b_i)
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
-+        s_r = SIGN(-a_i, b_r)
-+        if (abs(s_r - a_r) > 1.0D-6) STOP 24
-+
-+        mx_i = MAX(-a_i, -b_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 25
-+        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 26
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
-+        mx_r = MAX(-a_i, -b_r, x_r, y_i)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 30
-+
-+        mn_i = MIN(-a_i, -b_i, x_i, y_i)
-+        if (mn_i .ne. -a_i) STOP 31
-+        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
-+        if (mn_i .ne. -a2_i) STOP 32
-+        mn_r = MIN(-a_r, -b_r, x_r, y_r)
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
-+        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
-+        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
-+        mn_r = MIN(-a_i, -b_r, x_r, y_i)
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 36
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
-new file mode 100644
-index 00000000000..d64d468f7d1
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
-@@ -0,0 +1,130 @@
-+! { dg-do run }
-+! { dg-options "-fdec-promotion" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        INTEGER a_i/4/
-+        INTEGER*4 a2_i/4/
-+        INTEGER b_i/3/
-+        INTEGER*8 b2_i/3/
-+        INTEGER x_i/2/
-+        INTEGER y_i/1/
-+        REAL a_r/4.0/
-+        REAL*4 a2_r/4.0/
-+        REAL b_r/3.0/
-+        REAL*8 b2_r/3.0/
-+        REAL x_r/2.0/
-+        REAL y_r/1.0/
-+
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        ! array_nan 4th position value is NAN
-+        array_nan(4) = 0/l
-+
-+        m_i = MOD(a_i, b_i)
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_i, b2_i)
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_r, b_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_r, b2_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_i, b_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_r, b_i)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_i, b_i)
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_i, b2_i)
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_r, b_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_r, b2_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_i, b_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_r, b_i)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_i, b_i)
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_i, b2_i)
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_r, b_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_r, b2_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_r, b_i)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_i, a_r)
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_i, b_i)
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_i, b2_i)
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_r, -b_r)
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
-+        s_r = SIGN(a2_r, -b2_r)
-+        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
-+        s_r = SIGN(a_r, -b_i)
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
-+        s_r = SIGN(-a_i, b_r)
-+        if (abs(s_r - a_r) > 1.0D-6) STOP 24
-+
-+        mx_i = MAX(-a_i, -b_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 25
-+        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 26
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
-+        mx_r = MAX(-a_i, -b_r, x_r, y_i)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 30
-+
-+        mn_i = MIN(-a_i, -b_i, x_i, y_i)
-+        if (mn_i .ne. -a_i) STOP 31
-+        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
-+        if (mn_i .ne. -a2_i) STOP 32
-+        mn_r = MIN(-a_r, -b_r, x_r, y_r)
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
-+        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
-+        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
-+        mn_r = MIN(-a_i, -b_r, x_r, y_i)
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 36
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
-new file mode 100644
-index 00000000000..0708b666633
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
-@@ -0,0 +1,130 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-promotion" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        INTEGER a_i/4/
-+        INTEGER*4 a2_i/4/
-+        INTEGER b_i/3/
-+        INTEGER*8 b2_i/3/
-+        INTEGER x_i/2/
-+        INTEGER y_i/1/
-+        REAL a_r/4.0/
-+        REAL*4 a2_r/4.0/
-+        REAL b_r/3.0/
-+        REAL*8 b2_r/3.0/
-+        REAL x_r/2.0/
-+        REAL y_r/1.0/
-+
-+        REAL array_nan(4)
-+        DATA array_nan(1)/-4.0/
-+        DATA array_nan(2)/3.0/
-+        DATA array_nan(3)/-2/
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        ! array_nan 4th position value is NAN
-+        array_nan(4) = 0/l
-+
-+        m_i = MOD(a_i, b_i)
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_i, b2_i)
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_r, b_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_r, b2_r)
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_i, b_i)
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_i, b2_i)
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_r, b_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_r, b2_r)
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_i, b_i)
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_i, b2_i)
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_r, b_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_r, b2_r)
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_r, b_i) ! { dg-error "'x' and 'y' arguments" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_i, a_r) ! { dg-error "'x' and 'y' arguments" }
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_i, b_i)
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_i, b2_i) ! { dg-error "'b' argument" }
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_r, -b_r)
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
-+        s_r = SIGN(a2_r, -b2_r) ! { dg-error "'b' argument" }
-+        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
-+        s_r = SIGN(a_r, -b_i) ! { dg-error "'b' argument" }
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
-+        s_r = SIGN(-a_i, b_r) ! { dg-error "'b' argument" }
-+        if (abs(s_r - a_r) > 1.0D-6) STOP 24
-+
-+        mx_i = MAX(-a_i, -b_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 25
-+        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
-+        if (mx_i .ne. x_i) STOP 26
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
-+        mx_r = MAX(-a_r, -b_r, x_r, y_r)
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
-+        mx_r = MAX(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
-+        mx_i = MAXLOC(array_nan, 1)
-+        if (mx_i .ne. 2) STOP 30
-+
-+        mn_i = MIN(-a_i, -b_i, x_i, y_i)
-+        if (mn_i .ne. -a_i) STOP 31
-+        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
-+        if (mn_i .ne. -a2_i) STOP 32
-+        mn_r = MIN(-a_r, -b_r, x_r, y_r)
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
-+        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
-+        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
-+        mn_r = MIN(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
-+        mn_i = MINLOC(array_nan, 1)
-+        if (mn_i .ne. 1) STOP 36
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
-new file mode 100644
-index 00000000000..efa4f236410
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
-@@ -0,0 +1,118 @@
-+! { dg-do compile }
-+! { dg-options "-fdec" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        LOGICAL a_l
-+        LOGICAL*4 a2_l
-+        LOGICAL b_l
-+        LOGICAL*8 b2_l
-+        LOGICAL x_l
-+        LOGICAL y_l
-+        CHARACTER a_c
-+        CHARACTER*4 a2_c
-+        CHARACTER b_c
-+        CHARACTER*8 b2_c
-+        CHARACTER x_c
-+        CHARACTER y_c
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(a_l, b_l)                     ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_l, b2_l)                   ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_c, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_c, b2_c)                   ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_l, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_c, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_l, b_l)                 ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_l, b2_l)               ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_c, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_c, b2_c)               ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_l, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_c, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_l, b_l)                     ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_l, b2_l)                   ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_c, b_c)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_c, b2_c)                   ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_c, b_l)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_l, a_c)                     ! { dg-error "" }
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_l, b_l)                   ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_l, b2_l)                 ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_c, -b_c)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
-+        s_r = SIGN(a2_c, -b2_c)                 ! { dg-error "" }
-+        if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
-+        s_r = SIGN(a_c, -b_l)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
-+        s_r = SIGN(-a_l, b_c)                   ! { dg-error "" }
-+        if (abs(s_r - a_c) > 1.0D-6) STOP 24    ! { dg-error "" }
-+
-+        mx_i = MAX(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
-+        if (mx_i .ne. x_l) STOP 25              ! { dg-error "" }
-+        mx_i = MAX(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
-+        if (mx_i .ne. x_l) STOP 26              ! { dg-error "" }
-+        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 27   ! { dg-error "" }
-+        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 28   ! { dg-error "" }
-+        mx_r = MAX(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 29   ! { dg-error "" }
-+
-+        mn_i = MIN(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
-+        if (mn_i .ne. -a_l) STOP 31             ! { dg-error "" }
-+        mn_i = MIN(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
-+        if (mn_i .ne. -a2_l) STOP 32            ! { dg-error "" }
-+        mn_r = MIN(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
-+        mn_r = MIN(-a2_c, -b2_c, x_c, y_c)      ! { dg-error "" }
-+        if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
-+        mn_r = MIN(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
-new file mode 100644
-index 00000000000..d023af5086d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
-@@ -0,0 +1,118 @@
-+! { dg-do compile }
-+! { dg-options "-fdec-promotion" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        LOGICAL a_l
-+        LOGICAL*4 a2_l
-+        LOGICAL b_l
-+        LOGICAL*8 b2_l
-+        LOGICAL x_l
-+        LOGICAL y_l
-+        CHARACTER a_c
-+        CHARACTER*4 a2_c
-+        CHARACTER b_c
-+        CHARACTER*8 b2_c
-+        CHARACTER x_c
-+        CHARACTER y_c
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(a_l, b_l)                     ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_l, b2_l)                   ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_c, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_c, b2_c)                   ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_l, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_c, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_l, b_l)                 ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_l, b2_l)               ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_c, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_c, b2_c)               ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_l, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_c, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_l, b_l)                     ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_l, b2_l)                   ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_c, b_c)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_c, b2_c)                   ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_c, b_l)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_l, a_c)                     ! { dg-error "" }
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_l, b_l)                   ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_l, b2_l)                 ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_c, -b_c)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
-+        s_r = SIGN(a2_c, -b2_c)                 ! { dg-error "" }
-+        if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
-+        s_r = SIGN(a_c, -b_l)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
-+        s_r = SIGN(-a_l, b_c)                   ! { dg-error "" }
-+        if (abs(s_r - a_c) > 1.0D-6) STOP 24    ! { dg-error "" }
-+
-+        mx_i = MAX(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
-+        if (mx_i .ne. x_l) STOP 25              ! { dg-error "" }
-+        mx_i = MAX(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
-+        if (mx_i .ne. x_l) STOP 26              ! { dg-error "" }
-+        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 27   ! { dg-error "" }
-+        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 28   ! { dg-error "" }
-+        mx_r = MAX(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_c) > 1.0D-6) STOP 29   ! { dg-error "" }
-+
-+        mn_i = MIN(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
-+        if (mn_i .ne. -a_l) STOP 31             ! { dg-error "" }
-+        mn_i = MIN(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
-+        if (mn_i .ne. -a2_l) STOP 32            ! { dg-error "" }
-+        mn_r = MIN(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
-+        mn_r = MIN(-a2_c, -b2_c, x_c, y_c)      ! { dg-error "" }
-+        if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
-+        mn_r = MIN(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
-new file mode 100644
-index 00000000000..00f8fb88f1b
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
-@@ -0,0 +1,118 @@
-+! { dg-do compile }
-+! { dg-options "-fdec" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        INTEGER a_i/4/
-+        INTEGER*4 a2_i/4/
-+        CHARACTER b_c
-+        CHARACTER*8 b2_c
-+        INTEGER x_i/2/
-+        CHARACTER y_c
-+        REAL a_r/4.0/
-+        REAL*4 a2_r/4.0/
-+        LOGICAL b_l
-+        LOGICAL*8 b2_l
-+        REAL x_r/2.0/
-+        LOGICAL y_l
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(a_i, b_c)                     ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_i, b2_c)                   ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_r, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_r, b2_l)                   ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_i, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_r, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_i, b_c)                 ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_i, b2_c)               ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_r, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_r, b2_l)               ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_i, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_r, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_i, b_c)                     ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_i, b2_c)                   ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_r, b_l)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_r, b2_l)                   ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_r, b_c)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_c, a_r)                     ! { dg-error "" }
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_i, b_c)                   ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_i, b2_c)                 ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_r, -b_l)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
-+        s_r = SIGN(a2_r, -b2_l)                 ! { dg-error "" }
-+        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
-+        s_r = SIGN(a_r, -b_c)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
-+        s_r = SIGN(-a_i, b_l)                   ! { dg-error "" }
-+        if (abs(s_r - a_r) > 1.0D-6) STOP 24
-+
-+        mx_i = MAX(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
-+        if (mx_i .ne. x_i) STOP 25
-+        mx_i = MAX(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
-+        if (mx_i .ne. x_i) STOP 26
-+        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
-+        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
-+        mx_r = MAX(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
-+
-+        mn_i = MIN(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
-+        if (mn_i .ne. -a_i) STOP 31
-+        mn_i = MIN(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
-+        if (mn_i .ne. -a2_i) STOP 32
-+        mn_r = MIN(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
-+        mn_r = MIN(-a2_r, -b2_l, x_r, y_l)      ! { dg-error "" }
-+        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
-+        mn_r = MIN(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
-new file mode 100644
-index 00000000000..1d4150d81c0
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
-@@ -0,0 +1,118 @@
-+! { dg-do compile }
-+! { dg-options "-fdec-promotion" }
-+!
-+! Test promotion between integers and reals in intrinsic operations.
-+! These operations are: mod, modulo, dim, sign, min, max, minloc and
-+! maxloc.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+!             and Jeff Law <law@redhat.com>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      PROGRAM promotion_int_real
-+        REAL l/0.0/
-+        INTEGER a_i/4/
-+        INTEGER*4 a2_i/4/
-+        CHARACTER b_c
-+        CHARACTER*8 b2_c
-+        INTEGER x_i/2/
-+        CHARACTER y_c
-+        REAL a_r/4.0/
-+        REAL*4 a2_r/4.0/
-+        LOGICAL b_l
-+        LOGICAL*8 b2_l
-+        REAL x_r/2.0/
-+        LOGICAL y_l
-+
-+        INTEGER m_i/0/
-+        REAL m_r/0.0/
-+
-+        INTEGER md_i/0/
-+        REAL md_r/0.0/
-+
-+        INTEGER d_i/0/
-+        REAL d_r/0.0/
-+
-+        INTEGER s_i/0/
-+        REAL s_r/0.0/
-+
-+        INTEGER mn_i/0/
-+        REAL mn_r/0.0/
-+
-+        INTEGER mx_i/0/
-+        REAL mx_r/0.0/
-+
-+        m_i = MOD(a_i, b_c)                     ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 1
-+        m_i = MOD(a2_i, b2_c)                   ! { dg-error "" }
-+        if (m_i .ne. 1) STOP 2
-+        m_r = MOD(a_r, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
-+        m_r = MOD(a2_r, b2_l)                   ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
-+        m_r = MOD(a_i, b_l)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
-+        m_r = MOD(a_r, b_c)                     ! { dg-error "" }
-+        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
-+
-+        md_i = MODULO(a_i, b_c)                 ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 7
-+        md_i = MODULO(a2_i, b2_c)               ! { dg-error "" }
-+        if (md_i .ne. 1) STOP 8
-+        md_r = MODULO(a_r, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
-+        md_r = MODULO(a2_r, b2_l)               ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
-+        md_r = MODULO(a_i, b_l)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
-+        md_r = MODULO(a_r, b_c)                 ! { dg-error "" }
-+        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
-+
-+        d_i = DIM(a_i, b_c)                     ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 13
-+        d_i = DIM(a2_i, b2_c)                   ! { dg-error "" }
-+        if (d_i .ne. 1) STOP 14
-+        d_r = DIM(a_r, b_l)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
-+        d_r = DIM(a2_r, b2_l)                   ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
-+        d_r = DIM(a_r, b_c)                     ! { dg-error "" }
-+        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
-+        d_r = DIM(b_c, a_r)                     ! { dg-error "" }
-+        if (abs(d_r) > 1.0D-6) STOP 18
-+
-+        s_i = SIGN(-a_i, b_c)                   ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 19
-+        s_i = SIGN(-a2_i, b2_c)                 ! { dg-error "" }
-+        if (s_i .ne. 4) STOP 20
-+        s_r = SIGN(a_r, -b_l)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
-+        s_r = SIGN(a2_r, -b2_l)                 ! { dg-error "" }
-+        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
-+        s_r = SIGN(a_r, -b_c)                   ! { dg-error "" }
-+        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
-+        s_r = SIGN(-a_i, b_l)                   ! { dg-error "" }
-+        if (abs(s_r - a_r) > 1.0D-6) STOP 24
-+
-+        mx_i = MAX(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
-+        if (mx_i .ne. x_i) STOP 25
-+        mx_i = MAX(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
-+        if (mx_i .ne. x_i) STOP 26
-+        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
-+        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
-+        mx_r = MAX(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
-+        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
-+
-+        mn_i = MIN(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
-+        if (mn_i .ne. -a_i) STOP 31
-+        mn_i = MIN(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
-+        if (mn_i .ne. -a2_i) STOP 32
-+        mn_r = MIN(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
-+        mn_r = MIN(-a2_r, -b2_l, x_r, y_l)      ! { dg-error "" }
-+        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
-+        mn_r = MIN(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
-+        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
-+      END PROGRAM
-diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
-new file mode 100644
-index 00000000000..435bf98350c
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
-@@ -0,0 +1,40 @@
-+!{ dg-do run }
-+!{ dg-options "-fdec" }
-+!
-+! integer types of a smaller kind than expected should be
-+! accepted by type specific intrinsic functions
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program test_small_type_promtion
-+        implicit none
-+        integer(1) :: a = 1
-+        integer :: i
-+        if (iiabs(-9_1).ne.9) stop 1
-+        if (iabs(-9_1).ne.9) stop 2
-+        if (iabs(-9_2).ne.9) stop 3
-+        if (jiabs(-9_1).ne.9) stop 4
-+        if (jiabs(-9_2).ne.9) stop 5
-+        if (iishft(1_1, 2).ne.4) stop 6
-+        if (jishft(1_1, 2).ne.4) stop 7
-+        if (jishft(1_2, 2).ne.4) stop 8
-+        if (kishft(1_1, 2).ne.4) stop 9
-+        if (kishft(1_2, 2).ne.4) stop 10
-+        if (kishft(1_4, 2).ne.4) stop 11
-+        if (imod(17_1, 3).ne.2) stop 12
-+        if (jmod(17_1, 3).ne.2) stop 13
-+        if (jmod(17_2, 3).ne.2) stop 14
-+        if (kmod(17_1, 3).ne.2) stop 15
-+        if (kmod(17_2, 3).ne.2) stop 16
-+        if (kmod(17_4, 3).ne.2) stop 17
-+        if (inot(5_1).ne.-6) stop 18
-+        if (jnot(5_1).ne.-6) stop 19
-+        if (jnot(5_2).ne.-6) stop 20
-+        if (knot(5_1).ne.-6) stop 21
-+        if (knot(5_2).ne.-6) stop 22
-+        if (knot(5_4).ne.-6) stop 23
-+        if (isign(-77_1, 1).ne.77) stop 24
-+        if (isign(-77_1, -1).ne.-77) stop 25
-+        if (isign(-77_2, 1).ne.77) stop 26
-+        if (isign(-77_2, -1).ne.-77) stop 27
-+      end program
-diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
-new file mode 100644
-index 00000000000..7b1697ca665
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
-@@ -0,0 +1,40 @@
-+!{ dg-do run }
-+!{ dg-options "-fdec-intrinsic-ints -fdec-promotion" }
-+!
-+! integer types of a smaller kind than expected should be
-+! accepted by type specific intrinsic functions
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program test_small_type_promtion
-+        implicit none
-+        integer(1) :: a = 1
-+        integer :: i
-+        if (iiabs(-9_1).ne.9) stop 1
-+        if (iabs(-9_1).ne.9) stop 2
-+        if (iabs(-9_2).ne.9) stop 3
-+        if (jiabs(-9_1).ne.9) stop 4
-+        if (jiabs(-9_2).ne.9) stop 5
-+        if (iishft(1_1, 2).ne.4) stop 6
-+        if (jishft(1_1, 2).ne.4) stop 7
-+        if (jishft(1_2, 2).ne.4) stop 8
-+        if (kishft(1_1, 2).ne.4) stop 9
-+        if (kishft(1_2, 2).ne.4) stop 10
-+        if (kishft(1_4, 2).ne.4) stop 11
-+        if (imod(17_1, 3).ne.2) stop 12
-+        if (jmod(17_1, 3).ne.2) stop 13
-+        if (jmod(17_2, 3).ne.2) stop 14
-+        if (kmod(17_1, 3).ne.2) stop 15
-+        if (kmod(17_2, 3).ne.2) stop 16
-+        if (kmod(17_4, 3).ne.2) stop 17
-+        if (inot(5_1).ne.-6) stop 18
-+        if (jnot(5_1).ne.-6) stop 19
-+        if (jnot(5_2).ne.-6) stop 20
-+        if (knot(5_1).ne.-6) stop 21
-+        if (knot(5_2).ne.-6) stop 22
-+        if (knot(5_4).ne.-6) stop 23
-+        if (isign(-77_1, 1).ne.77) stop 24
-+        if (isign(-77_1, -1).ne.-77) stop 25
-+        if (isign(-77_2, 1).ne.77) stop 26
-+        if (isign(-77_2, -1).ne.-77) stop 27
-+      end program
-diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
-new file mode 100644
-index 00000000000..db8dff6c55d
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
-@@ -0,0 +1,39 @@
-+!{ dg-do compile }
-+!{ dg-options "-fdec -fno-dec-promotion" }
-+!
-+! integer types of a smaller kind than expected should be
-+! accepted by type specific intrinsic functions
-+!
-+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+      program test_small_type_promtion
-+        integer(1) :: a = 1
-+        integer :: i
-+        if (iiabs(-9_1).ne.9) stop 1
-+        if (iabs(-9_1).ne.9) stop 2 ! { dg-error "type mismatch in argument" }
-+        if (iabs(-9_2).ne.9) stop 3 ! { dg-error "type mismatch in argument" }
-+        if (jiabs(-9_1).ne.9) stop 4
-+        if (jiabs(-9_2).ne.9) stop 5
-+        if (iishft(1_1, 2).ne.4) stop 6
-+        if (jishft(1_1, 2).ne.4) stop 7
-+        if (jishft(1_2, 2).ne.4) stop 8
-+        if (kishft(1_1, 2).ne.4) stop 9
-+        if (kishft(1_2, 2).ne.4) stop 10
-+        if (kishft(1_4, 2).ne.4) stop 11
-+        if (imod(17_1, 3).ne.2) stop 12
-+        if (jmod(17_1, 3).ne.2) stop 13
-+        if (jmod(17_2, 3).ne.2) stop 14
-+        if (kmod(17_1, 3).ne.2) stop 15
-+        if (kmod(17_2, 3).ne.2) stop 16
-+        if (kmod(17_4, 3).ne.2) stop 17
-+        if (inot(5_1).ne.-6) stop 18
-+        if (jnot(5_1).ne.-6) stop 19
-+        if (jnot(5_2).ne.-6) stop 20
-+        if (knot(5_1).ne.-6) stop 21
-+        if (knot(5_2).ne.-6) stop 22
-+        if (knot(5_4).ne.-6) stop 23
-+        if (isign(-77_1, 1).ne.77) stop 24 ! { dg-error "type mismatch in argument" }
-+        if (isign(-77_1, -1).ne.-77) stop 25 ! { dg-error "type mismatch in argument" }
-+        if (isign(-77_2, 1).ne.77) stop 26 ! { dg-error "type mismatch in argument" }
-+        if (isign(-77_2, -1).ne.-77) stop 27 ! { dg-error "type mismatch in argument" }
-+      end program
--- 
-2.27.0
-

diff --git a/gcc11-fortran-fdec-sequence.patch b/gcc11-fortran-fdec-sequence.patch
deleted file mode 100644
index 7b9ce71..0000000
--- a/gcc11-fortran-fdec-sequence.patch
+++ /dev/null
@@ -1,262 +0,0 @@
-From bb76446db10c21860a4e19569ce3e350d8a2b59f Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 15:00:44 +0000
-Subject: [PATCH 09/10] Add the SEQUENCE attribute by default if it's not
- present.
-
-Use -fdec-sequence to enable this feature. Also enabled by -fdec.
----
- gcc/fortran/lang.opt                          |  4 ++
- gcc/fortran/options.c                         |  1 +
- gcc/fortran/resolve.c                         | 13 ++++-
- ...dd_SEQUENCE_to_COMMON_block_by_default_1.f | 57 +++++++++++++++++++
- ...dd_SEQUENCE_to_COMMON_block_by_default_2.f | 57 +++++++++++++++++++
- ...dd_SEQUENCE_to_COMMON_block_by_default_3.f | 57 +++++++++++++++++++
- 6 files changed, 186 insertions(+), 3 deletions(-)
- create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 4ca2f93f2df..019c798cf09 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -509,6 +509,10 @@ fdec-promotion
- Fortran Var(flag_dec_promotion)
- Add support for type promotion in intrinsic arguments.
- 
-+fdec-sequence
-+Fortran Var(flag_dec_sequence)
-+Add the SEQUENCE attribute by default if it's not present.
-+
- fdec-structure
- Fortran Var(flag_dec_structure)
- Enable support for DEC STRUCTURE/RECORD.
-diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
-index 15079c7e95a..050f56fdc25 100644
---- a/gcc/fortran/options.c
-+++ b/gcc/fortran/options.c
-@@ -83,6 +83,7 @@ set_dec_flags (int value)
-   SET_BITFLAG (flag_dec_override_kind, value, value);
-   SET_BITFLAG (flag_dec_non_logical_if, value, value);
-   SET_BITFLAG (flag_dec_promotion, value, value);
-+  SET_BITFLAG (flag_dec_sequence, value, value);
- }
- 
- /* Finalize DEC flags.  */
-diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
-index 07dd039f3bf..fe7d0cc5944 100644
---- a/gcc/fortran/resolve.c
-+++ b/gcc/fortran/resolve.c
-@@ -978,9 +978,16 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common)
- 
-       if (!(csym->ts.u.derived->attr.sequence
- 	    || csym->ts.u.derived->attr.is_bind_c))
--	gfc_error_now ("Derived type variable %qs in COMMON at %L "
--		       "has neither the SEQUENCE nor the BIND(C) "
--		       "attribute", csym->name, &csym->declared_at);
-+	{
-+	  if (flag_dec_sequence)
-+	    /* Assume sequence. */
-+	    csym->ts.u.derived->attr.sequence = 1;
-+	  else
-+	    gfc_error_now ("Derived type variable '%s' in COMMON at %L "
-+			   "has neither the SEQUENCE nor the BIND(C) "
-+			   "attribute", csym->name, &csym->declared_at);
-+	}
-+
-       if (csym->ts.u.derived->attr.alloc_comp)
- 	gfc_error_now ("Derived type variable %qs in COMMON at %L "
- 		       "has an ultimate component that is "
-diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
-new file mode 100644
-index 00000000000..fe7b39625eb
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
-@@ -0,0 +1,57 @@
-+! { dg-do run }
-+! { dg-options "-fdec" }
-+!
-+! Test add default SEQUENCE attribute derived types appearing in
-+! COMMON blocks and EQUIVALENCE statements.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        MODULE SEQ
-+          TYPE STRUCT1
-+            INTEGER*4     ID
-+            INTEGER*4     TYPE
-+            INTEGER*8     DEFVAL
-+            CHARACTER*(4) NAME
-+            LOGICAL*1     NIL
-+          END TYPE STRUCT1
-+        END MODULE
-+
-+        SUBROUTINE A
-+          USE SEQ
-+          TYPE (STRUCT1) S
-+          COMMON /BLOCK1/ S
-+          IF (S%ID.NE.5) STOP 1
-+          IF (S%TYPE.NE.1000) STOP 2
-+          IF (S%DEFVAL.NE.-99) STOP 3
-+          IF (S%NAME.NE."JANE") STOP 4
-+          IF (S%NIL.NEQV..FALSE.) STOP 5
-+        END SUBROUTINE
-+
-+        PROGRAM sequence_att_common
-+          USE SEQ
-+          IMPLICIT NONE
-+          TYPE (STRUCT1) S1
-+          TYPE (STRUCT1) S2
-+          TYPE (STRUCT1) S3
-+
-+          EQUIVALENCE (S1,S2)
-+          COMMON /BLOCK1/ S3
-+
-+          S1%ID = 5
-+          S1%TYPE = 1000
-+          S1%DEFVAL = -99
-+          S1%NAME = "JANE"
-+          S1%NIL = .FALSE.
-+
-+          IF (S2%ID.NE.5) STOP 1
-+          IF (S2%TYPE.NE.1000) STOP 2
-+          IF (S2%DEFVAL.NE.-99) STOP 3
-+          IF (S2%NAME.NE."JANE") STOP 4
-+          IF (S2%NIL.NEQV..FALSE.) STOP 5
-+
-+          S3 = S1
-+
-+          CALL A
-+          
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
-new file mode 100644
-index 00000000000..83512f0f3a2
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
-@@ -0,0 +1,57 @@
-+! { dg-do run }
-+! { dg-options "-fdec-sequence" }
-+!
-+! Test add default SEQUENCE attribute derived types appearing in
-+! COMMON blocks and EQUIVALENCE statements.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        MODULE SEQ
-+          TYPE STRUCT1
-+            INTEGER*4     ID
-+            INTEGER*4     TYPE
-+            INTEGER*8     DEFVAL
-+            CHARACTER*(4) NAME
-+            LOGICAL*1     NIL
-+          END TYPE STRUCT1
-+        END MODULE
-+
-+        SUBROUTINE A
-+          USE SEQ
-+          TYPE (STRUCT1) S
-+          COMMON /BLOCK1/ S
-+          IF (S%ID.NE.5) STOP 1
-+          IF (S%TYPE.NE.1000) STOP 2
-+          IF (S%DEFVAL.NE.-99) STOP 3
-+          IF (S%NAME.NE."JANE") STOP 4
-+          IF (S%NIL.NEQV..FALSE.) STOP 5
-+        END SUBROUTINE
-+
-+        PROGRAM sequence_att_common
-+          USE SEQ
-+          IMPLICIT NONE
-+          TYPE (STRUCT1) S1
-+          TYPE (STRUCT1) S2
-+          TYPE (STRUCT1) S3
-+
-+          EQUIVALENCE (S1,S2)
-+          COMMON /BLOCK1/ S3
-+
-+          S1%ID = 5
-+          S1%TYPE = 1000
-+          S1%DEFVAL = -99
-+          S1%NAME = "JANE"
-+          S1%NIL = .FALSE.
-+
-+          IF (S2%ID.NE.5) STOP 1
-+          IF (S2%TYPE.NE.1000) STOP 2
-+          IF (S2%DEFVAL.NE.-99) STOP 3
-+          IF (S2%NAME.NE."JANE") STOP 4
-+          IF (S2%NIL.NEQV..FALSE.) STOP 5
-+
-+          S3 = S1
-+
-+          CALL A
-+          
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
-new file mode 100644
-index 00000000000..26cd59f9090
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
-@@ -0,0 +1,57 @@
-+! { dg-do compile }
-+! { dg-options "-fdec -fno-dec-sequence" }
-+!
-+! Test add default SEQUENCE attribute derived types appearing in
-+! COMMON blocks and EQUIVALENCE statements.
-+!
-+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+        MODULE SEQ
-+          TYPE STRUCT1
-+            INTEGER*4     ID
-+            INTEGER*4     TYPE
-+            INTEGER*8     DEFVAL
-+            CHARACTER*(4) NAME
-+            LOGICAL*1     NIL
-+          END TYPE STRUCT1
-+        END MODULE
-+
-+        SUBROUTINE A
-+          USE SEQ
-+          TYPE (STRUCT1) S ! { dg-error "Derived type variable" }
-+          COMMON /BLOCK1/ S
-+          IF (S%ID.NE.5) STOP 1
-+          IF (S%TYPE.NE.1000) STOP 2
-+          IF (S%DEFVAL.NE.-99) STOP 3
-+          IF (S%NAME.NE."JANE") STOP 4
-+          IF (S%NIL.NEQV..FALSE.) STOP 5
-+        END SUBROUTINE
-+
-+        PROGRAM sequence_att_common
-+          USE SEQ
-+          IMPLICIT NONE
-+          TYPE (STRUCT1) S1
-+          TYPE (STRUCT1) S2
-+          TYPE (STRUCT1) S3 ! { dg-error "Derived type variable" }
-+
-+          EQUIVALENCE (S1,S2) ! { dg-error "Derived type variable" }
-+          COMMON /BLOCK1/ S3
-+
-+          S1%ID = 5
-+          S1%TYPE = 1000
-+          S1%DEFVAL = -99
-+          S1%NAME = "JANE"
-+          S1%NIL = .FALSE.
-+
-+          IF (S2%ID.NE.5) STOP 1
-+          IF (S2%TYPE.NE.1000) STOP 2
-+          IF (S2%DEFVAL.NE.-99) STOP 3
-+          IF (S2%NAME.NE."JANE") STOP 4
-+          IF (S2%NIL.NEQV..FALSE.) STOP 5
-+
-+          S3 = S1
-+
-+          CALL A
-+          
-+        END
--- 
-2.27.0
-

diff --git a/gcc11-fortran-flogical-as-integer.patch b/gcc11-fortran-flogical-as-integer.patch
deleted file mode 100644
index 41cbf60..0000000
--- a/gcc11-fortran-flogical-as-integer.patch
+++ /dev/null
@@ -1,305 +0,0 @@
-From 9b45f3063dfd2b893e7963a4828c1b0afecdc68a Mon Sep 17 00:00:00 2001
-From: Mark Eggleston <markeggleston@gcc.gnu.org>
-Date: Fri, 22 Jan 2021 12:41:46 +0000
-Subject: [PATCH 02/10] Convert LOGICAL to INTEGER for arithmetic ops, and vice
- versa
-
-We allow converting LOGICAL types to INTEGER when doing arithmetic
-operations, and converting INTEGER types to LOGICAL for use in
-boolean operations.
-
-This feature is enabled with the -flogical-as-integer flag.
-
-Note: using this feature will disable bitwise logical operations enabled by
--fdec.
----
- gcc/fortran/lang.opt                          |  4 ++
- gcc/fortran/resolve.c                         | 55 ++++++++++++++++++-
- .../logical_to_integer_and_vice_versa_1.f     | 31 +++++++++++
- .../logical_to_integer_and_vice_versa_2.f     | 31 +++++++++++
- .../logical_to_integer_and_vice_versa_3.f     | 33 +++++++++++
- .../logical_to_integer_and_vice_versa_4.f     | 33 +++++++++++
- 6 files changed, 186 insertions(+), 1 deletion(-)
- create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
- create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
- create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
- create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
-
-diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
-index 52bd522051e..c4da248f07c 100644
---- a/gcc/fortran/lang.opt
-+++ b/gcc/fortran/lang.opt
-@@ -497,6 +497,10 @@ fdec-static
- Fortran Var(flag_dec_static)
- Enable DEC-style STATIC and AUTOMATIC attributes.
- 
-+flogical-as-integer
-+Fortran Var(flag_logical_as_integer)
-+Convert from integer to logical or logical to integer for arithmetic operations.
-+
- fdefault-double-8
- Fortran Var(flag_default_double)
- Set the default double precision kind to an 8 byte wide type.
-diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
-index c075d0fa0c4..4b90cb59902 100644
---- a/gcc/fortran/resolve.c
-+++ b/gcc/fortran/resolve.c
-@@ -3915,7 +3915,6 @@ lookup_uop_fuzzy (const char *op, gfc_symtree *uop)
-   return gfc_closest_fuzzy_match (op, candidates);
- }
- 
--
- /* Callback finding an impure function as an operand to an .and. or
-    .or.  expression.  Remember the last function warned about to
-    avoid double warnings when recursing.  */
-@@ -3975,6 +3974,22 @@ convert_hollerith_to_character (gfc_expr *e)
-     }
- }
- 
-+/* If E is a logical, convert it to an integer and issue a warning
-+   for the conversion.  */
-+
-+static void
-+convert_integer_to_logical (gfc_expr *e)
-+{
-+  if (e->ts.type == BT_INTEGER)
-+    {
-+      /* Convert to LOGICAL */
-+      gfc_typespec t;
-+      t.type = BT_LOGICAL;
-+      t.kind = 1;
-+      gfc_convert_type_warn (e, &t, 2, 1);
-+    }
-+}
-+
- /* Convert to numeric and issue a warning for the conversion.  */
- 
- static void
-@@ -3987,6 +4002,22 @@ convert_to_numeric (gfc_expr *a, gfc_expr *b)
-   gfc_convert_type_warn (a, &t, 2, 1);
- }
- 
-+/* If E is a logical, convert it to an integer and issue a warning
-+   for the conversion.  */
-+
-+static void
-+convert_logical_to_integer (gfc_expr *e)
-+{
-+  if (e->ts.type == BT_LOGICAL)
-+    {
-+      /* Convert to INTEGER */
-+      gfc_typespec t;
-+      t.type = BT_INTEGER;
-+      t.kind = 1;
-+      gfc_convert_type_warn (e, &t, 2, 1);
-+    }
-+}
-+
- /* Resolve an operator expression node.  This can involve replacing the
-    operation with a user defined function call.  */
- 
-@@ -4072,6 +4103,12 @@ resolve_operator (gfc_expr *e)
-     case INTRINSIC_TIMES:
-     case INTRINSIC_DIVIDE:
-     case INTRINSIC_POWER:
-+      if (flag_logical_as_integer)
-+	{
-+	  convert_logical_to_integer (op1);
-+	  convert_logical_to_integer (op2);
-+	}
-+
-       if (gfc_numeric_ts (&op1->ts) && gfc_numeric_ts (&op2->ts))
- 	{
- 	  gfc_type_convert_binary (e, 1);
-@@ -4108,6 +4145,13 @@ resolve_operator (gfc_expr *e)
-     case INTRINSIC_OR:
-     case INTRINSIC_EQV:
-     case INTRINSIC_NEQV:
-+
-+      if (flag_logical_as_integer)
-+	{
-+	  convert_integer_to_logical (op1);
-+	  convert_integer_to_logical (op2);
-+	}
-+
-       if (op1->ts.type == BT_LOGICAL && op2->ts.type == BT_LOGICAL)
- 	{
- 	  e->ts.type = BT_LOGICAL;
-@@ -4158,6 +4202,9 @@ resolve_operator (gfc_expr *e)
- 	  goto simplify_op;
- 	}
- 
-+      if (flag_logical_as_integer)
-+	convert_integer_to_logical (op1);
-+
-       if (op1->ts.type == BT_LOGICAL)
- 	{
- 	  e->ts.type = BT_LOGICAL;
-@@ -4198,6 +4245,12 @@ resolve_operator (gfc_expr *e)
- 	  convert_hollerith_to_character (op2);
- 	}
- 
-+      if (flag_logical_as_integer)
-+	{
-+	  convert_logical_to_integer (op1);
-+	  convert_logical_to_integer (op2);
-+	}
-+
-       if (op1->ts.type == BT_CHARACTER && op2->ts.type == BT_CHARACTER
- 	  && op1->ts.kind == op2->ts.kind)
- 	{
-diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
-new file mode 100644
-index 00000000000..938a91d9e9a
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
-@@ -0,0 +1,31 @@
-+! { dg-do run }
-+! { dg-options "-std=legacy -flogical-as-integer" }
-+!
-+! Test conversion between logical and integer for logical operators
-+!
-+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
-+! Modified for -flogical-as-integer by Mark Eggleston
-+! <mark.eggleston@codethink.com>
-+!
-+        PROGRAM logical_integer_conversion
-+          LOGICAL lpos /.true./
-+          INTEGER ineg/0/
-+          INTEGER ires
-+          LOGICAL lres
-+
-+          ! Test Logicals converted to Integers
-+          if ((lpos.AND.ineg).EQ.1) STOP 3
-+          if ((ineg.AND.lpos).NE.0) STOP 4
-+          ires = (.true..AND.0)
-+          if (ires.NE.0) STOP 5
-+          ires = (1.AND..false.)
-+          if (ires.EQ.1) STOP 6
-+
-+          ! Test Integers converted to Logicals
-+          if (lpos.EQ.ineg) STOP 7
-+          if (ineg.EQ.lpos) STOP 8
-+          lres = (.true..EQ.0)
-+          if (lres) STOP 9
-+          lres = (1.EQ..false.)
-+          if (lres) STOP 10
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
-new file mode 100644
-index 00000000000..9f146202ba5
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
-@@ -0,0 +1,31 @@
-+! { dg-do compile }
-+! { dg-options "-std=legacy -flogical-as-integer -fno-logical-as-integer" }
-+!
-+! Based on logical_to_integer_and_vice_versa_1.f but with option disabled
-+! to test for error messages.
-+!
-+! Test case contributed by by Mark Eggleston <mark.eggleston@codethink.com>
-+!
-+!
-+        PROGRAM logical_integer_conversion
-+          LOGICAL lpos /.true./
-+          INTEGER ineg/0/
-+          INTEGER ires
-+          LOGICAL lres
-+
-+          ! Test Logicals converted to Integers
-+          if ((lpos.AND.ineg).EQ.1) STOP 3 ! { dg-error "Operands of logical operator" }
-+          if ((ineg.AND.lpos).NE.0) STOP 4 ! { dg-error "Operands of logical operator" }
-+          ires = (.true..AND.0) ! { dg-error "Operands of logical operator" }
-+          if (ires.NE.0) STOP 5
-+          ires = (1.AND..false.) ! { dg-error "Operands of logical operator" }
-+          if (ires.EQ.1) STOP 6
-+
-+          ! Test Integers converted to Logicals
-+          if (lpos.EQ.ineg) STOP 7 ! { dg-error "Operands of comparison operator" }
-+          if (ineg.EQ.lpos) STOP 8 ! { dg-error "Operands of comparison operator" }
-+          lres = (.true..EQ.0) ! { dg-error "Operands of comparison operator" }
-+          if (lres) STOP 9
-+          lres = (1.EQ..false.) ! { dg-error "Operands of comparison operator" }
-+          if (lres) STOP 10
-+        END
-diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
-new file mode 100644
-index 00000000000..446873eb2dc
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
-@@ -0,0 +1,33 @@
-+! { dg-do compile }
-+! { dg-options "-std=legacy -flogical-as-integer" }
-+!
-+! Test conversion between logical and integer for logical operators
-+!
-+        program test
-+          logical f /.false./
-+          logical t /.true./
-+          real x
-+
-+          x = 7.7
-+          x = x + t*3.0
-+          if (abs(x - 10.7).gt.0.00001) stop 1
-+          x = x + .false.*5.0
-+          if (abs(x - 10.7).gt.0.00001) stop 2
-+          x = x - .true.*5.0
-+          if (abs(x - 5.7).gt.0.00001) stop 3
-+          x = x + t
-+          if (abs(x - 6.7).gt.0.00001) stop 4
-+          x = x + f
-+          if (abs(x - 6.7).gt.0.00001) stop 5
-+          x = x - t
-+          if (abs(x - 5.7).gt.0.00001) stop 6
-+          x = x - f
-+          if (abs(x - 5.7).gt.0.00001) stop 7
-+          x = x**.true.
-+          if (abs(x - 5.7).gt.0.00001) stop 8
-+          x = x**.false.
-+          if (abs(x - 1.0).gt.0.00001) stop 9
-+          x = x/t
-+          if (abs(x - 1.0).gt.0.00001) stop 10
-+          if ((x/.false.).le.huge(x)) stop 11
-+        end
-diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
-new file mode 100644
-index 00000000000..4301a4988d8
---- /dev/null
-+++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
-@@ -0,0 +1,33 @@
-+! { dg-do compile }
-+! { dg-options "-std=legacy -flogical-as-integer -fno-logical-as-integer" }
-+!
-+! Test conversion between logical and integer for logical operators
-+!
-+        program test
-+          logical f /.false./
-+          logical t /.true./
-+          real x
-+
-+          x = 7.7
-+          x = x + t*3.0 ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 10.7).gt.0.00001) stop 1
-+          x = x + .false.*5.0 ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 10.7).gt.0.00001) stop 2
-+          x = x - .true.*5.0 ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 5.7).gt.0.00001) stop 3
-+          x = x + t ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 6.7).gt.0.00001) stop 4
-+          x = x + f ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 6.7).gt.0.00001) stop 5
-+          x = x - t ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 5.7).gt.0.00001) stop 6
-+          x = x - f ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 5.7).gt.0.00001) stop 7
-+          x = x**.true. ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 5.7).gt.0.00001) stop 8
-+          x = x**.false. ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 1.0).gt.0.00001) stop 9
-+          x = x/t ! { dg-error "Operands of binary numeric" }
-+          if (abs(x - 1.0).gt.0.00001) stop 10
-+          if ((x/.false.).le.huge(x)) stop 11 ! { dg-error "Operands of binary numeric" }
-+        end
--- 
-2.27.0
-

diff --git a/gcc11-hack.patch b/gcc11-hack.patch
deleted file mode 100644
index 3a5f3f3..0000000
--- a/gcc11-hack.patch
+++ /dev/null
@@ -1,126 +0,0 @@
---- libada/Makefile.in.jj	2019-01-09 13:01:18.015608205 +0100
-+++ libada/Makefile.in	2019-01-11 18:16:23.441726931 +0100
-@@ -71,18 +71,40 @@ version := $(shell @get_gcc_base_ver@ $(
- libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)$(MULTISUBDIR)
- ADA_RTS_DIR=$(GCC_DIR)/ada/rts$(subst /,_,$(MULTISUBDIR))
- 
-+DEFAULTMULTIFLAGS :=
-+ifeq ($(MULTISUBDIR),)
-+targ:=$(subst -, ,$(target))
-+arch:=$(word 1,$(targ))
-+ifeq ($(words $(targ)),2)
-+osys:=$(word 2,$(targ))
-+else
-+osys:=$(word 3,$(targ))
-+endif
-+ifeq ($(strip $(filter-out i%86 x86_64 powerpc% ppc% s390% sparc% linux%, $(arch) $(osys))),)
-+ifeq ($(shell $(CC) $(CFLAGS) -print-multi-os-directory),../lib64)
-+DEFAULTMULTIFLAGS := -m64
-+else
-+ifeq ($(strip $(filter-out s390%, $(arch))),)
-+DEFAULTMULTIFLAGS := -m31
-+else
-+DEFAULTMULTIFLAGS := -m32
-+endif
-+endif
-+endif
-+endif
-+
- # exeext should not be used because it's the *host* exeext.  We're building
- # a *target* library, aren't we?!?  Likewise for CC.  Still, provide bogus
- # definitions just in case something slips through the safety net provided
- # by recursive make invocations in gcc/ada/Makefile.in
- LIBADA_FLAGS_TO_PASS = \
-         "MAKEOVERRIDES=" \
--        "LDFLAGS=$(LDFLAGS)" \
-+        "LDFLAGS=$(LDFLAGS) $(DEFAULTMULTIFLAGS)" \
-         "LN_S=$(LN_S)" \
-         "SHELL=$(SHELL)" \
--        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \
--        "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
--        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \
-+        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
-+        "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
-+        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
-         "PICFLAG_FOR_TARGET=$(PICFLAG)" \
-         "THREAD_KIND=$(THREAD_KIND)" \
-         "TRACE=$(TRACE)" \
-@@ -93,7 +115,7 @@ LIBADA_FLAGS_TO_PASS = \
-         "exeext=.exeext.should.not.be.used " \
- 	'CC=the.host.compiler.should.not.be.needed' \
- 	"GCC_FOR_TARGET=$(CC)" \
--        "CFLAGS=$(CFLAGS)"
-+        "CFLAGS=$(CFLAGS) $(DEFAULTMULTIFLAGS)"
- 
- .PHONY: libada gnatlib gnatlib-shared gnatlib-sjlj gnatlib-zcx osconstool
- 
---- config-ml.in.jj	2019-01-09 12:50:16.646501448 +0100
-+++ config-ml.in	2019-01-11 18:16:23.442726914 +0100
-@@ -511,6 +511,8 @@ multi-do:
- 				ADAFLAGS="$(ADAFLAGS) $${flags}" \
- 				prefix="$(prefix)" \
- 				exec_prefix="$(exec_prefix)" \
-+				mandir="$(mandir)" \
-+				infodir="$(infodir)" \
- 				GOCFLAGS="$(GOCFLAGS) $${flags}" \
- 				GDCFLAGS="$(GDCFLAGS) $${flags}" \
- 				CXXFLAGS="$(CXXFLAGS) $${flags}" \
---- libcpp/macro.c.jj	2019-01-09 13:01:21.420552123 +0100
-+++ libcpp/macro.c	2019-01-11 18:18:17.736876285 +0100
-@@ -3256,8 +3256,6 @@ static cpp_macro *
- create_iso_definition (cpp_reader *pfile)
- {
-   bool following_paste_op = false;
--  const char *paste_op_error_msg =
--    N_("'##' cannot appear at either end of a macro expansion");
-   unsigned int num_extra_tokens = 0;
-   unsigned nparms = 0;
-   cpp_hashnode **params = NULL;
-@@ -3382,7 +3380,9 @@ create_iso_definition (cpp_reader *pfile
- 	     function-like macros, but not at the end.  */
- 	  if (following_paste_op)
- 	    {
--	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
-+	      cpp_error (pfile, CPP_DL_ERROR,
-+			 "'##' cannot appear at either end of a macro "
-+			 "expansion");
- 	      goto out;
- 	    }
- 	  if (!vaopt_tracker.completed ())
-@@ -3397,7 +3397,9 @@ create_iso_definition (cpp_reader *pfile
- 	     function-like macros, but not at the beginning.  */
- 	  if (macro->count == 1)
- 	    {
--	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
-+	      cpp_error (pfile, CPP_DL_ERROR,
-+			 "'##' cannot appear at either end of a macro "
-+			 "expansion");
- 	      goto out;
- 	    }
- 
---- libcpp/expr.c.jj	2019-01-09 13:01:22.415535734 +0100
-+++ libcpp/expr.c	2019-01-11 18:16:23.444726882 +0100
-@@ -803,16 +803,17 @@ cpp_classify_number (cpp_reader *pfile,
-       if ((result & CPP_N_WIDTH) == CPP_N_LARGE
- 	  && CPP_OPTION (pfile, cpp_warn_long_long))
-         {
--          const char *message = CPP_OPTION (pfile, cplusplus) 
--				? N_("use of C++11 long long integer constant")
--		                : N_("use of C99 long long integer constant");
--
- 	  if (CPP_OPTION (pfile, c99))
-             cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location,
--				   0, message);
-+				   0, CPP_OPTION (pfile, cplusplus)
-+				      ? N_("use of C++11 long long integer constant")
-+				      : N_("use of C99 long long integer constant"));
-           else
-             cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG,
--				      virtual_location, 0, message);
-+				      virtual_location, 0,
-+				      CPP_OPTION (pfile, cplusplus)
-+				      ? N_("use of C++11 long long integer constant")
-+				      : N_("use of C99 long long integer constant"));
-         }
- 
-       if ((result & CPP_N_SIZE_T) == CPP_N_SIZE_T

diff --git a/gcc11-isl-dl.patch b/gcc11-isl-dl.patch
deleted file mode 100644
index b3982f9..0000000
--- a/gcc11-isl-dl.patch
+++ /dev/null
@@ -1,716 +0,0 @@
---- gcc/Makefile.in.jj	2015-06-06 10:00:25.000000000 +0200
-+++ gcc/Makefile.in	2015-11-04 14:56:02.643536437 +0100
-@@ -1063,7 +1063,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
- # and the system's installed libraries.
- LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
- 	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
--BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
-+BACKENDLIBS = $(if $(ISLLIBS),-ldl) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
- 	$(ZLIB) $(ZSTD_LIB)
- # Any system libraries needed just for GNAT.
- SYSLIBS = @GNAT_LIBEXC@
-@@ -2302,6 +2302,15 @@ $(out_object_file): $(out_file)
- $(common_out_object_file): $(common_out_file)
- 	$(COMPILE) $<
- 	$(POSTCOMPILE)
-+
-+graphite%.o : \
-+  ALL_CFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CFLAGS))
-+graphite.o : \
-+  ALL_CFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CFLAGS))
-+graphite%.o : \
-+  ALL_CXXFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CXXFLAGS))
-+graphite.o : \
-+  ALL_CXXFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CXXFLAGS))
- #\f
- # Generate header and source files from the machine description,
- # and compile them.
---- gcc/graphite.h.jj	2016-01-27 12:44:06.000000000 +0100
-+++ gcc/graphite.h	2016-01-27 13:26:38.309876856 +0100
-@@ -24,6 +24,591 @@ along with GCC; see the file COPYING3.
- 
- #include "sese.h"
- 
-+#include <isl/version.h>
-+#include <dlfcn.h>
-+
-+#define DYNSYMS \
-+  DYNSYM (isl_aff_add_coefficient_si); \
-+  DYNSYM (isl_aff_free); \
-+  DYNSYM (isl_aff_get_space); \
-+  DYNSYM (isl_aff_set_coefficient_si); \
-+  DYNSYM (isl_aff_set_constant_si); \
-+  DYNSYM (isl_aff_zero_on_domain); \
-+  DYNSYM (isl_band_free); \
-+  DYNSYM (isl_band_get_children); \
-+  DYNSYM (isl_band_get_partial_schedule); \
-+  DYNSYM (isl_band_has_children); \
-+  DYNSYM (isl_band_list_free); \
-+  DYNSYM (isl_band_list_get_band); \
-+  DYNSYM (isl_band_list_get_ctx); \
-+  DYNSYM (isl_band_list_n_band); \
-+  DYNSYM (isl_band_n_member); \
-+  DYNSYM (isl_basic_map_add_constraint); \
-+  DYNSYM (isl_basic_map_project_out); \
-+  DYNSYM (isl_basic_map_universe); \
-+  DYNSYM (isl_constraint_set_coefficient_si); \
-+  DYNSYM (isl_constraint_set_constant_si); \
-+  DYNSYM (isl_ctx_alloc); \
-+  DYNSYM (isl_ctx_free); \
-+  DYNSYM (isl_equality_alloc); \
-+  DYNSYM (isl_id_alloc); \
-+  DYNSYM (isl_id_copy); \
-+  DYNSYM (isl_id_free); \
-+  DYNSYM (isl_inequality_alloc); \
-+  DYNSYM (isl_local_space_copy); \
-+  DYNSYM (isl_local_space_free); \
-+  DYNSYM (isl_local_space_from_space); \
-+  DYNSYM (isl_local_space_range); \
-+  DYNSYM (isl_map_add_constraint); \
-+  DYNSYM (isl_map_add_dims); \
-+  DYNSYM (isl_map_align_params); \
-+  DYNSYM (isl_map_apply_range); \
-+  DYNSYM (isl_map_copy); \
-+  DYNSYM (isl_map_dim); \
-+  DYNSYM (isl_map_dump); \
-+  DYNSYM (isl_map_equate); \
-+  DYNSYM (isl_map_fix_si); \
-+  DYNSYM (isl_map_flat_product); \
-+  DYNSYM (isl_map_flat_range_product); \
-+  DYNSYM (isl_map_free); \
-+  DYNSYM (isl_map_from_basic_map); \
-+  DYNSYM (isl_map_from_pw_aff); \
-+  DYNSYM (isl_map_from_union_map); \
-+  DYNSYM (isl_map_get_ctx); \
-+  DYNSYM (isl_map_get_space); \
-+  DYNSYM (isl_map_get_tuple_id); \
-+  DYNSYM (isl_map_insert_dims); \
-+  DYNSYM (isl_map_intersect); \
-+  DYNSYM (isl_map_intersect_domain); \
-+  DYNSYM (isl_map_intersect_range); \
-+  DYNSYM (isl_map_is_empty); \
-+  DYNSYM (isl_map_lex_ge); \
-+  DYNSYM (isl_map_lex_le); \
-+  DYNSYM (isl_map_n_out); \
-+  DYNSYM (isl_map_range); \
-+  DYNSYM (isl_map_set_tuple_id); \
-+  DYNSYM (isl_map_universe); \
-+  DYNSYM (isl_options_set_on_error); \
-+  DYNSYM (isl_options_set_schedule_serialize_sccs); \
-+  DYNSYM (isl_printer_set_yaml_style); \
-+  DYNSYM (isl_options_set_schedule_max_constant_term); \
-+  DYNSYM (isl_options_set_schedule_maximize_band_depth); \
-+  DYNSYM (isl_printer_free); \
-+  DYNSYM (isl_printer_print_aff); \
-+  DYNSYM (isl_printer_print_constraint); \
-+  DYNSYM (isl_printer_print_map); \
-+  DYNSYM (isl_printer_print_set); \
-+  DYNSYM (isl_printer_to_file); \
-+  DYNSYM (isl_pw_aff_add); \
-+  DYNSYM (isl_pw_aff_alloc); \
-+  DYNSYM (isl_pw_aff_copy); \
-+  DYNSYM (isl_pw_aff_eq_set); \
-+  DYNSYM (isl_pw_aff_free); \
-+  DYNSYM (isl_pw_aff_from_aff); \
-+  DYNSYM (isl_pw_aff_ge_set); \
-+  DYNSYM (isl_pw_aff_gt_set); \
-+  DYNSYM (isl_pw_aff_is_cst); \
-+  DYNSYM (isl_pw_aff_le_set); \
-+  DYNSYM (isl_pw_aff_lt_set); \
-+  DYNSYM (isl_pw_aff_mul); \
-+  DYNSYM (isl_pw_aff_ne_set); \
-+  DYNSYM (isl_pw_aff_nonneg_set); \
-+  DYNSYM (isl_pw_aff_set_tuple_id); \
-+  DYNSYM (isl_pw_aff_sub); \
-+  DYNSYM (isl_pw_aff_zero_set); \
-+  DYNSYM (isl_schedule_free); \
-+  DYNSYM (isl_schedule_get_band_forest); \
-+  DYNSYM (isl_set_add_constraint); \
-+  DYNSYM (isl_set_add_dims); \
-+  DYNSYM (isl_set_apply); \
-+  DYNSYM (isl_set_coalesce); \
-+  DYNSYM (isl_set_copy); \
-+  DYNSYM (isl_set_dim); \
-+  DYNSYM (isl_set_fix_si); \
-+  DYNSYM (isl_set_free); \
-+  DYNSYM (isl_set_get_space); \
-+  DYNSYM (isl_set_get_tuple_id); \
-+  DYNSYM (isl_set_intersect); \
-+  DYNSYM (isl_set_is_empty); \
-+  DYNSYM (isl_set_n_dim); \
-+  DYNSYM (isl_set_nat_universe); \
-+  DYNSYM (isl_set_project_out); \
-+  DYNSYM (isl_set_set_tuple_id); \
-+  DYNSYM (isl_set_universe); \
-+  DYNSYM (isl_space_add_dims); \
-+  DYNSYM (isl_space_alloc); \
-+  DYNSYM (isl_space_copy); \
-+  DYNSYM (isl_space_dim); \
-+  DYNSYM (isl_space_domain); \
-+  DYNSYM (isl_space_find_dim_by_id); \
-+  DYNSYM (isl_space_free); \
-+  DYNSYM (isl_space_from_domain); \
-+  DYNSYM (isl_space_get_tuple_id); \
-+  DYNSYM (isl_space_params_alloc); \
-+  DYNSYM (isl_space_range); \
-+  DYNSYM (isl_space_set_alloc); \
-+  DYNSYM (isl_space_set_dim_id); \
-+  DYNSYM (isl_space_set_tuple_id); \
-+  DYNSYM (isl_union_map_add_map); \
-+  DYNSYM (isl_union_map_align_params); \
-+  DYNSYM (isl_union_map_apply_domain); \
-+  DYNSYM (isl_union_map_apply_range); \
-+  DYNSYM (isl_union_map_compute_flow); \
-+  DYNSYM (isl_union_map_copy); \
-+  DYNSYM (isl_union_map_empty); \
-+  DYNSYM (isl_union_map_flat_range_product); \
-+  DYNSYM (isl_union_map_foreach_map); \
-+  DYNSYM (isl_union_map_free); \
-+  DYNSYM (isl_union_map_from_map); \
-+  DYNSYM (isl_union_map_get_ctx); \
-+  DYNSYM (isl_union_map_get_space); \
-+  DYNSYM (isl_union_map_gist_domain); \
-+  DYNSYM (isl_union_map_gist_range); \
-+  DYNSYM (isl_union_map_intersect_domain); \
-+  DYNSYM (isl_union_map_is_empty); \
-+  DYNSYM (isl_union_map_subtract); \
-+  DYNSYM (isl_union_map_union); \
-+  DYNSYM (isl_union_set_add_set); \
-+  DYNSYM (isl_union_set_compute_schedule); \
-+  DYNSYM (isl_union_set_copy); \
-+  DYNSYM (isl_union_set_empty); \
-+  DYNSYM (isl_union_set_from_set); \
-+  DYNSYM (isl_aff_add_constant_val); \
-+  DYNSYM (isl_aff_get_coefficient_val); \
-+  DYNSYM (isl_aff_get_ctx); \
-+  DYNSYM (isl_aff_mod_val); \
-+  DYNSYM (isl_ast_build_ast_from_schedule); \
-+  DYNSYM (isl_ast_build_free); \
-+  DYNSYM (isl_ast_build_from_context); \
-+  DYNSYM (isl_ast_build_get_ctx); \
-+  DYNSYM (isl_ast_build_get_schedule); \
-+  DYNSYM (isl_ast_build_get_schedule_space); \
-+  DYNSYM (isl_ast_build_set_before_each_for); \
-+  DYNSYM (isl_ast_build_set_options); \
-+  DYNSYM (isl_ast_expr_free); \
-+  DYNSYM (isl_ast_expr_from_val); \
-+  DYNSYM (isl_ast_expr_get_ctx); \
-+  DYNSYM (isl_ast_expr_get_id); \
-+  DYNSYM (isl_ast_expr_get_op_arg); \
-+  DYNSYM (isl_ast_expr_get_op_n_arg); \
-+  DYNSYM (isl_ast_expr_get_op_type); \
-+  DYNSYM (isl_ast_expr_get_type); \
-+  DYNSYM (isl_ast_expr_get_val); \
-+  DYNSYM (isl_ast_expr_sub); \
-+  DYNSYM (isl_ast_node_block_get_children); \
-+  DYNSYM (isl_ast_node_for_get_body); \
-+  DYNSYM (isl_ast_node_for_get_cond); \
-+  DYNSYM (isl_ast_node_for_get_inc); \
-+  DYNSYM (isl_ast_node_for_get_init); \
-+  DYNSYM (isl_ast_node_for_get_iterator); \
-+  DYNSYM (isl_ast_node_free); \
-+  DYNSYM (isl_ast_node_get_annotation); \
-+  DYNSYM (isl_ast_node_get_type); \
-+  DYNSYM (isl_ast_node_if_get_cond); \
-+  DYNSYM (isl_ast_node_if_get_else); \
-+  DYNSYM (isl_ast_node_if_get_then); \
-+  DYNSYM (isl_ast_node_list_free); \
-+  DYNSYM (isl_ast_node_list_get_ast_node); \
-+  DYNSYM (isl_ast_node_list_n_ast_node); \
-+  DYNSYM (isl_ast_node_user_get_expr); \
-+  DYNSYM (isl_constraint_set_coefficient_val); \
-+  DYNSYM (isl_constraint_set_constant_val); \
-+  DYNSYM (isl_id_get_user); \
-+  DYNSYM (isl_local_space_get_ctx); \
-+  DYNSYM (isl_map_fix_val); \
-+  DYNSYM (isl_options_set_ast_build_atomic_upper_bound); \
-+  DYNSYM (isl_printer_print_ast_node); \
-+  DYNSYM (isl_printer_print_str); \
-+  DYNSYM (isl_printer_set_output_format); \
-+  DYNSYM (isl_pw_aff_mod_val); \
-+  DYNSYM (isl_schedule_constraints_compute_schedule); \
-+  DYNSYM (isl_schedule_constraints_on_domain); \
-+  DYNSYM (isl_schedule_constraints_set_coincidence); \
-+  DYNSYM (isl_schedule_constraints_set_proximity); \
-+  DYNSYM (isl_schedule_constraints_set_validity); \
-+  DYNSYM (isl_set_get_dim_id); \
-+  DYNSYM (isl_set_max_val); \
-+  DYNSYM (isl_set_min_val); \
-+  DYNSYM (isl_set_params); \
-+  DYNSYM (isl_space_align_params); \
-+  DYNSYM (isl_space_map_from_domain_and_range); \
-+  DYNSYM (isl_space_set_tuple_name); \
-+  DYNSYM (isl_space_wrap); \
-+  DYNSYM (isl_union_map_from_domain_and_range); \
-+  DYNSYM (isl_union_map_range); \
-+  DYNSYM (isl_union_set_union); \
-+  DYNSYM (isl_union_set_universe); \
-+  DYNSYM (isl_val_2exp); \
-+  DYNSYM (isl_val_add_ui); \
-+  DYNSYM (isl_val_copy); \
-+  DYNSYM (isl_val_free); \
-+  DYNSYM (isl_val_int_from_si); \
-+  DYNSYM (isl_val_int_from_ui); \
-+  DYNSYM (isl_val_mul); \
-+  DYNSYM (isl_val_neg); \
-+  DYNSYM (isl_val_sub); \
-+  DYNSYM (isl_printer_print_union_map); \
-+  DYNSYM (isl_pw_aff_get_ctx); \
-+  DYNSYM (isl_val_is_int); \
-+  DYNSYM (isl_ctx_get_max_operations); \
-+  DYNSYM (isl_ctx_set_max_operations); \
-+  DYNSYM (isl_ctx_last_error); \
-+  DYNSYM (isl_ctx_reset_operations); \
-+  DYNSYM (isl_map_coalesce); \
-+  DYNSYM (isl_printer_print_schedule); \
-+  DYNSYM (isl_set_set_dim_id); \
-+  DYNSYM (isl_union_map_coalesce); \
-+  DYNSYM (isl_multi_val_set_val); \
-+  DYNSYM (isl_multi_val_zero); \
-+  DYNSYM (isl_options_set_schedule_max_coefficient); \
-+  DYNSYM (isl_options_set_tile_scale_tile_loops); \
-+  DYNSYM (isl_schedule_copy); \
-+  DYNSYM (isl_schedule_get_map); \
-+  DYNSYM (isl_schedule_map_schedule_node_bottom_up); \
-+  DYNSYM (isl_schedule_node_band_get_permutable); \
-+  DYNSYM (isl_schedule_node_band_get_space); \
-+  DYNSYM (isl_schedule_node_band_tile); \
-+  DYNSYM (isl_schedule_node_child); \
-+  DYNSYM (isl_schedule_node_free); \
-+  DYNSYM (isl_schedule_node_get_child); \
-+  DYNSYM (isl_schedule_node_get_ctx); \
-+  DYNSYM (isl_schedule_node_get_type); \
-+  DYNSYM (isl_schedule_node_n_children); \
-+  DYNSYM (isl_union_map_is_equal); \
-+  DYNSYM (isl_union_access_info_compute_flow); \
-+  DYNSYM (isl_union_access_info_from_sink); \
-+  DYNSYM (isl_union_access_info_set_may_source); \
-+  DYNSYM (isl_union_access_info_set_must_source); \
-+  DYNSYM (isl_union_access_info_set_schedule); \
-+  DYNSYM (isl_union_flow_free); \
-+  DYNSYM (isl_union_flow_get_may_dependence); \
-+  DYNSYM (isl_union_flow_get_must_dependence); \
-+  DYNSYM (isl_aff_var_on_domain); \
-+  DYNSYM (isl_multi_aff_from_aff); \
-+  DYNSYM (isl_schedule_get_ctx); \
-+  DYNSYM (isl_multi_aff_set_tuple_id); \
-+  DYNSYM (isl_multi_aff_dim); \
-+  DYNSYM (isl_schedule_get_domain); \
-+  DYNSYM (isl_union_set_is_empty); \
-+  DYNSYM (isl_union_set_get_space); \
-+  DYNSYM (isl_union_pw_multi_aff_empty); \
-+  DYNSYM (isl_union_set_foreach_set); \
-+  DYNSYM (isl_union_set_free); \
-+  DYNSYM (isl_multi_union_pw_aff_from_union_pw_multi_aff); \
-+  DYNSYM (isl_multi_union_pw_aff_apply_multi_aff); \
-+  DYNSYM (isl_schedule_insert_partial_schedule); \
-+  DYNSYM (isl_union_pw_multi_aff_free); \
-+  DYNSYM (isl_pw_multi_aff_project_out_map); \
-+  DYNSYM (isl_union_pw_multi_aff_add_pw_multi_aff); \
-+  DYNSYM (isl_schedule_from_domain); \
-+  DYNSYM (isl_schedule_sequence); \
-+  DYNSYM (isl_ast_build_node_from_schedule); \
-+  DYNSYM (isl_ast_node_mark_get_node); \
-+  DYNSYM (isl_schedule_node_band_member_get_ast_loop_type); \
-+  DYNSYM (isl_schedule_node_band_member_set_ast_loop_type); \
-+  DYNSYM (isl_val_n_abs_num_chunks); \
-+  DYNSYM (isl_val_get_abs_num_chunks); \
-+  DYNSYM (isl_val_int_from_chunks); \
-+  DYNSYM (isl_val_is_neg); \
-+  DYNSYM (isl_version); \
-+  DYNSYM (isl_options_get_on_error); \
-+  DYNSYM (isl_ctx_reset_error);
-+
-+extern struct isl_pointers_s__
-+{
-+  bool inited;
-+  void *h;
-+#define DYNSYM(x) __typeof (x) *p_##x
-+  DYNSYMS
-+#undef DYNSYM
-+} isl_pointers__;
-+
-+#define isl_aff_add_coefficient_si (*isl_pointers__.p_isl_aff_add_coefficient_si)
-+#define isl_aff_free (*isl_pointers__.p_isl_aff_free)
-+#define isl_aff_get_space (*isl_pointers__.p_isl_aff_get_space)
-+#define isl_aff_set_coefficient_si (*isl_pointers__.p_isl_aff_set_coefficient_si)
-+#define isl_aff_set_constant_si (*isl_pointers__.p_isl_aff_set_constant_si)
-+#define isl_aff_zero_on_domain (*isl_pointers__.p_isl_aff_zero_on_domain)
-+#define isl_band_free (*isl_pointers__.p_isl_band_free)
-+#define isl_band_get_children (*isl_pointers__.p_isl_band_get_children)
-+#define isl_band_get_partial_schedule (*isl_pointers__.p_isl_band_get_partial_schedule)
-+#define isl_band_has_children (*isl_pointers__.p_isl_band_has_children)
-+#define isl_band_list_free (*isl_pointers__.p_isl_band_list_free)
-+#define isl_band_list_get_band (*isl_pointers__.p_isl_band_list_get_band)
-+#define isl_band_list_get_ctx (*isl_pointers__.p_isl_band_list_get_ctx)
-+#define isl_band_list_n_band (*isl_pointers__.p_isl_band_list_n_band)
-+#define isl_band_n_member (*isl_pointers__.p_isl_band_n_member)
-+#define isl_basic_map_add_constraint (*isl_pointers__.p_isl_basic_map_add_constraint)
-+#define isl_basic_map_project_out (*isl_pointers__.p_isl_basic_map_project_out)
-+#define isl_basic_map_universe (*isl_pointers__.p_isl_basic_map_universe)
-+#define isl_constraint_set_coefficient_si (*isl_pointers__.p_isl_constraint_set_coefficient_si)
-+#define isl_constraint_set_constant_si (*isl_pointers__.p_isl_constraint_set_constant_si)
-+#define isl_ctx_alloc (*isl_pointers__.p_isl_ctx_alloc)
-+#define isl_ctx_free (*isl_pointers__.p_isl_ctx_free)
-+#define isl_equality_alloc (*isl_pointers__.p_isl_equality_alloc)
-+#define isl_id_alloc (*isl_pointers__.p_isl_id_alloc)
-+#define isl_id_copy (*isl_pointers__.p_isl_id_copy)
-+#define isl_id_free (*isl_pointers__.p_isl_id_free)
-+#define isl_inequality_alloc (*isl_pointers__.p_isl_inequality_alloc)
-+#define isl_local_space_copy (*isl_pointers__.p_isl_local_space_copy)
-+#define isl_local_space_free (*isl_pointers__.p_isl_local_space_free)
-+#define isl_local_space_from_space (*isl_pointers__.p_isl_local_space_from_space)
-+#define isl_local_space_range (*isl_pointers__.p_isl_local_space_range)
-+#define isl_map_add_constraint (*isl_pointers__.p_isl_map_add_constraint)
-+#define isl_map_add_dims (*isl_pointers__.p_isl_map_add_dims)
-+#define isl_map_align_params (*isl_pointers__.p_isl_map_align_params)
-+#define isl_map_apply_range (*isl_pointers__.p_isl_map_apply_range)
-+#define isl_map_copy (*isl_pointers__.p_isl_map_copy)
-+#define isl_map_dim (*isl_pointers__.p_isl_map_dim)
-+#define isl_map_dump (*isl_pointers__.p_isl_map_dump)
-+#define isl_map_equate (*isl_pointers__.p_isl_map_equate)
-+#define isl_map_fix_si (*isl_pointers__.p_isl_map_fix_si)
-+#define isl_map_flat_product (*isl_pointers__.p_isl_map_flat_product)
-+#define isl_map_flat_range_product (*isl_pointers__.p_isl_map_flat_range_product)
-+#define isl_map_free (*isl_pointers__.p_isl_map_free)
-+#define isl_map_from_basic_map (*isl_pointers__.p_isl_map_from_basic_map)
-+#define isl_map_from_pw_aff (*isl_pointers__.p_isl_map_from_pw_aff)
-+#define isl_map_from_union_map (*isl_pointers__.p_isl_map_from_union_map)
-+#define isl_map_get_ctx (*isl_pointers__.p_isl_map_get_ctx)
-+#define isl_map_get_space (*isl_pointers__.p_isl_map_get_space)
-+#define isl_map_get_tuple_id (*isl_pointers__.p_isl_map_get_tuple_id)
-+#define isl_map_insert_dims (*isl_pointers__.p_isl_map_insert_dims)
-+#define isl_map_intersect (*isl_pointers__.p_isl_map_intersect)
-+#define isl_map_intersect_domain (*isl_pointers__.p_isl_map_intersect_domain)
-+#define isl_map_intersect_range (*isl_pointers__.p_isl_map_intersect_range)
-+#define isl_map_is_empty (*isl_pointers__.p_isl_map_is_empty)
-+#define isl_map_lex_ge (*isl_pointers__.p_isl_map_lex_ge)
-+#define isl_map_lex_le (*isl_pointers__.p_isl_map_lex_le)
-+#define isl_map_n_out (*isl_pointers__.p_isl_map_n_out)
-+#define isl_map_range (*isl_pointers__.p_isl_map_range)
-+#define isl_map_set_tuple_id (*isl_pointers__.p_isl_map_set_tuple_id)
-+#define isl_map_universe (*isl_pointers__.p_isl_map_universe)
-+#define isl_options_set_on_error (*isl_pointers__.p_isl_options_set_on_error)
-+#define isl_options_set_schedule_serialize_sccs (*isl_pointers__.p_isl_options_set_schedule_serialize_sccs)
-+#define isl_printer_set_yaml_style (*isl_pointers__.p_isl_printer_set_yaml_style)
-+#define isl_options_set_schedule_max_constant_term (*isl_pointers__.p_isl_options_set_schedule_max_constant_term)
-+#define isl_options_set_schedule_maximize_band_depth (*isl_pointers__.p_isl_options_set_schedule_maximize_band_depth)
-+#define isl_printer_free (*isl_pointers__.p_isl_printer_free)
-+#define isl_printer_print_aff (*isl_pointers__.p_isl_printer_print_aff)
-+#define isl_printer_print_constraint (*isl_pointers__.p_isl_printer_print_constraint)
-+#define isl_printer_print_map (*isl_pointers__.p_isl_printer_print_map)
-+#define isl_printer_print_set (*isl_pointers__.p_isl_printer_print_set)
-+#define isl_printer_to_file (*isl_pointers__.p_isl_printer_to_file)
-+#define isl_pw_aff_add (*isl_pointers__.p_isl_pw_aff_add)
-+#define isl_pw_aff_alloc (*isl_pointers__.p_isl_pw_aff_alloc)
-+#define isl_pw_aff_copy (*isl_pointers__.p_isl_pw_aff_copy)
-+#define isl_pw_aff_eq_set (*isl_pointers__.p_isl_pw_aff_eq_set)
-+#define isl_pw_aff_free (*isl_pointers__.p_isl_pw_aff_free)
-+#define isl_pw_aff_from_aff (*isl_pointers__.p_isl_pw_aff_from_aff)
-+#define isl_pw_aff_ge_set (*isl_pointers__.p_isl_pw_aff_ge_set)
-+#define isl_pw_aff_gt_set (*isl_pointers__.p_isl_pw_aff_gt_set)
-+#define isl_pw_aff_is_cst (*isl_pointers__.p_isl_pw_aff_is_cst)
-+#define isl_pw_aff_le_set (*isl_pointers__.p_isl_pw_aff_le_set)
-+#define isl_pw_aff_lt_set (*isl_pointers__.p_isl_pw_aff_lt_set)
-+#define isl_pw_aff_mul (*isl_pointers__.p_isl_pw_aff_mul)
-+#define isl_pw_aff_ne_set (*isl_pointers__.p_isl_pw_aff_ne_set)
-+#define isl_pw_aff_nonneg_set (*isl_pointers__.p_isl_pw_aff_nonneg_set)
-+#define isl_pw_aff_set_tuple_id (*isl_pointers__.p_isl_pw_aff_set_tuple_id)
-+#define isl_pw_aff_sub (*isl_pointers__.p_isl_pw_aff_sub)
-+#define isl_pw_aff_zero_set (*isl_pointers__.p_isl_pw_aff_zero_set)
-+#define isl_schedule_free (*isl_pointers__.p_isl_schedule_free)
-+#define isl_schedule_get_band_forest (*isl_pointers__.p_isl_schedule_get_band_forest)
-+#define isl_set_add_constraint (*isl_pointers__.p_isl_set_add_constraint)
-+#define isl_set_add_dims (*isl_pointers__.p_isl_set_add_dims)
-+#define isl_set_apply (*isl_pointers__.p_isl_set_apply)
-+#define isl_set_coalesce (*isl_pointers__.p_isl_set_coalesce)
-+#define isl_set_copy (*isl_pointers__.p_isl_set_copy)
-+#define isl_set_dim (*isl_pointers__.p_isl_set_dim)
-+#define isl_set_fix_si (*isl_pointers__.p_isl_set_fix_si)
-+#define isl_set_free (*isl_pointers__.p_isl_set_free)
-+#define isl_set_get_space (*isl_pointers__.p_isl_set_get_space)
-+#define isl_set_get_tuple_id (*isl_pointers__.p_isl_set_get_tuple_id)
-+#define isl_set_intersect (*isl_pointers__.p_isl_set_intersect)
-+#define isl_set_is_empty (*isl_pointers__.p_isl_set_is_empty)
-+#define isl_set_n_dim (*isl_pointers__.p_isl_set_n_dim)
-+#define isl_set_nat_universe (*isl_pointers__.p_isl_set_nat_universe)
-+#define isl_set_project_out (*isl_pointers__.p_isl_set_project_out)
-+#define isl_set_set_tuple_id (*isl_pointers__.p_isl_set_set_tuple_id)
-+#define isl_set_universe (*isl_pointers__.p_isl_set_universe)
-+#define isl_space_add_dims (*isl_pointers__.p_isl_space_add_dims)
-+#define isl_space_alloc (*isl_pointers__.p_isl_space_alloc)
-+#define isl_space_copy (*isl_pointers__.p_isl_space_copy)
-+#define isl_space_dim (*isl_pointers__.p_isl_space_dim)
-+#define isl_space_domain (*isl_pointers__.p_isl_space_domain)
-+#define isl_space_find_dim_by_id (*isl_pointers__.p_isl_space_find_dim_by_id)
-+#define isl_space_free (*isl_pointers__.p_isl_space_free)
-+#define isl_space_from_domain (*isl_pointers__.p_isl_space_from_domain)
-+#define isl_space_get_tuple_id (*isl_pointers__.p_isl_space_get_tuple_id)
-+#define isl_space_params_alloc (*isl_pointers__.p_isl_space_params_alloc)
-+#define isl_space_range (*isl_pointers__.p_isl_space_range)
-+#define isl_space_set_alloc (*isl_pointers__.p_isl_space_set_alloc)
-+#define isl_space_set_dim_id (*isl_pointers__.p_isl_space_set_dim_id)
-+#define isl_space_set_tuple_id (*isl_pointers__.p_isl_space_set_tuple_id)
-+#define isl_union_map_add_map (*isl_pointers__.p_isl_union_map_add_map)
-+#define isl_union_map_align_params (*isl_pointers__.p_isl_union_map_align_params)
-+#define isl_union_map_apply_domain (*isl_pointers__.p_isl_union_map_apply_domain)
-+#define isl_union_map_apply_range (*isl_pointers__.p_isl_union_map_apply_range)
-+#define isl_union_map_compute_flow (*isl_pointers__.p_isl_union_map_compute_flow)
-+#define isl_union_map_copy (*isl_pointers__.p_isl_union_map_copy)
-+#define isl_union_map_empty (*isl_pointers__.p_isl_union_map_empty)
-+#define isl_union_map_flat_range_product (*isl_pointers__.p_isl_union_map_flat_range_product)
-+#define isl_union_map_foreach_map (*isl_pointers__.p_isl_union_map_foreach_map)
-+#define isl_union_map_free (*isl_pointers__.p_isl_union_map_free)
-+#define isl_union_map_from_map (*isl_pointers__.p_isl_union_map_from_map)
-+#define isl_union_map_get_ctx (*isl_pointers__.p_isl_union_map_get_ctx)
-+#define isl_union_map_get_space (*isl_pointers__.p_isl_union_map_get_space)
-+#define isl_union_map_gist_domain (*isl_pointers__.p_isl_union_map_gist_domain)
-+#define isl_union_map_gist_range (*isl_pointers__.p_isl_union_map_gist_range)
-+#define isl_union_map_intersect_domain (*isl_pointers__.p_isl_union_map_intersect_domain)
-+#define isl_union_map_is_empty (*isl_pointers__.p_isl_union_map_is_empty)
-+#define isl_union_map_subtract (*isl_pointers__.p_isl_union_map_subtract)
-+#define isl_union_map_union (*isl_pointers__.p_isl_union_map_union)
-+#define isl_union_set_add_set (*isl_pointers__.p_isl_union_set_add_set)
-+#define isl_union_set_compute_schedule (*isl_pointers__.p_isl_union_set_compute_schedule)
-+#define isl_union_set_copy (*isl_pointers__.p_isl_union_set_copy)
-+#define isl_union_set_empty (*isl_pointers__.p_isl_union_set_empty)
-+#define isl_union_set_from_set (*isl_pointers__.p_isl_union_set_from_set)
-+#define isl_aff_add_constant_val (*isl_pointers__.p_isl_aff_add_constant_val)
-+#define isl_aff_get_coefficient_val (*isl_pointers__.p_isl_aff_get_coefficient_val)
-+#define isl_aff_get_ctx (*isl_pointers__.p_isl_aff_get_ctx)
-+#define isl_aff_mod_val (*isl_pointers__.p_isl_aff_mod_val)
-+#define isl_ast_build_ast_from_schedule (*isl_pointers__.p_isl_ast_build_ast_from_schedule)
-+#define isl_ast_build_free (*isl_pointers__.p_isl_ast_build_free)
-+#define isl_ast_build_from_context (*isl_pointers__.p_isl_ast_build_from_context)
-+#define isl_ast_build_get_ctx (*isl_pointers__.p_isl_ast_build_get_ctx)
-+#define isl_ast_build_get_schedule (*isl_pointers__.p_isl_ast_build_get_schedule)
-+#define isl_ast_build_get_schedule_space (*isl_pointers__.p_isl_ast_build_get_schedule_space)
-+#define isl_ast_build_set_before_each_for (*isl_pointers__.p_isl_ast_build_set_before_each_for)
-+#define isl_ast_build_set_options (*isl_pointers__.p_isl_ast_build_set_options)
-+#define isl_ast_expr_free (*isl_pointers__.p_isl_ast_expr_free)
-+#define isl_ast_expr_from_val (*isl_pointers__.p_isl_ast_expr_from_val)
-+#define isl_ast_expr_get_ctx (*isl_pointers__.p_isl_ast_expr_get_ctx)
-+#define isl_ast_expr_get_id (*isl_pointers__.p_isl_ast_expr_get_id)
-+#define isl_ast_expr_get_op_arg (*isl_pointers__.p_isl_ast_expr_get_op_arg)
-+#define isl_ast_expr_get_op_n_arg (*isl_pointers__.p_isl_ast_expr_get_op_n_arg)
-+#define isl_ast_expr_get_op_type (*isl_pointers__.p_isl_ast_expr_get_op_type)
-+#define isl_ast_expr_get_type (*isl_pointers__.p_isl_ast_expr_get_type)
-+#define isl_ast_expr_get_val (*isl_pointers__.p_isl_ast_expr_get_val)
-+#define isl_ast_expr_sub (*isl_pointers__.p_isl_ast_expr_sub)
-+#define isl_ast_node_block_get_children (*isl_pointers__.p_isl_ast_node_block_get_children)
-+#define isl_ast_node_for_get_body (*isl_pointers__.p_isl_ast_node_for_get_body)
-+#define isl_ast_node_for_get_cond (*isl_pointers__.p_isl_ast_node_for_get_cond)
-+#define isl_ast_node_for_get_inc (*isl_pointers__.p_isl_ast_node_for_get_inc)
-+#define isl_ast_node_for_get_init (*isl_pointers__.p_isl_ast_node_for_get_init)
-+#define isl_ast_node_for_get_iterator (*isl_pointers__.p_isl_ast_node_for_get_iterator)
-+#define isl_ast_node_free (*isl_pointers__.p_isl_ast_node_free)
-+#define isl_ast_node_get_annotation (*isl_pointers__.p_isl_ast_node_get_annotation)
-+#define isl_ast_node_get_type (*isl_pointers__.p_isl_ast_node_get_type)
-+#define isl_ast_node_if_get_cond (*isl_pointers__.p_isl_ast_node_if_get_cond)
-+#define isl_ast_node_if_get_else (*isl_pointers__.p_isl_ast_node_if_get_else)
-+#define isl_ast_node_if_get_then (*isl_pointers__.p_isl_ast_node_if_get_then)
-+#define isl_ast_node_list_free (*isl_pointers__.p_isl_ast_node_list_free)
-+#define isl_ast_node_list_get_ast_node (*isl_pointers__.p_isl_ast_node_list_get_ast_node)
-+#define isl_ast_node_list_n_ast_node (*isl_pointers__.p_isl_ast_node_list_n_ast_node)
-+#define isl_ast_node_user_get_expr (*isl_pointers__.p_isl_ast_node_user_get_expr)
-+#define isl_constraint_set_coefficient_val (*isl_pointers__.p_isl_constraint_set_coefficient_val)
-+#define isl_constraint_set_constant_val (*isl_pointers__.p_isl_constraint_set_constant_val)
-+#define isl_id_get_user (*isl_pointers__.p_isl_id_get_user)
-+#define isl_local_space_get_ctx (*isl_pointers__.p_isl_local_space_get_ctx)
-+#define isl_map_fix_val (*isl_pointers__.p_isl_map_fix_val)
-+#define isl_options_set_ast_build_atomic_upper_bound (*isl_pointers__.p_isl_options_set_ast_build_atomic_upper_bound)
-+#define isl_printer_print_ast_node (*isl_pointers__.p_isl_printer_print_ast_node)
-+#define isl_printer_print_str (*isl_pointers__.p_isl_printer_print_str)
-+#define isl_printer_set_output_format (*isl_pointers__.p_isl_printer_set_output_format)
-+#define isl_pw_aff_mod_val (*isl_pointers__.p_isl_pw_aff_mod_val)
-+#define isl_schedule_constraints_compute_schedule (*isl_pointers__.p_isl_schedule_constraints_compute_schedule)
-+#define isl_schedule_constraints_on_domain (*isl_pointers__.p_isl_schedule_constraints_on_domain)
-+#define isl_schedule_constraints_set_coincidence (*isl_pointers__.p_isl_schedule_constraints_set_coincidence)
-+#define isl_schedule_constraints_set_proximity (*isl_pointers__.p_isl_schedule_constraints_set_proximity)
-+#define isl_schedule_constraints_set_validity (*isl_pointers__.p_isl_schedule_constraints_set_validity)
-+#define isl_set_get_dim_id (*isl_pointers__.p_isl_set_get_dim_id)
-+#define isl_set_max_val (*isl_pointers__.p_isl_set_max_val)
-+#define isl_set_min_val (*isl_pointers__.p_isl_set_min_val)
-+#define isl_set_params (*isl_pointers__.p_isl_set_params)
-+#define isl_space_align_params (*isl_pointers__.p_isl_space_align_params)
-+#define isl_space_map_from_domain_and_range (*isl_pointers__.p_isl_space_map_from_domain_and_range)
-+#define isl_space_set_tuple_name (*isl_pointers__.p_isl_space_set_tuple_name)
-+#define isl_space_wrap (*isl_pointers__.p_isl_space_wrap)
-+#define isl_union_map_from_domain_and_range (*isl_pointers__.p_isl_union_map_from_domain_and_range)
-+#define isl_union_map_range (*isl_pointers__.p_isl_union_map_range)
-+#define isl_union_set_union (*isl_pointers__.p_isl_union_set_union)
-+#define isl_union_set_universe (*isl_pointers__.p_isl_union_set_universe)
-+#define isl_val_2exp (*isl_pointers__.p_isl_val_2exp)
-+#define isl_val_add_ui (*isl_pointers__.p_isl_val_add_ui)
-+#define isl_val_copy (*isl_pointers__.p_isl_val_copy)
-+#define isl_val_free (*isl_pointers__.p_isl_val_free)
-+#define isl_val_int_from_si (*isl_pointers__.p_isl_val_int_from_si)
-+#define isl_val_int_from_ui (*isl_pointers__.p_isl_val_int_from_ui)
-+#define isl_val_mul (*isl_pointers__.p_isl_val_mul)
-+#define isl_val_neg (*isl_pointers__.p_isl_val_neg)
-+#define isl_val_sub (*isl_pointers__.p_isl_val_sub)
-+#define isl_printer_print_union_map (*isl_pointers__.p_isl_printer_print_union_map)
-+#define isl_pw_aff_get_ctx (*isl_pointers__.p_isl_pw_aff_get_ctx)
-+#define isl_val_is_int (*isl_pointers__.p_isl_val_is_int)
-+#define isl_ctx_get_max_operations (*isl_pointers__.p_isl_ctx_get_max_operations)
-+#define isl_ctx_set_max_operations (*isl_pointers__.p_isl_ctx_set_max_operations)
-+#define isl_ctx_last_error (*isl_pointers__.p_isl_ctx_last_error)
-+#define isl_ctx_reset_operations (*isl_pointers__.p_isl_ctx_reset_operations)
-+#define isl_map_coalesce (*isl_pointers__.p_isl_map_coalesce)
-+#define isl_printer_print_schedule (*isl_pointers__.p_isl_printer_print_schedule)
-+#define isl_set_set_dim_id (*isl_pointers__.p_isl_set_set_dim_id)
-+#define isl_union_map_coalesce (*isl_pointers__.p_isl_union_map_coalesce)
-+#define isl_multi_val_set_val (*isl_pointers__.p_isl_multi_val_set_val)
-+#define isl_multi_val_zero (*isl_pointers__.p_isl_multi_val_zero)
-+#define isl_options_set_schedule_max_coefficient (*isl_pointers__.p_isl_options_set_schedule_max_coefficient)
-+#define isl_options_set_tile_scale_tile_loops (*isl_pointers__.p_isl_options_set_tile_scale_tile_loops)
-+#define isl_schedule_copy (*isl_pointers__.p_isl_schedule_copy)
-+#define isl_schedule_get_map (*isl_pointers__.p_isl_schedule_get_map)
-+#define isl_schedule_map_schedule_node_bottom_up (*isl_pointers__.p_isl_schedule_map_schedule_node_bottom_up)
-+#define isl_schedule_node_band_get_permutable (*isl_pointers__.p_isl_schedule_node_band_get_permutable)
-+#define isl_schedule_node_band_get_space (*isl_pointers__.p_isl_schedule_node_band_get_space)
-+#define isl_schedule_node_band_tile (*isl_pointers__.p_isl_schedule_node_band_tile)
-+#define isl_schedule_node_child (*isl_pointers__.p_isl_schedule_node_child)
-+#define isl_schedule_node_free (*isl_pointers__.p_isl_schedule_node_free)
-+#define isl_schedule_node_get_child (*isl_pointers__.p_isl_schedule_node_get_child)
-+#define isl_schedule_node_get_ctx (*isl_pointers__.p_isl_schedule_node_get_ctx)
-+#define isl_schedule_node_get_type (*isl_pointers__.p_isl_schedule_node_get_type)
-+#define isl_schedule_node_n_children (*isl_pointers__.p_isl_schedule_node_n_children)
-+#define isl_union_map_is_equal (*isl_pointers__.p_isl_union_map_is_equal)
-+#define isl_union_access_info_compute_flow (*isl_pointers__.p_isl_union_access_info_compute_flow)
-+#define isl_union_access_info_from_sink (*isl_pointers__.p_isl_union_access_info_from_sink)
-+#define isl_union_access_info_set_may_source (*isl_pointers__.p_isl_union_access_info_set_may_source)
-+#define isl_union_access_info_set_must_source (*isl_pointers__.p_isl_union_access_info_set_must_source)
-+#define isl_union_access_info_set_schedule (*isl_pointers__.p_isl_union_access_info_set_schedule)
-+#define isl_union_flow_free (*isl_pointers__.p_isl_union_flow_free)
-+#define isl_union_flow_get_may_dependence (*isl_pointers__.p_isl_union_flow_get_may_dependence)
-+#define isl_union_flow_get_must_dependence (*isl_pointers__.p_isl_union_flow_get_must_dependence)
-+#define isl_aff_var_on_domain (*isl_pointers__.p_isl_aff_var_on_domain)
-+#define isl_multi_aff_from_aff (*isl_pointers__.p_isl_multi_aff_from_aff)
-+#define isl_schedule_get_ctx (*isl_pointers__.p_isl_schedule_get_ctx)
-+#define isl_multi_aff_set_tuple_id (*isl_pointers__.p_isl_multi_aff_set_tuple_id)
-+#define isl_multi_aff_dim (*isl_pointers__.p_isl_multi_aff_dim)
-+#define isl_schedule_get_domain (*isl_pointers__.p_isl_schedule_get_domain)
-+#define isl_union_set_is_empty (*isl_pointers__.p_isl_union_set_is_empty)
-+#define isl_union_set_get_space (*isl_pointers__.p_isl_union_set_get_space)
-+#define isl_union_pw_multi_aff_empty (*isl_pointers__.p_isl_union_pw_multi_aff_empty)
-+#define isl_union_set_foreach_set (*isl_pointers__.p_isl_union_set_foreach_set)
-+#define isl_union_set_free (*isl_pointers__.p_isl_union_set_free)
-+#define isl_multi_union_pw_aff_from_union_pw_multi_aff (*isl_pointers__.p_isl_multi_union_pw_aff_from_union_pw_multi_aff)
-+#define isl_multi_union_pw_aff_apply_multi_aff (*isl_pointers__.p_isl_multi_union_pw_aff_apply_multi_aff)
-+#define isl_schedule_insert_partial_schedule (*isl_pointers__.p_isl_schedule_insert_partial_schedule)
-+#define isl_union_pw_multi_aff_free (*isl_pointers__.p_isl_union_pw_multi_aff_free)
-+#define isl_pw_multi_aff_project_out_map (*isl_pointers__.p_isl_pw_multi_aff_project_out_map)
-+#define isl_union_pw_multi_aff_add_pw_multi_aff (*isl_pointers__.p_isl_union_pw_multi_aff_add_pw_multi_aff)
-+#define isl_schedule_from_domain (*isl_pointers__.p_isl_schedule_from_domain)
-+#define isl_schedule_sequence (*isl_pointers__.p_isl_schedule_sequence)
-+#define isl_ast_build_node_from_schedule (*isl_pointers__.p_isl_ast_build_node_from_schedule)
-+#define isl_ast_node_mark_get_node (*isl_pointers__.p_isl_ast_node_mark_get_node)
-+#define isl_schedule_node_band_member_get_ast_loop_type (*isl_pointers__.p_isl_schedule_node_band_member_get_ast_loop_type)
-+#define isl_schedule_node_band_member_set_ast_loop_type (*isl_pointers__.p_isl_schedule_node_band_member_set_ast_loop_type)
-+#define isl_val_n_abs_num_chunks (*isl_pointers__.p_isl_val_n_abs_num_chunks)
-+#define isl_val_get_abs_num_chunks (*isl_pointers__.p_isl_val_get_abs_num_chunks)
-+#define isl_val_int_from_chunks (*isl_pointers__.p_isl_val_int_from_chunks)
-+#define isl_val_is_neg (*isl_pointers__.p_isl_val_is_neg)
-+#define isl_version (*isl_pointers__.p_isl_version)
-+#define isl_options_get_on_error (*isl_pointers__.p_isl_options_get_on_error)
-+#define isl_ctx_reset_error (*isl_pointers__.p_isl_ctx_reset_error)
-+
- typedef struct poly_dr *poly_dr_p;
- 
- typedef struct poly_bb *poly_bb_p;
-@@ -448,5 +1033,6 @@ extern tree cached_scalar_evolution_in_r
- extern void dot_all_sese (FILE *, vec<sese_l> &);
- extern void dot_sese (sese_l &);
- extern void dot_cfg ();
-+extern const char *get_isl_version (bool);
- 
- #endif
---- gcc/graphite.c.jj	2015-11-04 14:15:32.000000000 +0100
-+++ gcc/graphite.c	2015-11-04 14:56:02.645536409 +0100
-@@ -60,6 +60,35 @@ along with GCC; see the file COPYING3.
- #include "tree-into-ssa.h"
- #include "graphite.h"
- 
-+__typeof (isl_pointers__) isl_pointers__;
-+
-+static bool
-+init_isl_pointers (void)
-+{
-+  void *h;
-+
-+  if (isl_pointers__.inited)
-+    return isl_pointers__.h != NULL;
-+  h = dlopen ("libisl.so.15", RTLD_LAZY);
-+  isl_pointers__.h = h;
-+  if (h == NULL)
-+    return false;
-+#define DYNSYM(x) \
-+  do \
-+    { \
-+      union { __typeof (isl_pointers__.p_##x) p; void *q; } u; \
-+      u.q = dlsym (h, #x); \
-+      if (u.q == NULL) \
-+	return false; \
-+      isl_pointers__.p_##x = u.p; \
-+    } \
-+  while (0)
-+  DYNSYMS
-+#undef DYNSYM
-+  isl_pointers__.inited = true;
-+  return true;
-+}
-+
- /* Print global statistics to FILE.  */
- 
- static void
-@@ -365,6 +394,15 @@ graphite_transform_loops (void)
-   if (parallelized_function_p (cfun->decl))
-     return;
- 
-+  if (number_of_loops (cfun) <= 1)
-+    return;
-+
-+  if (!init_isl_pointers ())
-+    {
-+      sorry ("Graphite loop optimizations cannot be used");
-+      return;
-+    }
-+
-   calculate_dominance_info (CDI_DOMINATORS);
- 
-   /* We rely on post-dominators during merging of SESE regions so those
-@@ -455,6 +493,14 @@ graphite_transform_loops (void)
-     }
- }
- 
-+const char *
-+get_isl_version (bool force)
-+{
-+  if (force)
-+    init_isl_pointers ();
-+  return (isl_pointers__.inited && isl_version) ? isl_version () : "none";
-+}
-+
- #else /* If isl is not available: #ifndef HAVE_isl.  */
- 
- static void
---- gcc/toplev.c.jj	2017-02-19 13:02:31.000000000 +0100
-+++ gcc/toplev.c	2017-02-19 16:50:25.536301350 +0100
-@@ -94,6 +94,7 @@ along with GCC; see the file COPYING3.
- 
- #ifdef HAVE_isl
- #include <isl/version.h>
-+extern const char *get_isl_version (bool);
- #endif
- 
- static void general_init (const char *, bool);
-@@ -683,7 +684,7 @@ print_version (FILE *file, const char *i
- #ifndef HAVE_isl
- 	   "none"
- #else
--	   isl_version ()
-+	   get_isl_version (*indent == 0)
- #endif
- 	   );
-   if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))

diff --git a/gcc11-isl-dl2.patch b/gcc11-isl-dl2.patch
deleted file mode 100644
index ac14ed3..0000000
--- a/gcc11-isl-dl2.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-2011-04-04  Jakub Jelinek  <jakub@redhat.com>
-
-	* toplev.c (toplev_main_argv): New variable.
-	(toplev_main): Initialize it.
-	* graphite.c (init_isl_pointers): Load libisl.so.15 from gcc's private
-	directory.
-
---- gcc/toplev.c.jj	2008-12-09 23:59:10.000000000 +0100
-+++ gcc/toplev.c	2009-01-27 14:33:52.000000000 +0100
-@@ -117,6 +117,8 @@ static void compile_file (void);
- /* True if we don't need a backend (e.g. preprocessing only).  */
- static bool no_backend;
- 
-+const char **toplev_main_argv;
-+
- /* Decoded options, and number of such options.  */
- struct cl_decoded_option *save_decoded_options;
- unsigned int save_decoded_options_count;
-@@ -2287,6 +2289,8 @@ toplev::main (int argc, char **argv)
- 
-   expandargv (&argc, &argv);
- 
-+  toplev_main_argv = CONST_CAST2 (const char **, char **, argv);
-+
-   /* Initialization of GCC's environment, and diagnostics.  */
-   general_init (argv[0], m_init_signals);
- 
---- gcc/graphite.c.jj	2010-12-01 10:24:32.000000000 -0500
-+++ gcc/graphite.c	2010-12-01 11:46:07.832118193 -0500
-@@ -64,11 +64,39 @@ __typeof (isl_pointers__) isl_pointers__
- static bool
- init_isl_pointers (void)
- {
--  void *h;
-+  void *h = NULL;
-+  extern const char **toplev_main_argv;
-+  char *buf, *p;
-+  size_t len;
- 
-   if (isl_pointers__.inited)
-     return isl_pointers__.h != NULL;
--  h = dlopen ("libisl.so.15", RTLD_LAZY);
-+  len = progname - toplev_main_argv[0];
-+  buf = XALLOCAVAR (char, len + sizeof "libisl.so.15");
-+  memcpy (buf, toplev_main_argv[0], len);
-+  strcpy (buf + len, "libisl.so.15");
-+  len += sizeof "libisl.so.15";
-+  p = strstr (buf, "/libexec/");
-+  if (p != NULL)
-+    {
-+      while (1)
-+	{
-+	  char *q = strstr (p + 8, "/libexec/");
-+	  if (q == NULL)
-+	    break;
-+	  p = q;
-+	}
-+      memmove (p + 4, p + 8, len - (p + 8 - buf));
-+      h = dlopen (buf, RTLD_LAZY);
-+      if (h == NULL)
-+	{
-+	  len = progname - toplev_main_argv[0];
-+	  memcpy (buf, toplev_main_argv[0], len);
-+	  strcpy (buf + len, "libisl.so.15");
-+	}
-+    }
-+  if (h == NULL)
-+    h = dlopen (buf, RTLD_LAZY);
-   isl_pointers__.h = h;
-   if (h == NULL)
-     return false;

diff --git a/gcc11-libgcc-link.patch b/gcc11-libgcc-link.patch
deleted file mode 100644
index 8551934..0000000
--- a/gcc11-libgcc-link.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-libgcc: Honor LDFLAGS_FOR_TARGET when linking libgcc_s
-
-When building gcc with some specific LDFLAGS_FOR_TARGET, e.g.
-LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
-those flags propagate info linking of target shared libraries,
-e.g. lib{ubsan,tsan,stdc++,quadmath,objc,lsan,itm,gphobos,gdruntime,gomp,go,gfortran,atomic,asan}.so.*
-but there is one important exception, libgcc_s.so.* linking ignores it.
-
-The following patch fixes that.
-
-Bootstrapped/regtested on x86_64-linux with LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
-and verified that libgcc_s.so.* is BIND_NOW when it previously wasn't, and
-without any LDFLAGS_FOR_TARGET on x86_64-linux and i686-linux.
-There on x86_64-linux I've verified that the libgcc_s.so.1 linking command
-line for -m64 is identical except for whitespace to one without the patch,
-and for -m32 multilib $(LDFLAGS) actually do supply there an extra -m32
-that also repeats later in the @multilib_flags@, which should be harmless.
-
-2021-08-04  Jakub Jelinek  <jakub@redhat.com>
-
-	* config/t-slibgcc (SHLIB_LINK): Add $(LDFLAGS).
-	* config/t-slibgcc-darwin (SHLIB_LINK): Likewise.
-	* config/t-slibgcc-vms (SHLIB_LINK): Likewise.
-
---- libgcc/config/t-slibgcc
-+++ libgcc/config/t-slibgcc
-@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
- 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
- 
- SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
--	$(SHLIB_LDFLAGS) \
-+	$(SHLIB_LDFLAGS) $(LDFLAGS) \
- 	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
- 	$(SHLIB_OBJS) $(SHLIB_LC) && \
- 	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
---- libgcc/config/t-slibgcc-darwin
-+++ libgcc/config/t-slibgcc-darwin
-@@ -15,7 +15,7 @@ SHLIB_LC = -lc
- # Note that this version is used for the loader, not the linker; the linker
- # uses the stub versions named by the versioned members of $(INSTALL_FILES).
- 
--SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
-+SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
- 	-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
- 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
- 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
---- libgcc/config/t-slibgcc-vms
-+++ libgcc/config/t-slibgcc-vms
-@@ -22,7 +22,7 @@ SHLIB_LINK = \
-   objdump --syms $(SHLIB_OBJS) | \
-   $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt ; \
-   echo "case_sensitive=NO" >> SYMVEC_$$$$.opt; \
--  $(CC) $(LIBGCC2_CFLAGS) -nodefaultlibs \
-+  $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -nodefaultlibs \
-   -shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \
-   --for-linker=SYMVEC_$$$$.opt \
-   --for-linker=gsmatch=equal,$(shlib_version)

diff --git a/gcc11-libgomp-omp_h-multilib.patch b/gcc11-libgomp-omp_h-multilib.patch
deleted file mode 100644
index d0e98d1..0000000
--- a/gcc11-libgomp-omp_h-multilib.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-2008-06-09  Jakub Jelinek  <jakub@redhat.com>
-
-	* omp.h.in (omp_nest_lock_t): Fix up for Linux multilibs.
-
---- libgomp/omp.h.in.jj	2008-06-09 13:34:05.000000000 +0200
-+++ libgomp/omp.h.in	2008-06-09 13:34:48.000000000 +0200
-@@ -42,8 +42,8 @@ typedef struct
- 
- typedef struct
- {
--  unsigned char _x[@OMP_NEST_LOCK_SIZE@] 
--    __attribute__((__aligned__(@OMP_NEST_LOCK_ALIGN@)));
-+  unsigned char _x[8 + sizeof (void *)] 
-+    __attribute__((__aligned__(sizeof (void *))));
- } omp_nest_lock_t;
- #endif
- 

diff --git a/gcc11-libstdc++-docs.patch b/gcc11-libstdc++-docs.patch
deleted file mode 100644
index 4b4f9f8..0000000
--- a/gcc11-libstdc++-docs.patch
+++ /dev/null
@@ -1,24 +0,0 @@
---- libstdc++-v3/doc/html/index.html.jj	2011-01-03 12:53:21.282829010 +0100
-+++ libstdc++-v3/doc/html/index.html	2011-01-04 18:06:28.999851145 +0100
-@@ -5,6 +5,8 @@
-       <a class="link" href="https://www.fsf.org" target="_top">FSF
-       </a>
-     </p><p>
-+      Release 11.2.1
-+    </p><p>
-       Permission is granted to copy, distribute and/or modify this
-       document under the terms of the GNU Free Documentation
-       License, Version 1.2 or any later version published by the
---- libstdc++-v3/doc/html/api.html.jj	2011-01-03 12:53:21.000000000 +0100
-+++ libstdc++-v3/doc/html/api.html	2011-01-04 18:12:01.672757784 +0100
-@@ -20,7 +20,9 @@
-   member functions for the library classes, finding out what is in a
-   particular include file, looking at inheritance diagrams, etc.
- </p><p>
--  The API documentation, rendered into HTML, can be viewed online
-+  The API documentation, rendered into HTML, can be viewed locally
-+  <a class="link" href="api/index.html" target="_top">for the 11.2.1 release</a>,
-+  online
-   <a class="link" href="http://gcc.gnu.org/onlinedocs/" target="_top">for each GCC release</a>
-   and
-   <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html" target="_top">

diff --git a/gcc11-libtool-no-rpath.patch b/gcc11-libtool-no-rpath.patch
deleted file mode 100644
index 466c661..0000000
--- a/gcc11-libtool-no-rpath.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-libtool sucks.
---- ltmain.sh.jj	2007-12-07 14:53:21.000000000 +0100
-+++ ltmain.sh	2008-09-05 21:51:48.000000000 +0200
-@@ -5394,6 +5394,7 @@ EOF
- 	  rpath="$finalize_rpath"
- 	  test "$mode" != relink && rpath="$compile_rpath$rpath"
- 	  for libdir in $rpath; do
-+	    case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
- 	    if test -n "$hardcode_libdir_flag_spec"; then
- 	      if test -n "$hardcode_libdir_separator"; then
- 		if test -z "$hardcode_libdirs"; then
-@@ -6071,6 +6072,7 @@ EOF
-       rpath=
-       hardcode_libdirs=
-       for libdir in $compile_rpath $finalize_rpath; do
-+	case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
- 	if test -n "$hardcode_libdir_flag_spec"; then
- 	  if test -n "$hardcode_libdir_separator"; then
- 	    if test -z "$hardcode_libdirs"; then
-@@ -6120,6 +6122,7 @@ EOF
-       rpath=
-       hardcode_libdirs=
-       for libdir in $finalize_rpath; do
-+	case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
- 	if test -n "$hardcode_libdir_flag_spec"; then
- 	  if test -n "$hardcode_libdir_separator"; then
- 	    if test -z "$hardcode_libdirs"; then

diff --git a/gcc11-no-add-needed.patch b/gcc11-no-add-needed.patch
deleted file mode 100644
index 5817299..0000000
--- a/gcc11-no-add-needed.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-2010-02-08  Roland McGrath  <roland@redhat.com>
-
-	* config/gnu-user.h (LINK_EH_SPEC): Pass --no-add-needed to the linker.
-	* config/alpha/elf.h (LINK_EH_SPEC): Likewise.
-	* config/ia64/linux.h (LINK_EH_SPEC): Likewise.
-
---- gcc/config/alpha/elf.h.jj	2011-01-03 12:52:31.118056764 +0100
-+++ gcc/config/alpha/elf.h	2011-01-04 18:14:10.931874160 +0100
-@@ -168,5 +168,5 @@ extern int alpha_this_gpdisp_sequence_nu
-    I imagine that other systems will catch up.  In the meantime, it
-    doesn't harm to make sure that the data exists to be used later.  */
- #if defined(HAVE_LD_EH_FRAME_HDR)
--#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
-+#define LINK_EH_SPEC "--no-add-needed %{!static|static-pie:--eh-frame-hdr} "
- #endif
---- gcc/config/ia64/linux.h.jj	2011-01-03 13:02:11.462994522 +0100
-+++ gcc/config/ia64/linux.h	2011-01-04 18:14:10.931874160 +0100
-@@ -76,7 +76,7 @@ do {						\
-    Signalize that because we have fde-glibc, we don't need all C shared libs
-    linked against -lgcc_s.  */
- #undef LINK_EH_SPEC
--#define LINK_EH_SPEC ""
-+#define LINK_EH_SPEC "--no-add-needed "
- 
- #undef TARGET_INIT_LIBFUNCS
- #define TARGET_INIT_LIBFUNCS ia64_soft_fp_init_libfuncs
---- gcc/config/gnu-user.h.jj	2011-01-03 12:53:03.739057299 +0100
-+++ gcc/config/gnu-user.h	2011-01-04 18:14:10.932814884 +0100
-@@ -106,7 +106,7 @@ see the files COPYING3 and COPYING.RUNTI
- #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
- 
- #if defined(HAVE_LD_EH_FRAME_HDR)
--#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
-+#define LINK_EH_SPEC "--no-add-needed %{!static|static-pie:--eh-frame-hdr} "
- #endif
- 
- #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \

diff --git a/gcc11-pr101786.patch b/gcc11-pr101786.patch
deleted file mode 100644
index 427c10a..0000000
--- a/gcc11-pr101786.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-c++: Optimize constinit thread_local vars [PR101786]
-
-The paper that introduced constinit mentioned in rationale that constinit
-can be used on externs as well and that it can be used to avoid the
-thread_local initialization wrappers, because the standard requires that
-if constinit is present on any declaration, it is also present on the
-initialization declaration, even if it is in some other TU etc.
-
-There is a small problem though, we use the tls wrappers not just if
-the thread_local variable needs dynamic initialization, but also when
-it has static initialization, but non-trivial destructor, as the
-"dynamic initialization" in that case needs to register the destructor.
-
-So, the following patch optimizes constinit thread_local vars only
-if we can prove they will not have non-trivial destructors.  That includes
-the case where we have incomplete type where we don't know and need to
-conservatively assume the type will have non-trivial destructor at the
-initializing declaration side.
-
-2021-08-11  Jakub Jelinek  <jakub@redhat.com>
-
-	PR c++/101786
-	* decl2.c (var_defined_without_dynamic_init): Return true for
-	DECL_DECLARED_CONSTINIT_P with complete type and trivial destructor.
-
-	* g++.dg/cpp2a/constinit16.C: New test.
-
---- gcc/cp/decl2.c
-+++ gcc/cp/decl2.c
-@@ -3447,6 +3447,12 @@ set_guard (tree guard)
- static bool
- var_defined_without_dynamic_init (tree var)
- {
-+  /* constinit vars are guaranteed to not have dynamic initializer,
-+     but still registering the destructor counts as dynamic initialization.  */
-+  if (DECL_DECLARED_CONSTINIT_P (var)
-+      && COMPLETE_TYPE_P (TREE_TYPE (var))
-+      && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var)))
-+    return true;
-   /* If it's defined in another TU, we can't tell.  */
-   if (DECL_EXTERNAL (var))
-     return false;
---- gcc/testsuite/g++.dg/cpp2a/constinit16.C
-+++ gcc/testsuite/g++.dg/cpp2a/constinit16.C
-@@ -0,0 +1,21 @@
-+// PR c++/101786
-+// { dg-do compile { target c++20 } }
-+// { dg-add-options tls }
-+// { dg-require-alias "" }
-+// { dg-require-effective-target tls_runtime }
-+// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar1" } }
-+// { dg-final { scan-assembler "_ZTH17mythreadlocalvar2" } }
-+// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar3" } }
-+// { dg-final { scan-assembler "_ZTH17mythreadlocalvar4" } }
-+
-+extern thread_local constinit int mythreadlocalvar1;
-+struct S;
-+extern thread_local constinit S mythreadlocalvar2;
-+struct T { int t; };
-+extern thread_local constinit T mythreadlocalvar3;
-+struct U { int u; ~U (); };
-+extern thread_local constinit U mythreadlocalvar4;
-+int foo () { return mythreadlocalvar1; }
-+S *bar () { return &mythreadlocalvar2; }
-+T *baz () { return &mythreadlocalvar3; }
-+U *qux () { return &mythreadlocalvar4; }

diff --git a/gcc11-pr99341-revert.patch b/gcc11-pr99341-revert.patch
deleted file mode 100644
index c7419cb..0000000
--- a/gcc11-pr99341-revert.patch
+++ /dev/null
@@ -1,176 +0,0 @@
-libstdc++: Remove symbols for new std::call_once implementation [PR 99341]
-    
-This removes the new symbols added for the new futex-based
-std::call_once implementation. These symbols were new on trunk, so not
-in any released version. However, they are already present in some
-beta distro releases (Fedora Linux 34) and in Fedora Linux rawhide. This
-change can be locally reverted by distros that need to keep the symbols
-present until affected packages have been rebuilt.
-
-Revert:
-2021-03-12  Jonathan Wakely  <jwakely@redhat.com>
-    
-	PR libstdc++/99341
-	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Remove
-	std::once_flag symbols.
-	* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Likewise.
-	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Likewise.
-	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
-	Likewise.
-	* config/abi/pre/gnu.ver: Likewise.
-	* src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX]
-	(struct __once_flag_compat): Remove.
-	(_ZNSt9once_flag11_M_activateEv): Remove.
-	(_ZNSt9once_flag9_M_finishEb): Remove.
-
---- libstdc++-v3/config/abi/post/aarch64-linux-gnu/baseline_symbols.txt
-+++ libstdc++-v3/config/abi/post/aarch64-linux-gnu/baseline_symbols.txt
-@@ -4086,6 +4086,8 @@ FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEEC2Em@@GLIBCXX
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED0Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED1Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED2Ev@@GLIBCXX_3.4
-+FUNC:_ZNSt9once_flag11_M_activateEv@@GLIBCXX_3.4.29
-+FUNC:_ZNSt9once_flag9_M_finishEb@@GLIBCXX_3.4.29
- FUNC:_ZNSt9strstream3strEv@@GLIBCXX_3.4
- FUNC:_ZNSt9strstream6freezeEb@@GLIBCXX_3.4
- FUNC:_ZNSt9strstreamC1EPciSt13_Ios_Openmode@@GLIBCXX_3.4
---- libstdc++-v3/config/abi/post/ia64-linux-gnu/baseline_symbols.txt
-+++ libstdc++-v3/config/abi/post/ia64-linux-gnu/baseline_symbols.txt
-@@ -4086,6 +4086,8 @@ FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEEC2Em@@GLIBCXX
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED0Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED1Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED2Ev@@GLIBCXX_3.4
-+FUNC:_ZNSt9once_flag11_M_activateEv@@GLIBCXX_3.4.29
-+FUNC:_ZNSt9once_flag9_M_finishEb@@GLIBCXX_3.4.29
- FUNC:_ZNSt9strstream3strEv@@GLIBCXX_3.4
- FUNC:_ZNSt9strstream6freezeEb@@GLIBCXX_3.4
- FUNC:_ZNSt9strstreamC1EPciSt13_Ios_Openmode@@GLIBCXX_3.4
---- libstdc++-v3/config/abi/post/m68k-linux-gnu/baseline_symbols.txt
-+++ libstdc++-v3/config/abi/post/m68k-linux-gnu/baseline_symbols.txt
-@@ -4086,6 +4086,8 @@ FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEEC2Ej@@GLIBCXX
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED0Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED1Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED2Ev@@GLIBCXX_3.4
-+FUNC:_ZNSt9once_flag11_M_activateEv@@GLIBCXX_3.4.29
-+FUNC:_ZNSt9once_flag9_M_finishEb@@GLIBCXX_3.4.29
- FUNC:_ZNSt9strstream3strEv@@GLIBCXX_3.4
- FUNC:_ZNSt9strstream6freezeEb@@GLIBCXX_3.4
- FUNC:_ZNSt9strstreamC1EPciSt13_Ios_Openmode@@GLIBCXX_3.4
---- libstdc++-v3/config/abi/post/riscv64-linux-gnu/baseline_symbols.txt
-+++ libstdc++-v3/config/abi/post/riscv64-linux-gnu/baseline_symbols.txt
-@@ -4086,6 +4086,8 @@ FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEEC2Em@@GLIBCXX
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED0Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED1Ev@@GLIBCXX_3.4
- FUNC:_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED2Ev@@GLIBCXX_3.4
-+FUNC:_ZNSt9once_flag11_M_activateEv@@GLIBCXX_3.4.29
-+FUNC:_ZNSt9once_flag9_M_finishEb@@GLIBCXX_3.4.29
- FUNC:_ZNSt9strstream3strEv@@GLIBCXX_3.4
- FUNC:_ZNSt9strstream6freezeEb@@GLIBCXX_3.4
- FUNC:_ZNSt9strstreamC1EPciSt13_Ios_Openmode@@GLIBCXX_3.4
---- libstdc++-v3/config/abi/pre/gnu.ver
-+++ libstdc++-v3/config/abi/pre/gnu.ver
-@@ -2388,6 +2388,11 @@ GLIBCXX_3.4.29 {
-     _ZNKRSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEv;
-     _ZNSt7__cxx1118basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE3strEONS_12basic_stringI[cw]S2_S3_EE;
- 
-+    # std::once_flag::_M_activate()
-+    _ZNSt9once_flag11_M_activateEv;
-+    # std::once_flag::_M_finish(bool)
-+    _ZNSt9once_flag9_M_finishEb;
-+
-     # std::to_chars(char*, char*, [float|double|long double])
-     _ZSt8to_charsPcS_[def];
-     # std::to_chars(char*, char*, [float|double|long double], chars_format)
---- libstdc++-v3/src/c++11/mutex.cc
-+++ libstdc++-v3/src/c++11/mutex.cc
-@@ -26,6 +26,90 @@
- 
- #ifdef _GLIBCXX_HAS_GTHREADS
- 
-+#if defined _GLIBCXX_SHARED && ! _GLIBCXX_INLINE_VERSION
-+
-+#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
-+# include <syscall.h>
-+# include <unistd.h>
-+# include <limits.h>
-+
-+namespace std _GLIBCXX_VISIBILITY(default)
-+{
-+_GLIBCXX_BEGIN_NAMESPACE_VERSION
-+
-+struct __once_flag_compat
-+{
-+  enum _Bits : int { _Init = 0, _Active = 1, _Done = 2 };
-+  int _M_once = 0;
-+  bool _M_activate();
-+  void _M_finish(bool returning) noexcept;
-+};
-+
-+bool
-+__once_flag_compat::_M_activate()
-+{
-+  if (__gnu_cxx::__is_single_threaded())
-+    {
-+      if (_M_once == _Bits::_Done)
-+	return false;
-+      _M_once = _Bits::_Active;
-+      return true;
-+    }
-+
-+  while (true)
-+    {
-+      int expected = _Bits::_Init;
-+      constexpr int active = _Bits::_Active;
-+      if (__atomic_compare_exchange_n(&_M_once, &expected, active, false,
-+					    __ATOMIC_ACQ_REL,
-+					    __ATOMIC_ACQUIRE))
-+	{
-+	  // This thread is now doing an active execution.
-+	  return true;
-+	}
-+
-+      if (expected == _Bits::_Done)
-+	return false; // A returning execution happened, this is passive.
-+
-+      // Otherwise, an active execution is happening. Wait for it to finish.
-+      constexpr int futex_wait = 128; // FUTEX_WAIT_PRIVATE
-+      syscall (SYS_futex, &_M_once, futex_wait, expected, 0);
-+    }
-+}
-+
-+void
-+std::__once_flag_compat::_M_finish(bool returning) noexcept
-+{
-+  const int newval = returning ? _Bits::_Done : _Bits::_Init;
-+  if (__gnu_cxx::__is_single_threaded())
-+    {
-+      __glibcxx_assert(_M_once == _Bits::_Active);
-+      _M_once = newval;
-+    }
-+  else
-+    {
-+      int prev [[maybe_unused]]
-+	= __atomic_exchange_n(&_M_once, newval, __ATOMIC_RELEASE);
-+      __glibcxx_assert(prev & _Bits::_Active);
-+      // Wake any other threads waiting for this execution to finish.
-+      constexpr int futex_wake = 129; // FUTEX_WAKE_PRIVATE
-+      syscall (SYS_futex, &_M_once, futex_wake, INT_MAX);
-+    }
-+}
-+
-+#pragma GCC diagnostic push
-+#pragma GCC diagnostic ignored "-Wattribute-alias"
-+extern "C" bool _ZNSt9once_flag11_M_activateEv()
-+  __attribute__((alias ("_ZNSt18__once_flag_compat11_M_activateEv")));
-+extern "C" void _ZNSt9once_flag9_M_finishEb() noexcept
-+  __attribute__((alias ("_ZNSt18__once_flag_compat9_M_finishEb")));
-+#pragma GCC diagnostic pop
-+
-+_GLIBCXX_END_NAMESPACE_VERSION
-+} // namespace std
-+#endif // FUTEX
-+#endif // ONCE_FLAG_COMPAT && SHARED && ! INLINE_VERSION
-+
- namespace std _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION

diff --git a/gcc11-rh1574936.patch b/gcc11-rh1574936.patch
deleted file mode 100644
index 6b4be0c..0000000
--- a/gcc11-rh1574936.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-crt files and statically linked libgcc objects cause false positives
-in annobin coverage, so we add the assembler flag to generate notes
-for them.
-
-The patch also adds notes to libgcc_s.so, but this is harmless because
-these notes only confer that there is no other annobin markup.
-
-2018-07-25  Florian Weimer  <fweimer@redhat.com>
-
-	* Makefile.in (LIBGCC2_CFLAGS, CRTSTUFF_CFLAGS): Add
-	-Wa,--generate-missing-build-notes=yes.
-
---- libgcc/Makefile.in	2018-01-13 13:05:41.000000000 +0100
-+++ libgcc/Makefile.in	2018-07-25 13:15:02.036226940 +0200
-@@ -246,6 +246,7 @@ LIBGCC2_DEBUG_CFLAGS = -g
- LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
- 		 $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
- 		 -fbuilding-libgcc -fno-stack-protector \
-+		 -Wa,--generate-missing-build-notes=yes \
- 		 $(INHIBIT_LIBC_CFLAGS)
- 
- # Additional options to use when compiling libgcc2.a.
-@@ -301,6 +302,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(IN
-   $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
-   -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
-   -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
-+  -Wa,--generate-missing-build-notes=yes \
-   $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
- 
- # Extra flags to use when compiling crt{begin,end}.o.

diff --git a/gcc11-sparc-config-detection.patch b/gcc11-sparc-config-detection.patch
deleted file mode 100644
index bb06b35..0000000
--- a/gcc11-sparc-config-detection.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- gcc/config.gcc.jj	2008-04-24 15:42:46.000000000 -0500
-+++ gcc/config.gcc	2008-04-24 15:44:51.000000000 -0500
-@@ -2790,7 +2790,7 @@ sparc-*-rtems*)
- 	tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp-elf.h sparc/rtemself.h rtems.h newlib-stdint.h"
- 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-rtems"
- 	;;
--sparc-*-linux*)
-+sparc-*-linux* | sparcv9-*-linux*)
- 	tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/tso.h"
- 	extra_options="${extra_options} sparc/long-double-switch.opt"
- 	case ${target} in
-@@ -2844,7 +2844,7 @@ sparc64-*-rtems*)
- 	extra_options="${extra_options}"
- 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-rtems-64"
- 	;;
--sparc64-*-linux*)
-+sparc64*-*-linux*)
- 	tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/default64.h sparc/linux64.h sparc/tso.h"
- 	extra_options="${extra_options} sparc/long-double-switch.opt"
- 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-linux64"
---- libgcc/config.host.jj	2008-04-24 15:46:19.000000000 -0500
-+++ libgcc/config.host	2008-04-24 15:46:49.000000000 -0500
-@@ -1002,7 +1002,7 @@ sparc-*-elf*)
- 	tmake_file="${tmake_file} t-fdpbit t-crtfm"
- 	extra_parts="$extra_parts crti.o crtn.o crtfastmath.o"
- 	;;
--sparc-*-linux*)		# SPARC's running GNU/Linux, libc6
-+sparc-*-linux* | sparcv9-*-linux*)		# SPARC's running GNU/Linux, libc6
- 	tmake_file="${tmake_file} t-crtfm"
- 	if test "${host_address}" = 64; then
- 		tmake_file="$tmake_file sparc/t-linux64"
-@@ -1050,7 +1050,7 @@ sparc64-*-freebsd*|ultrasparc-*-freebsd*
- 	tmake_file="$tmake_file t-crtfm"
- 	extra_parts="$extra_parts crtfastmath.o"
- 	;;
--sparc64-*-linux*)		# 64-bit SPARC's running GNU/Linux
-+sparc64*-*-linux*)		# 64-bit SPARC's running GNU/Linux
- 	extra_parts="$extra_parts crtfastmath.o"
- 	tmake_file="${tmake_file} t-crtfm sparc/t-linux"
- 	if test "${host_address}" = 64; then

diff --git a/gcc11-stringify-__VA_OPT__-2.patch b/gcc11-stringify-__VA_OPT__-2.patch
deleted file mode 100644
index 987f738..0000000
--- a/gcc11-stringify-__VA_OPT__-2.patch
+++ /dev/null
@@ -1,197 +0,0 @@
-libcpp: Fix up #__VA_OPT__ handling [PR103415]
-
-stringify_arg uses pfile->u_buff to create the string literal.
-Unfortunately, paste_tokens -> _cpp_lex_direct -> lex_number -> _cpp_unaligned_alloc
-can in some cases use pfile->u_buff too, which results in losing everything
-prepared for the string literal until the token pasting.
-
-The following patch fixes that by not calling paste_token during the
-construction of the string literal, but doing that before.  All the tokens
-we are processing have been pushed into a token buffer using
-tokens_buff_add_token so it is fine if we paste some of them in that buffer
-(successful pasting creates a new token in that buffer), move following
-tokens if any to make it contiguous, pop (throw away) the extra tokens at
-the end and then do stringify_arg.
-
-Also, paste_tokens now copies over PREV_WHITE and PREV_FALLTHROUGH flags
-from the original lhs token to the replacement token.  Copying that way
-the PREV_WHITE flag is needed for the #__VA_OPT__ handling and copying
-over PREV_FALLTHROUGH fixes the new Wimplicit-fallthrough-38.c test.
-
-2021-12-01  Jakub Jelinek  <jakub@redhat.com>
-
-	PR preprocessor/103415
-libcpp/
-	* macro.c (stringify_arg): Remove va_opt argument and va_opt handling.
-	(paste_tokens): On successful paste or in PREV_WHITE and
-	PREV_FALLTHROUGH flags from the *plhs token to the new token.
-	(replace_args): Adjust stringify_arg callers.  For #__VA_OPT__,
-	perform token pasting in a separate loop before stringify_arg call.
-gcc/testsuite/
-	* c-c++-common/cpp/va-opt-8.c: New test.
-	* c-c++-common/Wimplicit-fallthrough-38.c: New test.
-
---- libcpp/macro.c.jj
-+++ libcpp/macro.c
-@@ -295,7 +295,7 @@ static cpp_context *next_context (cpp_reader *);
- static const cpp_token *padding_token (cpp_reader *, const cpp_token *);
- static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
- static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **,
--				       unsigned int, bool);
-+				       unsigned int);
- static void paste_all_tokens (cpp_reader *, const cpp_token *);
- static bool paste_tokens (cpp_reader *, location_t,
- 			  const cpp_token **, const cpp_token *);
-@@ -834,8 +834,7 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
- /* Convert a token sequence FIRST to FIRST+COUNT-1 to a single string token
-    according to the rules of the ISO C #-operator.  */
- static const cpp_token *
--stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
--	       bool va_opt)
-+stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count)
- {
-   unsigned char *dest;
-   unsigned int i, escape_it, backslash_count = 0;
-@@ -852,24 +851,6 @@ stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
-     {
-       const cpp_token *token = first[i];
- 
--      if (va_opt && (token->flags & PASTE_LEFT))
--	{
--	  location_t virt_loc = pfile->invocation_location;
--	  const cpp_token *rhs;
--	  do
--	    {
--	      if (i == count)
--		abort ();
--	      rhs = first[++i];
--	      if (!paste_tokens (pfile, virt_loc, &token, rhs))
--		{
--		  --i;
--		  break;
--		}
--	    }
--	  while (rhs->flags & PASTE_LEFT);
--	}
--
-       if (token->type == CPP_PADDING)
- 	{
- 	  if (source == NULL
-@@ -1003,6 +984,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
-       return false;
-     }
- 
-+  lhs->flags |= (*plhs)->flags & (PREV_WHITE | PREV_FALLTHROUGH);
-   *plhs = lhs;
-   _cpp_pop_buffer (pfile);
-   return true;
-@@ -1945,8 +1927,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
- 	if (src->flags & STRINGIFY_ARG)
- 	  {
- 	    if (!arg->stringified)
--	      arg->stringified = stringify_arg (pfile, arg->first, arg->count,
--						false);
-+	      arg->stringified = stringify_arg (pfile, arg->first, arg->count);
- 	  }
- 	else if ((src->flags & PASTE_LEFT)
- 		 || (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT)))
-@@ -2066,11 +2047,46 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
- 		{
- 		  unsigned int count
- 		    = start ? paste_flag - start : tokens_buff_count (buff);
--		  const cpp_token *t
--		    = stringify_arg (pfile,
--				     start ? start + 1
--				     : (const cpp_token **) (buff->base),
--				     count, true);
-+		  const cpp_token **first
-+		    = start ? start + 1
-+			    : (const cpp_token **) (buff->base);
-+		  unsigned int i, j;
-+
-+		  /* Paste any tokens that need to be pasted before calling
-+		     stringify_arg, because stringify_arg uses pfile->u_buff
-+		     which paste_tokens can use as well.  */
-+		  for (i = 0, j = 0; i < count; i++, j++)
-+		    {
-+		      const cpp_token *token = first[i];
-+
-+		      if (token->flags & PASTE_LEFT)
-+			{
-+			  location_t virt_loc = pfile->invocation_location;
-+			  const cpp_token *rhs;
-+			  do
-+			    {
-+			      if (i == count)
-+				abort ();
-+			      rhs = first[++i];
-+			      if (!paste_tokens (pfile, virt_loc, &token, rhs))
-+				{
-+				  --i;
-+				  break;
-+				}
-+			    }
-+			  while (rhs->flags & PASTE_LEFT);
-+			}
-+
-+		      first[j] = token;
-+		    }
-+		  if (j != i)
-+		    {
-+		      while (i-- != j)
-+			tokens_buff_remove_last_token (buff);
-+		      count = j;
-+		    }
-+
-+		  const cpp_token *t = stringify_arg (pfile, first, count);
- 		  while (count--)
- 		    tokens_buff_remove_last_token (buff);
- 		  if (src->flags & PASTE_LEFT)
---- gcc/testsuite/c-c++-common/cpp/va-opt-8.c.jj
-+++ gcc/testsuite/c-c++-common/cpp/va-opt-8.c
-@@ -0,0 +1,18 @@
-+/* PR preprocessor/103415 */
-+/* { dg-do run } */
-+/* { dg-options "-std=gnu99" { target c } } */
-+/* { dg-options "-std=c++20" { target c++ } } */
-+
-+#define n(x, ...) = #__VA_OPT__(x##3)
-+#define o(x, ...) #__VA_OPT__(x##__VA_ARGS__##9)
-+const char *c n(1 2, 4);
-+const char *d = o(5  6, 7	8);
-+
-+int
-+main ()
-+{
-+  if (__builtin_strcmp (c, "1 23")
-+      || __builtin_strcmp (d, "5 67 89"))
-+    __builtin_abort ();
-+  return 0;
-+}
---- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-38.c.jj
-+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-38.c
-@@ -0,0 +1,24 @@
-+/* { dg-do compile } */
-+/* { dg-options "-Wimplicit-fallthrough=3" } */
-+
-+#define FOO \
-+int				\
-+foo (int a)			\
-+{				\
-+  switch (a)			\
-+    {				\
-+    case 1:			\
-+      ++a;			\
-+      /* FALLTHRU */		\
-+    case 2:			\
-+      ++a;			\
-+      /* FALLTHRU */		\
-+    ca##se 3:			\
-+      ++a;			\
-+    default:			\
-+      break;			\
-+    }				\
-+  return a;			\
-+}
-+
-+FOO

diff --git a/gcc11-stringify-__VA_OPT__.patch b/gcc11-stringify-__VA_OPT__.patch
deleted file mode 100644
index 3a2a71f..0000000
--- a/gcc11-stringify-__VA_OPT__.patch
+++ /dev/null
@@ -1,308 +0,0 @@
-c++: Add C++20 #__VA_OPT__ support
-
-The following patch implements C++20 # __VA_OPT__ (...) support.
-Testcases cover what I came up with myself and what LLVM has for #__VA_OPT__
-in its testsuite and the string literals are identical between the two
-compilers on the va-opt-5.c testcase.
-
-2021-08-17  Jakub Jelinek  <jakub@redhat.com>
-
-libcpp/
-	* macro.c (vaopt_state): Add m_stringify member.
-	(vaopt_state::vaopt_state): Initialize it.
-	(vaopt_state::update): Overwrite it.
-	(vaopt_state::stringify): New method.
-	(stringify_arg): Replace arg argument with first, count arguments
-	and add va_opt argument.  Use first instead of arg->first and
-	count instead of arg->count, for va_opt add paste_tokens handling.
-	(paste_tokens): Fix up len calculation.  Don't spell rhs twice,
-	instead use %.*s to supply lhs and rhs spelling lengths.  Don't call
-	_cpp_backup_tokens here.
-	(paste_all_tokens): Call it here instead.
-	(replace_args): Adjust stringify_arg caller.  For vaopt_state::END
-	if stringify is true handle __VA_OPT__ stringification.
-	(create_iso_definition): Handle # __VA_OPT__ similarly to # macro_arg.
-gcc/testsuite/
-	* c-c++-common/cpp/va-opt-5.c: New test.
-	* c-c++-common/cpp/va-opt-6.c: New test.
-
---- libcpp/macro.c
-+++ libcpp/macro.c
-@@ -118,6 +118,7 @@ class vaopt_state {
-     m_arg (arg),
-     m_variadic (is_variadic),
-     m_last_was_paste (false),
-+    m_stringify (false),
-     m_state (0),
-     m_paste_location (0),
-     m_location (0),
-@@ -145,6 +146,7 @@ class vaopt_state {
- 	  }
- 	++m_state;
- 	m_location = token->src_loc;
-+	m_stringify = (token->flags & STRINGIFY_ARG) != 0;
- 	return BEGIN;
-       }
-     else if (m_state == 1)
-@@ -234,6 +236,12 @@ class vaopt_state {
-     return m_state == 0;
-   }
- 
-+  /* Return true for # __VA_OPT__.  */
-+  bool stringify () const
-+  {
-+    return m_stringify;
-+  }
-+
-  private:
- 
-   /* The cpp_reader.  */
-@@ -247,6 +255,8 @@ class vaopt_state {
-   /* If true, the previous token was ##.  This is used to detect when
-      a paste occurs at the end of the sequence.  */
-   bool m_last_was_paste;
-+  /* True for #__VA_OPT__.  */
-+  bool m_stringify;
- 
-   /* The state variable:
-      0 means not parsing
-@@ -284,7 +294,8 @@ static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *,
- static cpp_context *next_context (cpp_reader *);
- static const cpp_token *padding_token (cpp_reader *, const cpp_token *);
- static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
--static const cpp_token *stringify_arg (cpp_reader *, macro_arg *);
-+static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **,
-+				       unsigned int, bool);
- static void paste_all_tokens (cpp_reader *, const cpp_token *);
- static bool paste_tokens (cpp_reader *, location_t,
- 			  const cpp_token **, const cpp_token *);
-@@ -818,10 +829,11 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
-   return dest;
- }
- 
--/* Convert a token sequence ARG to a single string token according to
--   the rules of the ISO C #-operator.  */
-+/* Convert a token sequence FIRST to FIRST+COUNT-1 to a single string token
-+   according to the rules of the ISO C #-operator.  */
- static const cpp_token *
--stringify_arg (cpp_reader *pfile, macro_arg *arg)
-+stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
-+	       bool va_opt)
- {
-   unsigned char *dest;
-   unsigned int i, escape_it, backslash_count = 0;
-@@ -834,9 +846,27 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg)
-   *dest++ = '"';
- 
-   /* Loop, reading in the argument's tokens.  */
--  for (i = 0; i < arg->count; i++)
-+  for (i = 0; i < count; i++)
-     {
--      const cpp_token *token = arg->first[i];
-+      const cpp_token *token = first[i];
-+
-+      if (va_opt && (token->flags & PASTE_LEFT))
-+	{
-+	  location_t virt_loc = pfile->invocation_location;
-+	  const cpp_token *rhs;
-+	  do
-+	    {
-+	      if (i == count)
-+		abort ();
-+	      rhs = first[++i];
-+	      if (!paste_tokens (pfile, virt_loc, &token, rhs))
-+		{
-+		  --i;
-+		  break;
-+		}
-+	    }
-+	  while (rhs->flags & PASTE_LEFT);
-+	}
- 
-       if (token->type == CPP_PADDING)
- 	{
-@@ -923,7 +953,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
-   cpp_token *lhs;
-   unsigned int len;
- 
--  len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 1;
-+  len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 2;
-   buf = (unsigned char *) alloca (len);
-   end = lhsend = cpp_spell_token (pfile, *plhs, buf, true);
- 
-@@ -949,8 +979,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
-       location_t saved_loc = lhs->src_loc;
- 
-       _cpp_pop_buffer (pfile);
--      _cpp_backup_tokens (pfile, 1);
--      *lhsend = '\0';
-+
-+      unsigned char *rhsstart = lhsend;
-+      if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ)
-+	rhsstart++;
- 
-       /* We have to remove the PASTE_LEFT flag from the old lhs, but
- 	 we want to keep the new location.  */
-@@ -962,8 +994,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
-       /* Mandatory error for all apart from assembler.  */
-       if (CPP_OPTION (pfile, lang) != CLK_ASM)
- 	cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
--	 "pasting \"%s\" and \"%s\" does not give a valid preprocessing token",
--		   buf, cpp_token_as_text (pfile, rhs));
-+			     "pasting \"%.*s\" and \"%.*s\" does not give "
-+			     "a valid preprocessing token",
-+			     (int) (lhsend - buf), buf,
-+			     (int) (end - rhsstart), rhsstart);
-       return false;
-     }
- 
-@@ -1039,7 +1073,10 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs)
- 	    abort ();
- 	}
-       if (!paste_tokens (pfile, virt_loc, &lhs, rhs))
--	break;
-+	{
-+	  _cpp_backup_tokens (pfile, 1);
-+	  break;
-+	}
-     }
-   while (rhs->flags & PASTE_LEFT);
- 
-@@ -1906,7 +1943,8 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
- 	if (src->flags & STRINGIFY_ARG)
- 	  {
- 	    if (!arg->stringified)
--	      arg->stringified = stringify_arg (pfile, arg);
-+	      arg->stringified = stringify_arg (pfile, arg->first, arg->count,
-+						false);
- 	  }
- 	else if ((src->flags & PASTE_LEFT)
- 		 || (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT)))
-@@ -2029,7 +2067,24 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
- 		  paste_flag = tokens_buff_last_token_ptr (buff);
- 		}
- 
--	      if (src->flags & PASTE_LEFT)
-+	      if (vaopt_tracker.stringify ())
-+		{
-+		  unsigned int count
-+		    = start ? paste_flag - start : tokens_buff_count (buff);
-+		  const cpp_token *t
-+		    = stringify_arg (pfile,
-+				     start ? start + 1
-+				     : (const cpp_token **) (buff->base),
-+				     count, true);
-+		  while (count--)
-+		    tokens_buff_remove_last_token (buff);
-+		  if (src->flags & PASTE_LEFT)
-+		    copy_paste_flag (pfile, &t, src);
-+		  tokens_buff_add_token (buff, virt_locs,
-+					 t, t->src_loc, t->src_loc,
-+					 NULL, 0);
-+		}
-+	      else if (src->flags & PASTE_LEFT)
- 		{
- 		  /* With a non-empty __VA_OPT__ on the LHS of ##, the last
- 		     token should be flagged PASTE_LEFT.  */
-@@ -3585,7 +3640,10 @@ create_iso_definition (cpp_reader *pfile)
- 	 function-like macros when lexing the subsequent token.  */
-       if (macro->count > 1 && token[-1].type == CPP_HASH && macro->fun_like)
- 	{
--	  if (token->type == CPP_MACRO_ARG)
-+	  if (token->type == CPP_MACRO_ARG
-+	      || (macro->variadic
-+		  && token->type == CPP_NAME
-+		  && token->val.node.node == pfile->spec_nodes.n__VA_OPT__))
- 	    {
- 	      if (token->flags & PREV_WHITE)
- 		token->flags |= SP_PREV_WHITE;
---- gcc/testsuite/c-c++-common/cpp/va-opt-5.c
-+++ gcc/testsuite/c-c++-common/cpp/va-opt-5.c
-@@ -0,0 +1,67 @@
-+/* { dg-do run } */
-+/* { dg-options "-std=gnu99" { target c } } */
-+/* { dg-options "-std=c++20" { target c++ } } */
-+
-+#define lparen (
-+#define a0 fooa0
-+#define a1  fooa1 a0
-+#define a2  fooa2 a1
-+#define a3  fooa3 a2
-+#define a() b lparen )
-+#define b() c lparen )
-+#define c() d lparen )
-+#define g h
-+#define i(j) j
-+#define f(...) #__VA_OPT__(g i(0))
-+#define k(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__)
-+#define l(x,...) #__VA_OPT__(a1 x)
-+#define m(x,...) "a()" #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) "a()"
-+#define n(x,...) = #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) #x #__VA_OPT__(a0 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a0) ;
-+#define o(x, ...) #__VA_OPT__(x##x x##x)
-+#define p(x, ...) #__VA_OPT__(_Pragma ("foobar"))
-+#define q(...) #__VA_OPT__(/* foo */x/* bar */)
-+const char *v1 = f();
-+const char *v2 = f(123);
-+const char *v3 = k(1);
-+const char *v4 = k(1, 2, 3 );
-+const char *v5 = l(a());
-+const char *v6 = l(a1 a(), 1);
-+const char *v7 = m();
-+const char *v8 = m(,);
-+const char *v9 = m(,a3);
-+const char *v10 = m(a3,a(),a0);
-+const char *v11 n()
-+const char *v12 n(,)
-+const char *v13 n(,a0)
-+const char *v14 n(a0, a(),a0)
-+const char *v15 = o(, 0);
-+const char *v16 = p(0);
-+const char *v17 = p(0, 1);
-+const char *v18 = q();
-+const char *v19 = q(1);
-+
-+int
-+main ()
-+{
-+  if (__builtin_strcmp (v1, "")
-+      || __builtin_strcmp (v2, "g i(0)")
-+      || __builtin_strcmp (v3, "1")
-+      || __builtin_strcmp (v4, "112, 3")
-+      || __builtin_strcmp (v5, "")
-+      || __builtin_strcmp (v6, "a1 fooa1 fooa0 b ( )")
-+      || __builtin_strcmp (v7, "a()a()")
-+      || __builtin_strcmp (v8, "a()a()")
-+      || __builtin_strcmp (v9, "a()a3 fooa3 fooa2 fooa1 fooa0 a3c a3a()")
-+      || __builtin_strcmp (v10, "a()a3 b ( ),fooa0 a3a(),a0a3c a3a()")
-+      || __builtin_strcmp (v11, "")
-+      || __builtin_strcmp (v12, "")
-+      || __builtin_strcmp (v13, "a3 fooa0 a0c a3a0 fooa0 a0c a0")
-+      || __builtin_strcmp (v14, "a3 b ( ),fooa0 a0a(),a0a0c a3a0a0 b ( ),fooa0 a0a(),a0a0c a0")
-+      || __builtin_strcmp (v15, "")
-+      || __builtin_strcmp (v16, "")
-+      || __builtin_strcmp (v17, "_Pragma (\"foobar\")")
-+      || __builtin_strcmp (v18, "")
-+      || __builtin_strcmp (v19, "x"))
-+    __builtin_abort ();
-+  return 0;
-+}
---- gcc/testsuite/c-c++-common/cpp/va-opt-6.c
-+++ gcc/testsuite/c-c++-common/cpp/va-opt-6.c
-@@ -0,0 +1,17 @@
-+/* { dg-do preprocess } */
-+/* { dg-options "-std=gnu99" { target c } } */
-+/* { dg-options "-std=c++20" { target c++ } } */
-+
-+#define a ""
-+#define b(...) a ## #__VA_OPT__(1)	/* { dg-error "pasting \"a\" and \"\"\"\" does not give a valid preprocessing token" } */
-+#define c(...) a ## #__VA_OPT__(1)	/* { dg-error "pasting \"a\" and \"\"1\"\" does not give a valid preprocessing token" } */
-+#define d(...) #__VA_OPT__(1) ## !
-+#define e(...) #__VA_OPT__(1) ## !
-+#define f(...) #__VA_OPT__(. ## !)
-+#define g(...) #__VA_OPT__(. ## !)
-+b()
-+c(1)
-+d(   )		/* { dg-error "pasting \"\"\"\" and \"!\" does not give a valid preprocessing token" } */
-+e(  1 )		/* { dg-error "pasting \"\"1\"\" and \"!\" does not give a valid preprocessing token" } */
-+f()
-+g(0)		/* { dg-error "pasting \".\" and \"!\" does not give a valid preprocessing token" } */

diff --git a/gcc12-Wno-format-security.patch b/gcc12-Wno-format-security.patch
new file mode 100644
index 0000000..3abf63b
--- /dev/null
+++ b/gcc12-Wno-format-security.patch
@@ -0,0 +1,58 @@
+2022-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+	* Makefile.tpl (GOCFLAGS, GDCFLAGS): Filter out -Wformat-security.
+	* Makefile.in: Regenerated.
+
+2017-02-25  Jakub Jelinek  <jakub@redhat.com>
+
+	* configure.ac: When adding -Wno-format, also add -Wno-format-security.
+	* configure: Regenerated.
+
+--- gcc/configure.ac.jj	2017-02-13 12:20:53.000000000 +0100
++++ gcc/configure.ac	2017-02-25 12:42:32.859175403 +0100
+@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
+   AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
+   [],[enable_build_format_warnings=yes])
+ AS_IF([test $enable_build_format_warnings = no],
+-      [wf_opt=-Wno-format],[wf_opt=])
++      [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
+ ACX_PROG_CXX_WARNING_OPTS(
+ 	m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
+ 		       [-Wcast-qual -Wno-error=format-diag $wf_opt])),
+--- gcc/configure.jj	2017-02-13 12:20:52.000000000 +0100
++++ gcc/configure	2017-02-25 12:42:50.041946391 +0100
+@@ -6647,7 +6647,7 @@ else
+ fi
+ 
+ if test $enable_build_format_warnings = no; then :
+-  wf_opt=-Wno-format
++  wf_opt="-Wno-format -Wno-format-security"
+ else
+   wf_opt=
+ fi
+--- Makefile.tpl.jj	2021-12-30 15:12:42.188164847 +0100
++++ Makefile.tpl	2022-01-07 12:06:12.115550714 +0100
+@@ -447,8 +447,8 @@ LDFLAGS = @LDFLAGS@
+ LIBCFLAGS = $(CFLAGS)
+ CXXFLAGS = @CXXFLAGS@
+ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
+-GOCFLAGS = $(CFLAGS)
+-GDCFLAGS = $(CFLAGS)
++GOCFLAGS = $(filter-out -Wformat-security,$(CFLAGS))
++GDCFLAGS = $(filter-out -Wformat-security,$(CFLAGS))
+ 
+ # Pass additional PGO and LTO compiler options to the PGO build.
+ BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
+--- Makefile.in.jj	2021-12-30 15:12:42.188164847 +0100
++++ Makefile.in	2022-01-07 12:06:27.335334561 +0100
+@@ -444,8 +444,8 @@ LDFLAGS = @LDFLAGS@
+ LIBCFLAGS = $(CFLAGS)
+ CXXFLAGS = @CXXFLAGS@
+ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
+-GOCFLAGS = $(CFLAGS)
+-GDCFLAGS = $(CFLAGS)
++GOCFLAGS = $(filter-out -Wformat-security,$(CFLAGS))
++GDCFLAGS = $(filter-out -Wformat-security,$(CFLAGS))
+ 
+ # Pass additional PGO and LTO compiler options to the PGO build.
+ BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)

diff --git a/gcc12-d-shared-libphobos.patch b/gcc12-d-shared-libphobos.patch
new file mode 100644
index 0000000..6384bbb
--- /dev/null
+++ b/gcc12-d-shared-libphobos.patch
@@ -0,0 +1,20 @@
+2019-01-17  Jakub Jelinek  <jakub@redhat.com>
+
+	* d-spec.cc (lang_specific_driver): Make -shared-libphobos
+	the default rather than -static-libphobos.
+
+--- gcc/d/d-spec.cc.jj	2019-01-01 12:37:49.502444257 +0100
++++ gcc/d/d-spec.cc	2019-01-17 17:09:45.364949246 +0100
+@@ -408,9 +408,9 @@ lang_specific_driver (cl_decoded_option
+   /* Add `-lgphobos' if we haven't already done so.  */
+   if (phobos_library != PHOBOS_NOLINK)
+     {
+-      /* Default to static linking.  */
+-      if (phobos_library != PHOBOS_DYNAMIC)
+-	phobos_library = PHOBOS_STATIC;
++      /* Default to shared linking.  */
++      if (phobos_library != PHOBOS_STATIC)
++	phobos_library = PHOBOS_DYNAMIC;
+ 
+ #ifdef HAVE_LD_STATIC_DYNAMIC
+       if (phobos_library == PHOBOS_STATIC && !static_link)

diff --git a/gcc12-fortran-fdec-add-missing-indexes.patch b/gcc12-fortran-fdec-add-missing-indexes.patch
new file mode 100644
index 0000000..d707b94
--- /dev/null
+++ b/gcc12-fortran-fdec-add-missing-indexes.patch
@@ -0,0 +1,181 @@
+From 7001d522d0273658d9e1fb12ca104d56bfcae34d Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 15:06:08 +0000
+Subject: [PATCH 10/10] Fill in missing array dimensions using the lower bound
+
+Use -fdec-add-missing-indexes to enable feature. Also enabled by fdec.
+---
+ gcc/fortran/lang.opt                  |  8 ++++++++
+ gcc/fortran/options.c                 |  1 +
+ gcc/fortran/resolve.c                 | 24 ++++++++++++++++++++++++
+ gcc/testsuite/gfortran.dg/array_6.f90 | 23 +++++++++++++++++++++++
+ gcc/testsuite/gfortran.dg/array_7.f90 | 23 +++++++++++++++++++++++
+ gcc/testsuite/gfortran.dg/array_8.f90 | 23 +++++++++++++++++++++++
+ 6 files changed, 102 insertions(+)
+ create mode 100644 gcc/testsuite/gfortran.dg/array_6.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/array_7.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/array_8.f90
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 019c798cf09..f27de88ea3f 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -281,6 +281,10 @@ Wmissing-include-dirs
+ Fortran
+ ; Documented in C/C++
+ 
++Wmissing-index
++Fortran Var(warn_missing_index) Warning LangEnabledBy(Fortran,Wall)
++Warn that the lower bound of a missing index will be used.
++
+ Wuse-without-only
+ Fortran Var(warn_use_without_only) Warning
+ Warn about USE statements that have no ONLY qualifier.
+@@ -460,6 +464,10 @@ fdec
+ Fortran Var(flag_dec)
+ Enable all DEC language extensions.
+ 
++fdec-add-missing-indexes
++Fortran Var(flag_dec_add_missing_indexes)
++Enable the addition of missing indexes using their lower bounds.
++
+ fdec-blank-format-item
+ Fortran Var(flag_dec_blank_format_item)
+ Enable the use of blank format items in format strings.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index 050f56fdc25..c3b2822685d 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -84,6 +84,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_non_logical_if, value, value);
+   SET_BITFLAG (flag_dec_promotion, value, value);
+   SET_BITFLAG (flag_dec_sequence, value, value);
++  SET_BITFLAG (flag_dec_add_missing_indexes, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
+index fe7d0cc5944..0efeedab46e 100644
+--- a/gcc/fortran/resolve.c
++++ b/gcc/fortran/resolve.c
+@@ -4806,6 +4806,30 @@ compare_spec_to_ref (gfc_array_ref *ar)
+   if (ar->type == AR_FULL)
+     return true;
+ 
++  if (flag_dec_add_missing_indexes && as->rank > ar->dimen)
++    {
++      /* Add in the missing dimensions, assuming they are the lower bound
++	 of that dimension if not specified.  */
++      int j;
++      if (warn_missing_index)
++	{
++	  gfc_warning (OPT_Wmissing_index, "Using the lower bound for "
++		       "unspecified dimensions in array reference at %L",
++		       &ar->where);
++	}
++      /* Other parts of the code iterate ar->start and ar->end from 0 to
++	 ar->dimen, so it is safe to assume slots from ar->dimen upwards
++	 are unused (i.e. there are no gaps; the specified indexes are
++	 contiguous and start at zero.  */
++      for(j = ar->dimen; j <= as->rank; j++)
++	{
++	  ar->start[j] = gfc_copy_expr (as->lower[j]);
++	  ar->end[j]   = gfc_copy_expr (as->lower[j]);
++	  ar->dimen_type[j] = DIMEN_ELEMENT;
++	}
++      ar->dimen = as->rank;
++    }
++
+   if (as->rank != ar->dimen)
+     {
+       gfc_error ("Rank mismatch in array reference at %L (%d/%d)",
+diff --git a/gcc/testsuite/gfortran.dg/array_6.f90 b/gcc/testsuite/gfortran.dg/array_6.f90
+new file mode 100644
+index 00000000000..5c26e18ab3e
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/array_6.f90
+@@ -0,0 +1,23 @@
++! { dg-do run }
++! { dg-options "-fdec -Wmissing-index" }!
++! Checks that under-specified arrays (referencing arrays with fewer
++! dimensions than the array spec) generates a warning.
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
++!
++
++program under_specified_array
++    integer chessboard(8,8)
++    integer chessboard3d(8,8,3:5)
++    chessboard(3,1) = 5
++    chessboard(3,2) = 55
++    chessboard3d(4,1,3) = 6
++    chessboard3d(4,1,4) = 66
++    chessboard3d(4,4,3) = 7
++    chessboard3d(4,4,4) = 77
++  
++    if (chessboard(3).ne.5) stop 1  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++    if (chessboard3d(4).ne.6) stop 2  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++end program
+diff --git a/gcc/testsuite/gfortran.dg/array_7.f90 b/gcc/testsuite/gfortran.dg/array_7.f90
+new file mode 100644
+index 00000000000..5588a5bd02d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/array_7.f90
+@@ -0,0 +1,23 @@
++! { dg-do run }
++! { dg-options "-fdec-add-missing-indexes -Wmissing-index" }!
++! Checks that under-specified arrays (referencing arrays with fewer
++! dimensions than the array spec) generates a warning.
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
++!
++
++program under_specified_array
++    integer chessboard(8,8)
++    integer chessboard3d(8,8,3:5)
++    chessboard(3,1) = 5
++    chessboard(3,2) = 55
++    chessboard3d(4,1,3) = 6
++    chessboard3d(4,1,4) = 66
++    chessboard3d(4,4,3) = 7
++    chessboard3d(4,4,4) = 77
++  
++    if (chessboard(3).ne.5) stop 1  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++    if (chessboard3d(4).ne.6) stop 2  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-warning "Using the lower bound for unspecified dimensions in array reference" }
++end program
+diff --git a/gcc/testsuite/gfortran.dg/array_8.f90 b/gcc/testsuite/gfortran.dg/array_8.f90
+new file mode 100644
+index 00000000000..f0d2ef5e37d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/array_8.f90
+@@ -0,0 +1,23 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-add-missing-indexes" }!
++! Checks that under-specified arrays (referencing arrays with fewer
++! dimensions than the array spec) generates a warning.
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Updated by Mark Eggleston <mark.eggleston@codethink.co.uk>
++!
++
++program under_specified_array
++    integer chessboard(8,8)
++    integer chessboard3d(8,8,3:5)
++    chessboard(3,1) = 5
++    chessboard(3,2) = 55
++    chessboard3d(4,1,3) = 6
++    chessboard3d(4,1,4) = 66
++    chessboard3d(4,4,3) = 7
++    chessboard3d(4,4,4) = 77
++  
++    if (chessboard(3).ne.5) stop 1  ! { dg-error "Rank mismatch" }
++    if (chessboard3d(4).ne.6) stop 2  ! { dg-error "Rank mismatch" }
++    if (chessboard3d(4,4).ne.7) stop 3  ! { dg-error "Rank mismatch" }
++end program
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-duplicates.patch b/gcc12-fortran-fdec-duplicates.patch
new file mode 100644
index 0000000..b5d1104
--- /dev/null
+++ b/gcc12-fortran-fdec-duplicates.patch
@@ -0,0 +1,215 @@
+From 23b1fcb104c666429451ffaf936f8da5fcd3d43a Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 12:29:47 +0000
+Subject: [PATCH 01/10] Allow duplicate declarations.
+
+Enabled by -fdec-duplicates and -fdec.
+
+Some fixes by Jim MacArthur <jim.macarthur@codethink.co.uk>
+Addition of -fdec-duplicates by Mark Eggleston <mark.eggleston@codethink.com>
+---
+ gcc/fortran/lang.opt                          |  4 ++++
+ gcc/fortran/options.c                         |  1 +
+ gcc/fortran/symbol.c                          | 21 +++++++++++++++++--
+ .../gfortran.dg/duplicate_type_4.f90          | 13 ++++++++++++
+ .../gfortran.dg/duplicate_type_5.f90          | 13 ++++++++++++
+ .../gfortran.dg/duplicate_type_6.f90          | 13 ++++++++++++
+ .../gfortran.dg/duplicate_type_7.f90          | 13 ++++++++++++
+ .../gfortran.dg/duplicate_type_8.f90          | 12 +++++++++++
+ .../gfortran.dg/duplicate_type_9.f90          | 12 +++++++++++
+ 9 files changed, 100 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_4.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_5.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_6.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_7.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_8.f90
+ create mode 100644 gcc/testsuite/gfortran.dg/duplicate_type_9.f90
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 2b1977c523b..52bd522051e 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -469,6 +469,10 @@ Fortran Var(flag_dec_char_conversions)
+ Enable the use of character literals in assignments and data statements
+ for non-character variables.
+ 
++fdec-duplicates
++Fortran Var(flag_dec_duplicates)
++Allow varibles to be duplicated in the type specification matches.
++
+ fdec-include
+ Fortran Var(flag_dec_include)
+ Enable legacy parsing of INCLUDE as statement.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index 3a0b98bf1ec..f19ba87f8a0 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -77,6 +77,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_format_defaults, value, value);
+   SET_BITFLAG (flag_dec_blank_format_item, value, value);
+   SET_BITFLAG (flag_dec_char_conversions, value, value);
++  SET_BITFLAG (flag_dec_duplicates, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
+index 3b988d1be22..9843175cc2a 100644
+--- a/gcc/fortran/symbol.c
++++ b/gcc/fortran/symbol.c
+@@ -1995,6 +1995,8 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
+   if (sym->attr.result && type == BT_UNKNOWN && sym->ns->proc_name)
+     type = sym->ns->proc_name->ts.type;
+ 
++  flavor = sym->attr.flavor;
++
+   if (type != BT_UNKNOWN && !(sym->attr.function && sym->attr.implicit_type)
+       && !(gfc_state_stack->previous && gfc_state_stack->previous->previous
+ 	   && gfc_state_stack->previous->previous->state == COMP_SUBMODULE)
+@@ -2007,6 +2009,23 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
+       else if (sym->attr.function && sym->attr.result)
+ 	gfc_error ("Symbol %qs at %L already has basic type of %s",
+ 		   sym->ns->proc_name->name, where, gfc_basic_typename (type));
++      else if (flag_dec_duplicates)
++	{
++	  /* Ignore temporaries and class/procedure names */
++	  if (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS
++	      || sym->ts.type == BT_PROCEDURE)
++	    return false;
++
++	  if (gfc_compare_types (&sym->ts, ts)
++	      && (flavor == FL_UNKNOWN || flavor == FL_VARIABLE
++	      || flavor == FL_PROCEDURE))
++	    {
++	      return gfc_notify_std (GFC_STD_LEGACY,
++				     "Symbol '%qs' at %L already has "
++				     "basic type of %s", sym->name, where,
++				     gfc_basic_typename (type));
++	    }
++	}
+       else
+ 	gfc_error ("Symbol %qs at %L already has basic type of %s", sym->name,
+ 		   where, gfc_basic_typename (type));
+@@ -2020,8 +2039,6 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
+       return false;
+     }
+ 
+-  flavor = sym->attr.flavor;
+-
+   if (flavor == FL_PROGRAM || flavor == FL_BLOCK_DATA || flavor == FL_MODULE
+       || flavor == FL_LABEL
+       || (flavor == FL_PROCEDURE && sym->attr.subroutine)
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_4.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
+new file mode 100644
+index 00000000000..cdd29ea8846
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_4.f90
+@@ -0,0 +1,13 @@
++! { dg-do compile }
++! { dg-options "-std=f95" }
++
++! PR fortran/30239
++! Check for errors when a symbol gets declared a type twice, even if it
++! is the same.
++
++INTEGER FUNCTION foo ()
++  IMPLICIT NONE
++  INTEGER :: x
++  INTEGER :: x ! { dg-error "basic type of" }
++  x = 42
++END FUNCTION foo
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_5.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_5.f90
+new file mode 100644
+index 00000000000..00f931809aa
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_5.f90
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++program test
++  implicit none
++  integer :: x
++  integer :: x
++  x = 42
++  if (x /= 42) stop 1
++end program test
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_6.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_6.f90
+new file mode 100644
+index 00000000000..f0df27e323c
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_6.f90
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! { dg-options "-std=legacy -fdec-duplicates" }
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++program test
++  implicit none
++  integer :: x
++  integer :: x
++  x = 42
++  if (x /= 42) stop 1
++end program test
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_7.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_7.f90
+new file mode 100644
+index 00000000000..f32472ff586
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_7.f90
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! { dg-options "-fdec-duplicates" }
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++program test
++  implicit none
++  integer :: x
++  integer :: x! { dg-warning "Legacy Extension" }
++  x = 42
++  if (x /= 42) stop 1
++end program test
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_8.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_8.f90
+new file mode 100644
+index 00000000000..23c94add179
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_8.f90
+@@ -0,0 +1,12 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-duplicates" }
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++integer function foo ()
++  implicit none
++  integer :: x
++  integer :: x ! { dg-error "basic type of" }
++  x = 42
++end function foo
+diff --git a/gcc/testsuite/gfortran.dg/duplicate_type_9.f90 b/gcc/testsuite/gfortran.dg/duplicate_type_9.f90
+new file mode 100644
+index 00000000000..d5edee4d8ee
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/duplicate_type_9.f90
+@@ -0,0 +1,12 @@
++! { dg-do compile }
++! { dg-options "-fdec-duplicates -fno-dec-duplicates" }
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++integer function foo ()
++  implicit none
++  integer :: x
++  integer :: x ! { dg-error "basic type of" }
++  x = 42
++end function foo
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-ichar.patch b/gcc12-fortran-fdec-ichar.patch
new file mode 100644
index 0000000..e7b0522
--- /dev/null
+++ b/gcc12-fortran-fdec-ichar.patch
@@ -0,0 +1,78 @@
+From f883ac209b0feea860354cb4ef7ff06dc8063fab Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 12:53:35 +0000
+Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
+
+Use -fdec to enable.
+---
+ gcc/fortran/check.c                           |  2 +-
+ gcc/fortran/simplify.c                        |  4 ++--
+ .../gfortran.dg/dec_ichar_with_string_1.f     | 21 +++++++++++++++++++
+ 3 files changed, 24 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
+
+diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
+index 82db8e4e1b2..623c1cc470e 100644
+--- a/gcc/fortran/check.c
++++ b/gcc/fortran/check.c
+@@ -3157,7 +3157,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
+   else
+     return true;
+ 
+-  if (i != 1)
++  if (i != 1 && !flag_dec)
+     {
+       gfc_error ("Argument of %s at %L must be of length one",
+ 		 gfc_current_intrinsic, &c->where);
+diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
+index 23317a2e2d9..9900572424f 100644
+--- a/gcc/fortran/simplify.c
++++ b/gcc/fortran/simplify.c
+@@ -3261,7 +3261,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
+   if (e->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+-  if (e->value.character.length != 1)
++  if (e->value.character.length != 1 && !flag_dec)
+     {
+       gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
+       return &gfc_bad_expr;
+@@ -3459,7 +3459,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
+   if (e->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+-  if (e->value.character.length != 1)
++  if (e->value.character.length != 1 && !flag_dec)
+     {
+       gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
+       return &gfc_bad_expr;
+diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
+new file mode 100644
+index 00000000000..85efccecc0f
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
+@@ -0,0 +1,21 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test ICHAR and IACHAR with more than one character as argument
++!
++! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM ichar_more_than_one_character
++          CHARACTER*4 st/'Test'/
++          INTEGER i
++
++          i = ICHAR(st)
++          if (i.NE.84) STOP 1
++          i = IACHAR(st)
++          if (i.NE.84) STOP 2
++          i = ICHAR('Test')
++          if (i.NE.84) STOP 3
++          i = IACHAR('Test')
++          if (i.NE.84) STOP 4
++        END
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-non-integer-index.patch b/gcc12-fortran-fdec-non-integer-index.patch
new file mode 100644
index 0000000..074df3b
--- /dev/null
+++ b/gcc12-fortran-fdec-non-integer-index.patch
@@ -0,0 +1,158 @@
+From 67aef262311d6a746786ee0f59748ccaa7e1e711 Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 13:09:54 +0000
+Subject: [PATCH 04/10] Allow non-integer substring indexes
+
+Use -fdec-non-integer-index compiler flag to enable. Also enabled by -fdec.
+---
+ gcc/fortran/lang.opt                          |  4 ++++
+ gcc/fortran/options.c                         |  1 +
+ gcc/fortran/resolve.c                         | 20 +++++++++++++++++++
+ .../dec_not_integer_substring_indexes_1.f     | 18 +++++++++++++++++
+ .../dec_not_integer_substring_indexes_2.f     | 18 +++++++++++++++++
+ .../dec_not_integer_substring_indexes_3.f     | 18 +++++++++++++++++
+ 6 files changed, 79 insertions(+)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index c4da248f07c..d527c106bd6 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -489,6 +489,10 @@ fdec-math
+ Fortran Var(flag_dec_math)
+ Enable legacy math intrinsics for compatibility.
+ 
++fdec-non-integer-index
++Fortran Var(flag_dec_non_integer_index)
++Enable support for non-integer substring indexes.
++
+ fdec-structure
+ Fortran Var(flag_dec_structure)
+ Enable support for DEC STRUCTURE/RECORD.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index f19ba87f8a0..9a042f64881 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -78,6 +78,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_blank_format_item, value, value);
+   SET_BITFLAG (flag_dec_char_conversions, value, value);
+   SET_BITFLAG (flag_dec_duplicates, value, value);
++  SET_BITFLAG (flag_dec_non_integer_index, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
+index 4b90cb59902..bc0df0fdb99 100644
+--- a/gcc/fortran/resolve.c
++++ b/gcc/fortran/resolve.c
+@@ -5131,6 +5131,16 @@ gfc_resolve_substring (gfc_ref *ref, bool *equal_length)
+       if (!gfc_resolve_expr (ref->u.ss.start))
+ 	return false;
+ 
++      /* In legacy mode, allow non-integer string indexes by converting */
++      if (flag_dec_non_integer_index && ref->u.ss.start->ts.type != BT_INTEGER
++	  && gfc_numeric_ts (&ref->u.ss.start->ts))
++	{
++	  gfc_typespec t;
++	  t.type = BT_INTEGER;
++	  t.kind = ref->u.ss.start->ts.kind;
++	  gfc_convert_type_warn (ref->u.ss.start, &t, 2, 1);
++	}
++
+       if (ref->u.ss.start->ts.type != BT_INTEGER)
+ 	{
+ 	  gfc_error ("Substring start index at %L must be of type INTEGER",
+@@ -5160,6 +5170,16 @@ gfc_resolve_substring (gfc_ref *ref, bool *equal_length)
+       if (!gfc_resolve_expr (ref->u.ss.end))
+ 	return false;
+ 
++      /* Non-integer string index endings, as for start */
++      if (flag_dec_non_integer_index && ref->u.ss.end->ts.type != BT_INTEGER
++	  && gfc_numeric_ts (&ref->u.ss.end->ts))
++	{
++	  gfc_typespec t;
++	  t.type = BT_INTEGER;
++	  t.kind = ref->u.ss.end->ts.kind;
++	  gfc_convert_type_warn (ref->u.ss.end, &t, 2, 1);
++	}
++
+       if (ref->u.ss.end->ts.type != BT_INTEGER)
+ 	{
+ 	  gfc_error ("Substring end index at %L must be of type INTEGER",
+diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
+new file mode 100644
+index 00000000000..0be28abaa4b
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_1.f
+@@ -0,0 +1,18 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test not integer substring indexes
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM not_integer_substring_indexes
++          CHARACTER*5 st/'Tests'/
++          REAL ir/1.0/
++          REAL ir2/4.0/
++
++          if (st(ir:4).ne.'Test') stop 1
++          if (st(1:ir2).ne.'Test') stop 2
++          if (st(1.0:4).ne.'Test') stop 3
++          if (st(1:4.0).ne.'Test') stop 4
++          if (st(2.5:4).ne.'est') stop 5
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
+new file mode 100644
+index 00000000000..3cf05296d0c
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_2.f
+@@ -0,0 +1,18 @@
++! { dg-do run }
++! { dg-options "-fdec-non-integer-index" }
++!
++! Test not integer substring indexes
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM not_integer_substring_indexes
++          CHARACTER*5 st/'Tests'/
++          REAL ir/1.0/
++          REAL ir2/4.0/
++
++          if (st(ir:4).ne.'Test') stop 1
++          if (st(1:ir2).ne.'Test') stop 2
++          if (st(1.0:4).ne.'Test') stop 3
++          if (st(1:4.0).ne.'Test') stop 4
++          if (st(2.5:4).ne.'est') stop 5
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
+new file mode 100644
+index 00000000000..703de995897
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_not_integer_substring_indexes_3.f
+@@ -0,0 +1,18 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-non-integer-index" }
++!
++! Test not integer substring indexes
++!
++! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM not_integer_substring_indexes
++          CHARACTER*5 st/'Tests'/
++          REAL ir/1.0/
++          REAL ir2/4.0/
++
++          if (st(ir:4).ne.'Test') stop 1 ! { dg-error "Substring start index" }
++          if (st(1:ir2).ne.'Test') stop 2 ! { dg-error "Substring end index" }
++          if (st(1.0:4).ne.'Test') stop 3 ! { dg-error "Substring start index" }
++          if (st(1:4.0).ne.'Test') stop 4 ! { dg-error "Substring end index" }
++          if (st(2.5:4).ne.'est') stop 5 ! { dg-error "Substring start index" }
++        END
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-non-logical-if.patch b/gcc12-fortran-fdec-non-logical-if.patch
new file mode 100644
index 0000000..0133d23
--- /dev/null
+++ b/gcc12-fortran-fdec-non-logical-if.patch
@@ -0,0 +1,378 @@
+From cc87ddb841017bb0976b05091733609ee17d7f05 Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 13:15:17 +0000
+Subject: [PATCH 07/10] Allow non-logical expressions in IF statements
+
+Use -fdec-non-logical-if to enable feature. Also enabled using -fdec.
+---
+ gcc/fortran/lang.opt                          |  4 ++
+ gcc/fortran/options.c                         |  1 +
+ gcc/fortran/resolve.c                         | 60 ++++++++++++++++---
+ ...gical_expressions_if_statements_blocks_1.f | 25 ++++++++
+ ...gical_expressions_if_statements_blocks_2.f | 25 ++++++++
+ ...gical_expressions_if_statements_blocks_3.f | 25 ++++++++
+ ...gical_expressions_if_statements_blocks_4.f | 45 ++++++++++++++
+ ...gical_expressions_if_statements_blocks_5.f | 45 ++++++++++++++
+ ...gical_expressions_if_statements_blocks_6.f | 45 ++++++++++++++
+ 9 files changed, 266 insertions(+), 9 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 4a269ebb22d..d886c2f33ed 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -497,6 +497,10 @@ fdec-override-kind
+ Fortran Var(flag_dec_override_kind)
+ Enable support for per variable kind specification.
+ 
++fdec-non-logical-if
++Fortran Var(flag_dec_non_logical_if)
++Enable support for non-logical expressions in if statements.
++
+ fdec-old-init
+ Fortran Var(flag_dec_old_init)
+ Enable support for old style initializers in derived types.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index edbab483b36..a946c86790a 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -81,6 +81,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_non_integer_index, value, value);
+   SET_BITFLAG (flag_dec_old_init, value, value);
+   SET_BITFLAG (flag_dec_override_kind, value, value);
++  SET_BITFLAG (flag_dec_non_logical_if, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
+index bc0df0fdb99..07dd039f3bf 100644
+--- a/gcc/fortran/resolve.c
++++ b/gcc/fortran/resolve.c
+@@ -10789,10 +10789,31 @@ gfc_resolve_blocks (gfc_code *b, gfc_namespace *ns)
+       switch (b->op)
+ 	{
+ 	case EXEC_IF:
+-	  if (t && b->expr1 != NULL
+-	      && (b->expr1->ts.type != BT_LOGICAL || b->expr1->rank != 0))
+-	    gfc_error ("IF clause at %L requires a scalar LOGICAL expression",
+-		       &b->expr1->where);
++	  if (t && b->expr1 != NULL)
++	    {
++	      if (flag_dec_non_logical_if && b->expr1->ts.type != BT_LOGICAL)
++		{
++		  gfc_expr* cast;
++		  cast = gfc_ne (b->expr1,
++				 gfc_get_int_expr (1, &gfc_current_locus, 0),
++				 INTRINSIC_NE);
++		  if (cast == NULL)
++		    gfc_internal_error ("gfc_resolve_blocks(): Failed to cast "
++					"to LOGICAL in IF");
++		  b->expr1 = cast;
++		  if (warn_conversion_extra)
++		    {
++		      gfc_warning (OPT_Wconversion_extra, "Non-LOGICAL type in"
++				   " IF statement condition %L will be true if"
++				   " it evaluates to nonzero",
++				   &b->expr1->where);
++		    }
++		}
++
++	      if ((b->expr1->ts.type != BT_LOGICAL || b->expr1->rank != 0))
++		gfc_error ("IF clause at %L requires a scalar LOGICAL "
++			   "expression", &b->expr1->where);
++	    }
+ 	  break;
+ 
+ 	case EXEC_WHERE:
+@@ -12093,11 +12114,32 @@ start:
+ 	  break;
+ 
+ 	case EXEC_IF:
+-	  if (t && code->expr1 != NULL
+-	      && (code->expr1->ts.type != BT_LOGICAL
+-		  || code->expr1->rank != 0))
+-	    gfc_error ("IF clause at %L requires a scalar LOGICAL expression",
+-		       &code->expr1->where);
++	  if (t && code->expr1 != NULL)
++	    {
++	      if (flag_dec_non_logical_if
++		  && code->expr1->ts.type != BT_LOGICAL)
++		{
++		  gfc_expr* cast;
++		  cast = gfc_ne (code->expr1,
++				 gfc_get_int_expr (1, &gfc_current_locus, 0),
++				 INTRINSIC_NE);
++		  if (cast == NULL)
++		    gfc_internal_error ("gfc_resolve_code(): Failed to cast "
++					"to LOGICAL in IF");
++		  code->expr1 = cast;
++		  if (warn_conversion_extra)
++		    {
++		      gfc_warning (OPT_Wconversion_extra, "Non-LOGICAL type in"
++				   " IF statement condition %L will be true if"
++				   " it evaluates to nonzero",
++				   &code->expr1->where);
++		    }
++		}
++
++	      if (code->expr1->ts.type != BT_LOGICAL || code->expr1->rank != 0)
++		gfc_error ("IF clause at %L requires a scalar LOGICAL "
++			   "expression", &code->expr1->where);
++	    }
+ 	  break;
+ 
+ 	case EXEC_CALL:
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
+new file mode 100644
+index 00000000000..0101db893ca
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_1.f
+@@ -0,0 +1,25 @@
++! { dg-do run }
++! { dg-options "-fdec -Wconversion-extra" }
++!
++! Allow logical expressions in if statements and blocks
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM logical_exp_if_st_bl
++          INTEGER ipos/1/
++          INTEGER ineg/0/
++
++          ! Test non logical variables
++          if (ineg) STOP 1 ! { dg-warning "if it evaluates to nonzero" }
++          if (0) STOP 2 ! { dg-warning "if it evaluates to nonzero" }
++
++          ! Test non logical expressions in if statements
++          if (MOD(ipos, 1)) STOP 3 ! { dg-warning "if it evaluates to nonzero" }
++
++          ! Test non logical expressions in if blocks
++          if (MOD(2 * ipos, 2)) then ! { dg-warning "if it evaluates to nonzero" }
++            STOP 4
++          endif
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
+new file mode 100644
+index 00000000000..876f4e09508
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_2.f
+@@ -0,0 +1,25 @@
++! { dg-do run }
++! { dg-options "-fdec-non-logical-if -Wconversion-extra" }
++!
++! Allow logical expressions in if statements and blocks
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM logical_exp_if_st_bl
++          INTEGER ipos/1/
++          INTEGER ineg/0/
++
++          ! Test non logical variables
++          if (ineg) STOP 1 ! { dg-warning "if it evaluates to nonzero" }
++          if (0) STOP 2 ! { dg-warning "if it evaluates to nonzero" }
++
++          ! Test non logical expressions in if statements
++          if (MOD(ipos, 1)) STOP 3 ! { dg-warning "if it evaluates to nonzero" }
++
++          ! Test non logical expressions in if blocks
++          if (MOD(2 * ipos, 2)) then ! { dg-warning "if it evaluates to nonzero" }
++            STOP 4
++          endif
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
+new file mode 100644
+index 00000000000..35cb4c51b8d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_3.f
+@@ -0,0 +1,25 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-non-logical-if" }
++!
++! Allow logical expressions in if statements and blocks
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM logical_exp_if_st_bl
++          INTEGER ipos/1/
++          INTEGER ineg/0/
++
++          ! Test non logical variables
++          if (ineg) STOP 1 ! { dg-error "IF clause at" }
++          if (0) STOP 2 ! { dg-error "IF clause at" }
++
++          ! Test non logical expressions in if statements
++          if (MOD(ipos, 1)) STOP 3 ! { dg-error "IF clause at" }
++
++          ! Test non logical expressions in if blocks
++          if (MOD(2 * ipos, 2)) then ! { dg-error "IF clause at" }
++            STOP 4
++          endif
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
+new file mode 100644
+index 00000000000..7b60b60827f
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_4.f
+@@ -0,0 +1,45 @@
++! { dg-do run }
++! { dg-options "-fdec -Wconversion-extra" }
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++       function othersub1()
++        integer*4 othersub1
++        othersub1 = 9
++       end
++
++       function othersub2()
++        integer*4 othersub2
++        othersub2 = 0
++       end
++
++       program MAIN
++        integer*4 othersub1
++        integer*4 othersub2
++        integer a /1/
++        integer b /2/        
++ 
++        if (othersub1()) then ! { dg-warning "if it evaluates to nonzero" }
++           write(*,*) "OK"
++        else
++           stop 1
++        end if
++        if (othersub2()) then ! { dg-warning "if it evaluates to nonzero" }
++           stop 2
++        else
++           write(*,*) "OK"
++        end if
++        if (a-b) then ! { dg-warning "if it evaluates to nonzero" }
++           write(*,*) "OK"
++        else
++           stop 3
++        end if
++        if (b-(a+1)) then ! { dg-warning "if it evaluates to nonzero" }
++           stop 3
++        else
++           write(*,*) "OK"
++        end if
++       end
++
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
+new file mode 100644
+index 00000000000..80336f48ca1
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_5.f
+@@ -0,0 +1,45 @@
++! { dg-do run }
++! { dg-options "-fdec-non-logical-if -Wconversion-extra" }
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++       function othersub1()
++        integer*4 othersub1
++        othersub1 = 9
++       end
++
++       function othersub2()
++        integer*4 othersub2
++        othersub2 = 0
++       end
++
++       program MAIN
++        integer*4 othersub1
++        integer*4 othersub2
++        integer a /1/
++        integer b /2/        
++ 
++        if (othersub1()) then ! { dg-warning "Non-LOGICAL type in IF statement" }
++           write(*,*) "OK"
++        else
++           stop 1
++        end if
++        if (othersub2()) then ! { dg-warning "Non-LOGICAL type in IF statement" }
++           stop 2
++        else
++           write(*,*) "OK"
++        end if
++        if (a-b) then ! { dg-warning "Non-LOGICAL type in IF statement" }
++           write(*,*) "OK"
++        else
++           stop 3
++        end if
++        if (b-(a+1)) then ! { dg-warning "Non-LOGICAL type in IF statement" }
++           stop 3
++        else
++           write(*,*) "OK"
++        end if
++       end
++
+diff --git a/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
+new file mode 100644
+index 00000000000..e1125ca717a
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_logical_expressions_if_statements_blocks_6.f
+@@ -0,0 +1,45 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-non-logical-if" }
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchema@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++       function othersub1()
++        integer*4 othersub1
++        othersub1 = 9
++       end
++
++       function othersub2()
++        integer*4 othersub2
++        othersub2 = 0
++       end
++
++       program MAIN
++        integer*4 othersub1
++        integer*4 othersub2
++        integer a /1/
++        integer b /2/        
++ 
++        if (othersub1()) then ! { dg-error "IF clause at" }
++           write(*,*) "OK"
++        else
++           stop 1
++        end if
++        if (othersub2()) then ! { dg-error "IF clause at" }
++           stop 2
++        else
++           write(*,*) "OK"
++        end if
++        if (a-b) then ! { dg-error "IF clause at" }
++           write(*,*) "OK"
++        else
++           stop 3
++        end if
++        if (b-(a+1)) then ! { dg-error "IF clause at" }
++           stop 3
++        else
++           write(*,*) "OK"
++        end if
++       end
++
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-old-init.patch b/gcc12-fortran-fdec-old-init.patch
new file mode 100644
index 0000000..8554f2e
--- /dev/null
+++ b/gcc12-fortran-fdec-old-init.patch
@@ -0,0 +1,185 @@
+From 8bcc0f85ed1718c0dd9033ad4a34df181aabaffe Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 13:11:06 +0000
+Subject: [PATCH 05/10] Allow old-style initializers in derived types
+
+This allows simple declarations in derived types and structures, such as:
+    LOGICAL*1      NIL      /0/
+Only single value expressions are allowed at the moment.
+
+Use -fdec-old-init to enable. Also enabled by -fdec.
+---
+ gcc/fortran/decl.c                            | 27 +++++++++++++++----
+ gcc/fortran/lang.opt                          |  4 +++
+ gcc/fortran/options.c                         |  1 +
+ ...ec_derived_types_initialised_old_style_1.f | 25 +++++++++++++++++
+ ...ec_derived_types_initialised_old_style_2.f | 25 +++++++++++++++++
+ ...ec_derived_types_initialised_old_style_3.f | 26 ++++++++++++++++++
+ 6 files changed, 103 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
+
+diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
+index 723915822f3..5c8c1b7981b 100644
+--- a/gcc/fortran/decl.c
++++ b/gcc/fortran/decl.c
+@@ -2827,12 +2827,29 @@ variable_decl (int elem)
+          but not components of derived types.  */
+       else if (gfc_current_state () == COMP_DERIVED)
+ 	{
+-	  gfc_error ("Invalid old style initialization for derived type "
+-		     "component at %C");
+-	  m = MATCH_ERROR;
+-	  goto cleanup;
++	  if (flag_dec_old_init)
++	    {
++	      /* Attempt to match an old-style initializer which is a simple
++		 integer or character expression; this will not work with
++		 multiple values. */
++	      m = gfc_match_init_expr (&initializer);
++	      if (m == MATCH_ERROR)
++		goto cleanup;
++	      else if (m == MATCH_YES)
++		{
++		  m = gfc_match ("/");
++		  if (m != MATCH_YES)
++		    goto cleanup;
++		}
++	    }
++	  else
++	    {
++	      gfc_error ("Invalid old style initialization for derived type "
++			 "component at %C");
++	      m = MATCH_ERROR;
++	      goto cleanup;
++	    }
+ 	}
+-
+       /* For structure components, read the initializer as a special
+          expression and let the rest of this function apply the initializer
+          as usual.  */
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index d527c106bd6..25cc948699b 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -493,6 +493,10 @@ fdec-non-integer-index
+ Fortran Var(flag_dec_non_integer_index)
+ Enable support for non-integer substring indexes.
+ 
++fdec-old-init
++Fortran Var(flag_dec_old_init)
++Enable support for old style initializers in derived types.
++
+ fdec-structure
+ Fortran Var(flag_dec_structure)
+ Enable support for DEC STRUCTURE/RECORD.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index 9a042f64881..d6bd36c3a8a 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -79,6 +79,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_char_conversions, value, value);
+   SET_BITFLAG (flag_dec_duplicates, value, value);
+   SET_BITFLAG (flag_dec_non_integer_index, value, value);
++  SET_BITFLAG (flag_dec_old_init, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
+new file mode 100644
+index 00000000000..eac4f9bfcf1
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_1.f
+@@ -0,0 +1,25 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test old style initializers in derived types
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM spec_in_var
++          TYPE STRUCT1
++            INTEGER*4      ID       /8/
++            INTEGER*4      TYPE     /5/
++            INTEGER*8      DEFVAL   /0/
++            CHARACTER*(5)  NAME     /'tests'/
++            LOGICAL*1      NIL      /0/
++          END TYPE STRUCT1
++
++          TYPE (STRUCT1) SINST
++
++          IF(SINST%ID.NE.8) STOP 1
++          IF(SINST%TYPE.NE.5) STOP 2
++          IF(SINST%DEFVAL.NE.0) STOP 3
++          IF(SINST%NAME.NE.'tests') STOP 4
++          IF(SINST%NIL) STOP 5
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
+new file mode 100644
+index 00000000000..d904c8b2974
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_2.f
+@@ -0,0 +1,25 @@
++! { dg-do run }
++! { dg-options "-std=legacy -fdec-old-init" }
++!
++! Test old style initializers in derived types
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM spec_in_var
++          TYPE STRUCT1
++            INTEGER*4      ID       /8/
++            INTEGER*4      TYPE     /5/
++            INTEGER*8      DEFVAL   /0/
++            CHARACTER*(5)  NAME     /'tests'/
++            LOGICAL*1      NIL      /0/
++          END TYPE STRUCT1
++
++          TYPE (STRUCT1) SINST
++
++          IF(SINST%ID.NE.8) STOP 1
++          IF(SINST%TYPE.NE.5) STOP 2
++          IF(SINST%DEFVAL.NE.0) STOP 3
++          IF(SINST%NAME.NE.'tests') STOP 4
++          IF(SINST%NIL) STOP 5
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
+new file mode 100644
+index 00000000000..58c2b4b66cf
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_derived_types_initialised_old_style_3.f
+@@ -0,0 +1,26 @@
++! { dg-do compile }
++! { dg-options "-std=legacy -fdec -fno-dec-old-init" }
++!
++! Test old style initializers in derived types
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++
++        PROGRAM spec_in_var
++          TYPE STRUCT1
++            INTEGER*4      ID       /8/ ! { dg-error "Invalid old style initialization" }
++            INTEGER*4      TYPE     /5/ ! { dg-error "Invalid old style initialization" }
++            INTEGER*8      DEFVAL   /0/ ! { dg-error "Invalid old style initialization" }
++            CHARACTER*(5)  NAME     /'tests'/ ! { dg-error "Invalid old style initialization" }
++            LOGICAL*1      NIL      /0/ ! { dg-error "Invalid old style initialization" }
++          END TYPE STRUCT1
++
++          TYPE (STRUCT1) SINST
++
++          IF(SINST%ID.NE.8) STOP 1 ! { dg-error "'id' at \\(1\\) is not a member" }
++          IF(SINST%TYPE.NE.5) STOP 2 ! { dg-error "'type' at \\(1\\) is not a member" }
++          IF(SINST%DEFVAL.NE.0) STOP 3  ! { dg-error "'defval' at \\(1\\) is not a member" }
++          IF(SINST%NAME.NE.'tests') STOP 4 ! { dg-error "'name' at \\(1\\) is not a member" }
++          IF(SINST%NIL) STOP 5 ! { dg-error "'nil' at \\(1\\) is not a member" }
++        END
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-override-kind.patch b/gcc12-fortran-fdec-override-kind.patch
new file mode 100644
index 0000000..e1c7b83
--- /dev/null
+++ b/gcc12-fortran-fdec-override-kind.patch
@@ -0,0 +1,588 @@
+From 786869fd62813e80da9b6545a295d53c36275c19 Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 13:12:14 +0000
+Subject: [PATCH 06/10] Allow string length and kind to be specified on a per
+ variable basis.
+
+This allows kind/length to be mixed with array specification in
+declarations.
+
+e.g.
+
+      INTEGER*4 x*2, y*8
+      CHARACTER names*20(10)
+      REAL v(100)*8, vv*4(50)
+
+The per-variable size overrides the kind or length specified for the type.
+
+Use -fdec-override-kind to enable. Also enabled by -fdec.
+
+Note: this feature is a merger of two previously separate features.
+
+Now accepts named constants as kind parameters:
+
+      INTEGER A
+      PARAMETER (A=2)
+      INTEGER B*(A)
+
+Contributed by Mark Eggleston <mark.eggleston@codethink.com>
+
+Now rejects invalid kind parameters and prints error messages:
+
+      INTEGER X*3
+
+caused an internal compiler error.
+
+Contributed by Mark Eggleston <mark.eggleston@codethink.com>
+---
+ gcc/fortran/decl.c                            | 156 ++++++++++++++----
+ gcc/fortran/lang.opt                          |   4 +
+ gcc/fortran/options.c                         |   1 +
+ .../dec_mixed_char_array_declaration_1.f      |  13 ++
+ .../dec_mixed_char_array_declaration_2.f      |  13 ++
+ .../dec_mixed_char_array_declaration_3.f      |  13 ++
+ .../gfortran.dg/dec_spec_in_variable_1.f      |  31 ++++
+ .../gfortran.dg/dec_spec_in_variable_2.f      |  31 ++++
+ .../gfortran.dg/dec_spec_in_variable_3.f      |  31 ++++
+ .../gfortran.dg/dec_spec_in_variable_4.f      |  14 ++
+ .../gfortran.dg/dec_spec_in_variable_5.f      |  19 +++
+ .../gfortran.dg/dec_spec_in_variable_6.f      |  19 +++
+ .../gfortran.dg/dec_spec_in_variable_7.f      |  15 ++
+ .../gfortran.dg/dec_spec_in_variable_8.f      |  14 ++
+ 14 files changed, 340 insertions(+), 34 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
+
+diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
+index 5c8c1b7981b..f7dc9d8263d 100644
+--- a/gcc/fortran/decl.c
++++ b/gcc/fortran/decl.c
+@@ -1213,6 +1213,54 @@ syntax:
+   return MATCH_ERROR;
+ }
+ 
++/* This matches the nonstandard kind given after a variable name, like:
++   INTEGER x*2, y*4
++   The per-variable kind will override any kind given in the type
++   declaration.
++*/
++
++static match
++match_per_symbol_kind (int *length)
++{
++  match m;
++  gfc_expr *expr = NULL;
++
++  m = gfc_match_char ('*');
++  if (m != MATCH_YES)
++    return m;
++
++  m = gfc_match_small_literal_int (length, NULL);
++  if (m == MATCH_YES || m == MATCH_ERROR)
++    return m;
++
++  if (gfc_match_char ('(') == MATCH_NO)
++    return MATCH_ERROR;
++
++  m = gfc_match_expr (&expr);
++  if (m == MATCH_YES)
++    {
++      m = MATCH_ERROR; // Assume error
++      if (gfc_expr_check_typed (expr, gfc_current_ns, false))
++	{
++	  if ((expr->expr_type == EXPR_CONSTANT)
++	      && (expr->ts.type == BT_INTEGER))
++	    {
++	      *length = mpz_get_si(expr->value.integer);
++	      m = MATCH_YES;
++	    }
++	}
++
++	if (m == MATCH_YES)
++	  {
++	    if (gfc_match_char (')') == MATCH_NO)
++	       m = MATCH_ERROR;
++  }
++     }
++
++  if (expr != NULL)
++     gfc_free_expr (expr);
++  return m;
++}
+ 
+ /* Special subroutine for finding a symbol.  Check if the name is found
+    in the current name space.  If not, and we're compiling a function or
+@@ -2443,6 +2491,35 @@ check_function_name (char *name)
+ }
+ 
+ 
++static match
++match_character_length_clause (gfc_charlen **cl, bool *cl_deferred, int elem)
++{
++  gfc_expr* char_len;
++  char_len = NULL;
++
++  match m = match_char_length (&char_len, cl_deferred, false);
++  if (m == MATCH_YES)
++    {
++      *cl = gfc_new_charlen (gfc_current_ns, NULL);
++      (*cl)->length = char_len;
++    }
++  else if (m == MATCH_NO)
++    {
++      if (elem > 1
++	  && (current_ts.u.cl->length == NULL
++	      || current_ts.u.cl->length->expr_type != EXPR_CONSTANT))
++	{
++	  *cl = gfc_new_charlen (gfc_current_ns, NULL);
++	  (*cl)->length = gfc_copy_expr (current_ts.u.cl->length);
++	}
++      else
++      *cl = current_ts.u.cl;
++
++      *cl_deferred = current_ts.deferred;
++    }
++  return m;
++}
++
+ /* Match a variable name with an optional initializer.  When this
+    subroutine is called, a variable is expected to be parsed next.
+    Depending on what is happening at the moment, updates either the
+@@ -2453,7 +2530,7 @@ variable_decl (int elem)
+ {
+   char name[GFC_MAX_SYMBOL_LEN + 1];
+   static unsigned int fill_id = 0;
+-  gfc_expr *initializer, *char_len;
++  gfc_expr *initializer;
+   gfc_array_spec *as;
+   gfc_array_spec *cp_as; /* Extra copy for Cray Pointees.  */
+   gfc_charlen *cl;
+@@ -2462,11 +2539,15 @@ variable_decl (int elem)
+   match m;
+   bool t;
+   gfc_symbol *sym;
++  match cl_match;
++  match kind_match;
++  int overridden_kind;
+   char c;
+ 
+   initializer = NULL;
+   as = NULL;
+   cp_as = NULL;
++  kind_match = MATCH_NO;
+ 
+   /* When we get here, we've just matched a list of attributes and
+      maybe a type and a double colon.  The next thing we expect to see
+@@ -2519,6 +2600,28 @@ variable_decl (int elem)
+ 
+   var_locus = gfc_current_locus;
+ 
++
++  cl = NULL;
++  cl_deferred = false;
++  cl_match = MATCH_NO;
++
++  /* Check for a character length clause before an array clause */
++  if (flag_dec_override_kind)
++    {
++      if (current_ts.type == BT_CHARACTER)
++	{
++	  cl_match = match_character_length_clause (&cl, &cl_deferred, elem);
++	  if (cl_match == MATCH_ERROR)
++	    goto cleanup;
++	}
++      else
++	{
++	  kind_match = match_per_symbol_kind (&overridden_kind);
++	  if (kind_match == MATCH_ERROR)
++	    goto cleanup;
++	}
++    }
++
+   /* Now we could see the optional array spec. or character length.  */
+   m = gfc_match_array_spec (&as, true, true);
+   if (m == MATCH_ERROR)
+@@ -2667,40 +2770,12 @@ variable_decl (int elem)
+ 	}
+     }
+ 
+-  char_len = NULL;
+-  cl = NULL;
+-  cl_deferred = false;
+-
+-  if (current_ts.type == BT_CHARACTER)
++  /* Second chance for a character length clause */
++  if (cl_match == MATCH_NO && current_ts.type == BT_CHARACTER)
+     {
+-      switch (match_char_length (&char_len, &cl_deferred, false))
+-	{
+-	case MATCH_YES:
+-	  cl = gfc_new_charlen (gfc_current_ns, NULL);
+-
+-	  cl->length = char_len;
+-	  break;
+-
+-	/* Non-constant lengths need to be copied after the first
+-	   element.  Also copy assumed lengths.  */
+-	case MATCH_NO:
+-	  if (elem > 1
+-	      && (current_ts.u.cl->length == NULL
+-		  || current_ts.u.cl->length->expr_type != EXPR_CONSTANT))
+-	    {
+-	      cl = gfc_new_charlen (gfc_current_ns, NULL);
+-	      cl->length = gfc_copy_expr (current_ts.u.cl->length);
+-	    }
+-	  else
+-	    cl = current_ts.u.cl;
+-
+-	  cl_deferred = current_ts.deferred;
+-
+-	  break;
+-
+-	case MATCH_ERROR:
+-	  goto cleanup;
+-	}
++      m = match_character_length_clause (&cl, &cl_deferred, elem);
++      if (m == MATCH_ERROR)
++	goto cleanup;
+     }
+ 
+   /* The dummy arguments and result of the abreviated form of MODULE
+@@ -2802,6 +2877,19 @@ variable_decl (int elem)
+       goto cleanup;
+     }
+ 
++  if (kind_match == MATCH_YES)
++    {
++      gfc_find_symbol (name, gfc_current_ns, 1, &sym);
++      /* sym *must* be found at this point */
++      sym->ts.kind = overridden_kind;
++      if (gfc_validate_kind (sym->ts.type, sym->ts.kind, true) < 0)
++	{
++	  gfc_error ("Kind %d not supported for type %s at %C",
++		     sym->ts.kind, gfc_basic_typename (sym->ts.type));
++	  return MATCH_ERROR;
++	}
++    }
++
+   if (!check_function_name (name))
+     {
+       m = MATCH_ERROR;
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 25cc948699b..4a269ebb22d 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -493,6 +493,10 @@ fdec-non-integer-index
+ Fortran Var(flag_dec_non_integer_index)
+ Enable support for non-integer substring indexes.
+ 
++fdec-override-kind
++Fortran Var(flag_dec_override_kind)
++Enable support for per variable kind specification.
++
+ fdec-old-init
+ Fortran Var(flag_dec_old_init)
+ Enable support for old style initializers in derived types.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index d6bd36c3a8a..edbab483b36 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -80,6 +80,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_duplicates, value, value);
+   SET_BITFLAG (flag_dec_non_integer_index, value, value);
+   SET_BITFLAG (flag_dec_old_init, value, value);
++  SET_BITFLAG (flag_dec_override_kind, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
+new file mode 100644
+index 00000000000..706ea4112a4
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_1.f
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test character declaration with mixed string length and array specification
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++       PROGRAM character_declaration
++          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/
++          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
++          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
+new file mode 100644
+index 00000000000..26d2acf01de
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_2.f
+@@ -0,0 +1,13 @@
++! { dg-do run }
++! { dg-options "-fdec-override-kind" }
++!
++! Test character declaration with mixed string length and array specification
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM character_declaration
++          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/
++          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
++          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
+new file mode 100644
+index 00000000000..76e4f0bdb93
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_mixed_char_array_declaration_3.f
+@@ -0,0 +1,13 @@
++! { dg-do compile }
++! { dg-options "-fdec-override-kind -fno-dec-override-kind" }
++!
++! Test character declaration with mixed string length and array specification
++!
++! Contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        PROGRAM character_declaration
++          CHARACTER ASPEC_SLENGTH*2 (5) /'01','02','03','04','05'/ ! { dg-error "Syntax error" }
++          CHARACTER SLENGTH_ASPEC(5)*2 /'01','02','03','04','05'/
++          if (ASPEC_SLENGTH(3).NE.SLENGTH_ASPEC(3)) STOP 1 ! { dg-error " Operands of comparison operator" }
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
+new file mode 100644
+index 00000000000..edd0f5874b7
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_1.f
+@@ -0,0 +1,31 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test kind specification in variable not in type
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer*8  ai*1, bi*4, ci
++          real*4 ar*4, br*8, cr
++
++          ai = 1
++          ar = 1.0
++          bi = 2
++          br = 2.0
++          ci = 3
++          cr = 3.0
++
++          if (ai .ne. 1) stop 1
++          if (abs(ar - 1.0) > 1.0D-6) stop 2
++          if (bi .ne. 2) stop 3
++          if (abs(br - 2.0) > 1.0D-6) stop 4
++          if (ci .ne. 3) stop 5
++          if (abs(cr - 3.0) > 1.0D-6) stop 6
++          if (kind(ai) .ne. 1) stop 7
++          if (kind(ar) .ne. 4) stop 8
++          if (kind(bi) .ne. 4) stop 9
++          if (kind(br) .ne. 8) stop 10
++          if (kind(ci) .ne. 8) stop 11
++          if (kind(cr) .ne. 4) stop 12
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
+new file mode 100644
+index 00000000000..bfaba584dbb
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_2.f
+@@ -0,0 +1,31 @@
++! { dg-do run }
++! { dg-options "-fdec-override-kind" }
++!
++! Test kind specification in variable not in type
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer*8  ai*1, bi*4, ci
++          real*4 ar*4, br*8, cr
++
++          ai = 1
++          ar = 1.0
++          bi = 2
++          br = 2.0
++          ci = 3
++          cr = 3.0
++
++          if (ai .ne. 1) stop 1
++          if (abs(ar - 1.0) > 1.0D-6) stop 2
++          if (bi .ne. 2) stop 3
++          if (abs(br - 2.0) > 1.0D-6) stop 4
++          if (ci .ne. 3) stop 5
++          if (abs(cr - 3.0) > 1.0D-6) stop 6
++          if (kind(ai) .ne. 1) stop 7
++          if (kind(ar) .ne. 4) stop 8
++          if (kind(bi) .ne. 4) stop 9
++          if (kind(br) .ne. 8) stop 10
++          if (kind(ci) .ne. 8) stop 11
++          if (kind(cr) .ne. 4) stop 12
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
+new file mode 100644
+index 00000000000..5ff434e7466
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_3.f
+@@ -0,0 +1,31 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-override-kind" }
++!
++! Test kind specification in variable not in type
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer*8  ai*1, bi*4, ci ! { dg-error "Syntax error" }
++          real*4 ar*4, br*8, cr ! { dg-error "Syntax error" }
++
++          ai = 1
++          ar = 1.0
++          bi = 2
++          br = 2.0
++          ci = 3
++          cr = 3.0
++
++          if (ai .ne. 1) stop 1
++          if (abs(ar - 1.0) > 1.0D-6) stop 2
++          if (bi .ne. 2) stop 3
++          if (abs(br - 2.0) > 1.0D-6) stop 4
++          if (ci .ne. 3) stop 5
++          if (abs(cr - 3.0) > 1.0D-6) stop 6
++          if (kind(ai) .ne. 1) stop 7
++          if (kind(ar) .ne. 4) stop 8
++          if (kind(bi) .ne. 4) stop 9
++          if (kind(br) .ne. 8) stop 10
++          if (kind(ci) .ne. 8) stop 11
++          if (kind(cr) .ne. 4) stop 12
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
+new file mode 100644
+index 00000000000..c01980e8b9d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_4.f
+@@ -0,0 +1,14 @@
++! { dg-do compile }
++!
++! Test kind specification in variable not in type. The per variable
++! kind specification is not enabled so these should fail
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer a
++          parameter(a=2)
++          integer b*(a) ! { dg-error "Syntax error" }
++          real c*(8)    ! { dg-error "Syntax error" }
++          logical d*1_1 ! { dg-error "Syntax error" }
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
+new file mode 100644
+index 00000000000..e2f39da3f4f
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_5.f
+@@ -0,0 +1,19 @@
++! { dg-do run }
++! { dg-options "-fdec-override-kind" }
++!
++! Test kind specification in variable not in type
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer a
++          parameter(a=2)
++          integer b*(a)
++          real c*(8)
++          logical d*(1_1)
++          character e*(a)
++          if (kind(b).ne.2) stop 1
++          if (kind(c).ne.8) stop 2
++          if (kind(d).ne.1) stop 3
++          if (len(e).ne.2) stop 4
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
+new file mode 100644
+index 00000000000..569747874e3
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_6.f
+@@ -0,0 +1,19 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test kind specification in variable not in type
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer a
++          parameter(a=2)
++          integer b*(a)
++          real c*(8)
++          logical d*(1_1)
++          character e*(a)
++          if (kind(b).ne.2) stop 1
++          if (kind(c).ne.8) stop 2
++          if (kind(d).ne.1) stop 3
++          if (len(e).ne.2) stop 4
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
+new file mode 100644
+index 00000000000..b975bfd15c5
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_7.f
+@@ -0,0 +1,15 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-override-kind" }
++!
++! Test kind specification in variable not in type as the per variable
++! kind specification is not enables these should fail
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer a
++          parameter(a=2)
++          integer b*(a) ! { dg-error "Syntax error" }
++          real c*(8)    ! { dg-error "Syntax error" }
++          logical d*1_1 ! { dg-error "Syntax error" }
++        end
+diff --git a/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
+new file mode 100644
+index 00000000000..85732e0bd85
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_spec_in_variable_8.f
+@@ -0,0 +1,14 @@
++! { dg-do compile }
++! { dg-options "-fdec" }
++!
++! Check that invalid kind values are rejected.
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        program spec_in_var
++          integer a
++          parameter(a=3)
++          integer b*(a) ! { dg-error "Kind 3 not supported" }
++          real c*(78)   ! { dg-error "Kind 78 not supported" }
++          logical d*(*) ! { dg-error "Invalid character" }
++        end
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-promotion.patch b/gcc12-fortran-fdec-promotion.patch
new file mode 100644
index 0000000..36e0ff0
--- /dev/null
+++ b/gcc12-fortran-fdec-promotion.patch
@@ -0,0 +1,2093 @@
+From 7a27318818e359a277f2fa5f7dc3932d0fb950f5 Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 14:58:07 +0000
+Subject: [PATCH 08/10] Support type promotion in calls to intrinsics
+
+Use -fdec-promotion or -fdec to enable this feature.
+
+Merged 2 commits: worked on by Ben Brewer <ben.brewer@codethink.co.uk>,
+Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> and
+Jeff Law <law@redhat.com>
+
+Re-worked by Mark Eggleston <mark.eggleston@codethink.com>
+---
+ gcc/fortran/check.c                           |  71 +++++-
+ gcc/fortran/intrinsic.c                       |   5 +
+ gcc/fortran/iresolve.c                        |  91 ++++---
+ gcc/fortran/lang.opt                          |   4 +
+ gcc/fortran/options.c                         |   1 +
+ gcc/fortran/simplify.c                        | 240 ++++++++++++++----
+ ...trinsic_int_real_array_const_promotion_1.f |  18 ++
+ ...trinsic_int_real_array_const_promotion_2.f |  18 ++
+ ...trinsic_int_real_array_const_promotion_3.f |  18 ++
+ ...dec_intrinsic_int_real_const_promotion_1.f |  90 +++++++
+ ...dec_intrinsic_int_real_const_promotion_2.f |  90 +++++++
+ ...dec_intrinsic_int_real_const_promotion_3.f |  92 +++++++
+ .../dec_intrinsic_int_real_promotion_1.f      | 130 ++++++++++
+ .../dec_intrinsic_int_real_promotion_2.f      | 130 ++++++++++
+ .../dec_intrinsic_int_real_promotion_3.f      | 130 ++++++++++
+ .../dec_intrinsic_int_real_promotion_4.f      | 118 +++++++++
+ .../dec_intrinsic_int_real_promotion_5.f      | 118 +++++++++
+ .../dec_intrinsic_int_real_promotion_6.f      | 118 +++++++++
+ .../dec_intrinsic_int_real_promotion_7.f      | 118 +++++++++
+ .../gfortran.dg/dec_kind_promotion-1.f        |  40 +++
+ .../gfortran.dg/dec_kind_promotion-2.f        |  40 +++
+ .../gfortran.dg/dec_kind_promotion-3.f        |  39 +++
+ 22 files changed, 1639 insertions(+), 80 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
+
+diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
+index 623c1cc470e..e20a834a860 100644
+--- a/gcc/fortran/check.c
++++ b/gcc/fortran/check.c
+@@ -1396,12 +1396,40 @@ gfc_check_allocated (gfc_expr *array)
+ }
+ 
+ 
++/* Check function where both arguments must be real or integer
++   and warn if they are different types.  */
++
++bool
++check_int_real_promotion (gfc_expr *a, gfc_expr *b)
++{
++  gfc_expr *i;
++
++  if (!int_or_real_check (a, 0))
++    return false;
++
++  if (!int_or_real_check (b, 1))
++    return false;
++
++  if (a->ts.type != b->ts.type)
++    {
++      i = (a->ts.type != BT_REAL ? a : b);
++      gfc_warning_now (OPT_Wconversion, "Conversion from INTEGER to REAL "
++		       "at %L might lose precision", &i->where);
++    }
++
++  return true;
++}
++
++
+ /* Common check function where the first argument must be real or
+    integer and the second argument must be the same as the first.  */
+ 
+ bool
+ gfc_check_a_p (gfc_expr *a, gfc_expr *p)
+ {
++  if (flag_dec_promotion)
++    return check_int_real_promotion (a, p);
++
+   if (!int_or_real_check (a, 0))
+     return false;
+ 
+@@ -3724,6 +3752,41 @@ check_rest (bt type, int kind, gfc_actual_arglist *arglist)
+ }
+ 
+ 
++/* Check function where all arguments of an argument list must be real
++   or integer.  */
++
++static bool
++check_rest_int_real (gfc_actual_arglist *arglist)
++{
++  gfc_actual_arglist *arg, *tmp;
++  gfc_expr *x;
++  int m, n;
++
++  if (!min_max_args (arglist))
++    return false;
++
++  for (arg = arglist, n=1; arg; arg = arg->next, n++)
++    {
++      x = arg->expr;
++      if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
++	{
++	  gfc_error ("%<a%d%> argument of %qs intrinsic at %L must be "
++		     "INTEGER or REAL", n, gfc_current_intrinsic, &x->where);
++	  return false;
++	}
++
++      for (tmp = arglist, m=1; tmp != arg; tmp = tmp->next, m++)
++	if (!gfc_check_conformance (tmp->expr, x,
++				    "arguments 'a%d' and 'a%d' for "
++				    "intrinsic '%s'", m, n,
++				    gfc_current_intrinsic))
++	  return false;
++    }
++
++  return true;
++}
++
++
+ bool
+ gfc_check_min_max (gfc_actual_arglist *arg)
+ {
+@@ -3748,7 +3811,10 @@ gfc_check_min_max (gfc_actual_arglist *arg)
+       return false;
+     }
+ 
+-  return check_rest (x->ts.type, x->ts.kind, arg);
++  if (flag_dec_promotion && x->ts.type != BT_CHARACTER)
++    return check_rest_int_real (arg);
++  else
++    return check_rest (x->ts.type, x->ts.kind, arg);
+ }
+ 
+ 
+@@ -5121,6 +5187,9 @@ gfc_check_shift (gfc_expr *i, gfc_expr *shift)
+ bool
+ gfc_check_sign (gfc_expr *a, gfc_expr *b)
+ {
++  if (flag_dec_promotion)
++    return check_int_real_promotion (a, b);
++
+   if (!int_or_real_check (a, 0))
+     return false;
+ 
+diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
+index e68eff8bdbb..81b3a24c2be 100644
+--- a/gcc/fortran/intrinsic.c
++++ b/gcc/fortran/intrinsic.c
+@@ -4467,6 +4467,11 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym,
+       if (ts.kind == 0)
+ 	ts.kind = actual->expr->ts.kind;
+ 
++      /* If kind promotion is allowed don't check for kind if it is smaller */
++      if (flag_dec_promotion && ts.type == BT_INTEGER)
++	if (actual->expr->ts.kind < ts.kind)
++	  ts.kind = actual->expr->ts.kind;
++
+       if (!gfc_compare_types (&ts, &actual->expr->ts))
+ 	{
+ 	  if (error_flag)
+diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
+index e17fe45f080..b9cdaff2499 100644
+--- a/gcc/fortran/iresolve.c
++++ b/gcc/fortran/iresolve.c
+@@ -817,19 +817,22 @@ gfc_resolve_dble (gfc_expr *f, gfc_expr *a)
+ void
+ gfc_resolve_dim (gfc_expr *f, gfc_expr *a, gfc_expr *p)
+ {
+-  f->ts.type = a->ts.type;
+   if (p != NULL)
+-    f->ts.kind = gfc_kind_max (a,p);
+-  else
+-    f->ts.kind = a->ts.kind;
+-
+-  if (p != NULL && a->ts.kind != p->ts.kind)
+     {
+-      if (a->ts.kind == gfc_kind_max (a,p))
+-	gfc_convert_type (p, &a->ts, 2);
++      f->ts.kind = gfc_kind_max (a,p);
++      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
++	f->ts.type = BT_REAL;
+       else
+-	gfc_convert_type (a, &p->ts, 2);
++	f->ts.type = BT_INTEGER;
++
++      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
++	gfc_convert_type (a, &f->ts, 2);
++
++      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
++	gfc_convert_type (p, &f->ts, 2);
+     }
++  else
++    f->ts = a->ts;
+ 
+   f->value.function.name
+     = gfc_get_string ("__dim_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
+@@ -1606,14 +1609,17 @@ gfc_resolve_minmax (const char *name, gfc_expr *f, gfc_actual_arglist *args)
+   /* Find the largest type kind.  */
+   for (a = args->next; a; a = a->next)
+     {
++      if (a->expr-> ts.type == BT_REAL)
++	f->ts.type = BT_REAL;
++
+       if (a->expr->ts.kind > f->ts.kind)
+ 	f->ts.kind = a->expr->ts.kind;
+     }
+ 
+-  /* Convert all parameters to the required kind.  */
++  /* Convert all parameters to the required type and/or kind.  */
+   for (a = args; a; a = a->next)
+     {
+-      if (a->expr->ts.kind != f->ts.kind)
++      if (a->expr->ts.type != f->ts.type || a->expr->ts.kind != f->ts.kind)
+ 	gfc_convert_type (a->expr, &f->ts, 2);
+     }
+ 
+@@ -2106,19 +2112,22 @@ gfc_resolve_minval (gfc_expr *f, gfc_expr *array, gfc_expr *dim,
+ void
+ gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
+ {
+-  f->ts.type = a->ts.type;
+   if (p != NULL)
+-    f->ts.kind = gfc_kind_max (a,p);
+-  else
+-    f->ts.kind = a->ts.kind;
+-
+-  if (p != NULL && a->ts.kind != p->ts.kind)
+     {
+-      if (a->ts.kind == gfc_kind_max (a,p))
+-	gfc_convert_type (p, &a->ts, 2);
++      f->ts.kind = gfc_kind_max (a,p);
++      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
++	f->ts.type = BT_REAL;
+       else
+-	gfc_convert_type (a, &p->ts, 2);
++	f->ts.type = BT_INTEGER;
++
++      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
++	gfc_convert_type (a, &f->ts, 2);
++
++      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
++	gfc_convert_type (p, &f->ts, 2);
+     }
++  else
++    f->ts = a->ts;
+ 
+   f->value.function.name
+     = gfc_get_string ("__mod_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
+@@ -2128,19 +2137,22 @@ gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
+ void
+ gfc_resolve_modulo (gfc_expr *f, gfc_expr *a, gfc_expr *p)
+ {
+-  f->ts.type = a->ts.type;
+   if (p != NULL)
+-    f->ts.kind = gfc_kind_max (a,p);
+-  else
+-    f->ts.kind = a->ts.kind;
+-
+-  if (p != NULL && a->ts.kind != p->ts.kind)
+     {
+-      if (a->ts.kind == gfc_kind_max (a,p))
+-	gfc_convert_type (p, &a->ts, 2);
++      f->ts.kind = gfc_kind_max (a,p);
++      if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
++	f->ts.type = BT_REAL;
+       else
+-	gfc_convert_type (a, &p->ts, 2);
++	f->ts.type = BT_INTEGER;
++
++      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
++	gfc_convert_type (a, &f->ts, 2);
++
++      if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
++	gfc_convert_type (p, &f->ts, 2);
+     }
++  else
++    f->ts = a->ts;
+ 
+   f->value.function.name
+     = gfc_get_string ("__modulo_%c%d", gfc_type_letter (f->ts.type),
+@@ -2515,9 +2527,26 @@ gfc_resolve_shift (gfc_expr *f, gfc_expr *i, gfc_expr *shift ATTRIBUTE_UNUSED)
+ 
+ 
+ void
+-gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b ATTRIBUTE_UNUSED)
++gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b)
+ {
+-  f->ts = a->ts;
++  if (b != NULL)
++    {
++      f->ts.kind = gfc_kind_max (a, b);
++      if (a->ts.type == BT_REAL || b->ts.type == BT_REAL)
++	f->ts.type = BT_REAL;
++      else
++	f->ts.type = BT_INTEGER;
++
++      if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
++	gfc_convert_type (a, &f->ts, 2);
++
++      if (b->ts.kind != f->ts.kind || b->ts.type != f->ts.type)
++	gfc_convert_type (b, &f->ts, 2);
++    }
++  else
++    {
++      f->ts = a->ts;
++    }
+   f->value.function.name
+     = gfc_get_string ("__sign_%c%d", gfc_type_letter (a->ts.type), a->ts.kind);
+ }
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index d886c2f33ed..4ca2f93f2df 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -505,6 +505,10 @@ fdec-old-init
+ Fortran Var(flag_dec_old_init)
+ Enable support for old style initializers in derived types.
+ 
++fdec-promotion
++Fortran Var(flag_dec_promotion)
++Add support for type promotion in intrinsic arguments.
++
+ fdec-structure
+ Fortran Var(flag_dec_structure)
+ Enable support for DEC STRUCTURE/RECORD.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index a946c86790a..15079c7e95a 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -82,6 +82,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_old_init, value, value);
+   SET_BITFLAG (flag_dec_override_kind, value, value);
+   SET_BITFLAG (flag_dec_non_logical_if, value, value);
++  SET_BITFLAG (flag_dec_promotion, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
+index 9900572424f..3419e06fec2 100644
+--- a/gcc/fortran/simplify.c
++++ b/gcc/fortran/simplify.c
+@@ -2333,39 +2333,79 @@ gfc_simplify_digits (gfc_expr *x)
+ }
+ 
+ 
++/* Simplify function which sets the floating-point value of ar from
++   the value of a independently if a is integer of real.  */
++
++static void
++simplify_int_real_promotion (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar)
++{
++  if (a->ts.type == BT_REAL)
++    {
++      mpfr_init2 (*ar, (a->ts.kind * 8));
++      mpfr_set (*ar, a->value.real, GFC_RND_MODE);
++    }
++  else
++    {
++      mpfr_init2 (*ar, (b->ts.kind * 8));
++      mpfr_set_z (*ar, a->value.integer, GFC_RND_MODE);
++    }
++}
++
++
++/* Simplify function which promotes a and b arguments from integer to real if
++   required in ar and br floating-point values. This function returns true if
++   a or b are reals and false otherwise. */
++
++static bool
++simplify_int_real_promotion2 (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar,
++			      mpfr_t *br)
++{
++  if (a->ts.type != BT_REAL && b->ts.type != BT_REAL)
++    return false;
++
++  simplify_int_real_promotion (a, b, ar);
++  simplify_int_real_promotion (b, a, br);
++
++  return true;
++}
++
++
+ gfc_expr *
+ gfc_simplify_dim (gfc_expr *x, gfc_expr *y)
+ {
+   gfc_expr *result;
+   int kind;
+ 
++  mpfr_t xr;
++  mpfr_t yr;
++
+   if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+-  kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
+-  result = gfc_get_constant_expr (x->ts.type, kind, &x->where);
+-
+-  switch (x->ts.type)
++  if ((x->ts.type != BT_REAL && x->ts.type != BT_INTEGER)
++      || (y->ts.type != BT_REAL && y->ts.type != BT_INTEGER))
+     {
+-      case BT_INTEGER:
+-	if (mpz_cmp (x->value.integer, y->value.integer) > 0)
+-	  mpz_sub (result->value.integer, x->value.integer, y->value.integer);
+-	else
+-	  mpz_set_ui (result->value.integer, 0);
+-
+-	break;
+-
+-      case BT_REAL:
+-	if (mpfr_cmp (x->value.real, y->value.real) > 0)
+-	  mpfr_sub (result->value.real, x->value.real, y->value.real,
+-		    GFC_RND_MODE);
+-	else
+-	  mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
++      gfc_internal_error ("gfc_simplify_dim(): Bad arguments");
++      return NULL;
++    }
+ 
+-	break;
++  kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
+ 
+-      default:
+-	gfc_internal_error ("gfc_simplify_dim(): Bad type");
++  if (simplify_int_real_promotion2 (x, y, &xr, &yr))
++    {
++      result = gfc_get_constant_expr (BT_REAL, kind, &x->where);
++      if (mpfr_cmp (xr, yr) > 0)
++	mpfr_sub (result->value.real, xr, yr, GFC_RND_MODE);
++      else
++	mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
++    }
++  else
++    {
++      result = gfc_get_constant_expr (BT_INTEGER, kind, &x->where);
++      if (mpz_cmp (x->value.integer, y->value.integer) > 0)
++	mpz_sub (result->value.integer, x->value.integer, y->value.integer);
++      else
++	mpz_set_ui (result->value.integer, 0);
+     }
+ 
+   return range_check (result, "DIM");
+@@ -4953,6 +4993,76 @@ min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign, bool back_val)
+ {
+   int ret;
+ 
++  mpfr_t *arp;
++  mpfr_t *erp;
++  mpfr_t ar;
++  mpfr_t er;
++
++  if (arg->ts.type != extremum->ts.type)
++    {
++      if (arg->ts.type == BT_REAL)
++	{
++	  arp = &arg->value.real;
++	}
++      else
++	{
++	  mpfr_init2 (ar, (arg->ts.kind * 8));
++	  mpfr_set_z (ar, arg->value.integer, GFC_RND_MODE);
++	  arp = &ar;
++	}
++
++      if (extremum->ts.type == BT_REAL)
++	{
++	  erp = &extremum->value.real;
++	}
++      else
++	{
++	  mpfr_init2 (er, (extremum->ts.kind * 8));
++	  mpfr_set_z (er, extremum->value.integer, GFC_RND_MODE);
++	  erp = &er;
++	}
++
++      if (mpfr_nan_p (*erp))
++	{
++	  ret = 1;
++	  extremum->ts.type = arg->ts.type;
++	  extremum->ts.kind = arg->ts.kind;
++	  if (arg->ts.type == BT_INTEGER)
++	    {
++	      mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
++	      mpz_set (extremum->value.integer, arg->value.integer);
++	    }
++	  else
++	    {
++	      mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
++	      mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
++	    }
++	}
++      else if (mpfr_nan_p (*arp))
++	ret = -1;
++      else
++	{
++	  ret = mpfr_cmp (*arp, *erp) * sign;
++	  if (ret > 0)
++	    {
++	      extremum->ts.type = arg->ts.type;
++	      extremum->ts.kind = arg->ts.kind;
++	      if (arg->ts.type == BT_INTEGER)
++		{
++		  mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
++		  mpz_set (extremum->value.integer, arg->value.integer);
++		}
++	      else
++		{
++		  mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
++		  mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
++		}
++	    }
++	}
++
++      return ret;
++    }
++
+   switch (arg->ts.type)
+     {
+       case BT_INTEGER:
+@@ -5912,7 +6022,9 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
+   gfc_expr *result;
+   int kind;
+ 
+-  /* First check p.  */
++  mpfr_t ar;
++  mpfr_t pr;
++
+   if (p->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+@@ -5942,16 +6054,24 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
+   if (a->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
++  if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
++    {
++      gfc_internal_error ("gfc_simplify_mod(): Bad arguments");
++      return NULL;
++    }
++
+   kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
+-  result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
+ 
+-  if (a->ts.type == BT_INTEGER)
+-    mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
+-  else
++  if (simplify_int_real_promotion2 (a, p, &ar, &pr))
+     {
++      result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
+       gfc_set_model_kind (kind);
+-      mpfr_fmod (result->value.real, a->value.real, p->value.real,
+-		 GFC_RND_MODE);
++      mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
++    }
++  else
++    {
++      result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
++      mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
+     }
+ 
+   return range_check (result, "MOD");
+@@ -5964,7 +6084,9 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
+   gfc_expr *result;
+   int kind;
+ 
+-  /* First check p.  */
++  mpfr_t ar;
++  mpfr_t pr;
++
+   if (p->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+@@ -5991,28 +6113,36 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
+ 	gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
+     }
+ 
++  if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
++    {
++      gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
++      return NULL;
++    }
++
+   if (a->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+   kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
+-  result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
+ 
+-  if (a->ts.type == BT_INTEGER)
+-	mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
+-  else
++  if (simplify_int_real_promotion2 (a, p, &ar, &pr))
+     {
++      result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
+       gfc_set_model_kind (kind);
+-      mpfr_fmod (result->value.real, a->value.real, p->value.real,
+-                 GFC_RND_MODE);
++      mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
+       if (mpfr_cmp_ui (result->value.real, 0) != 0)
+-        {
+-          if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real))
+-            mpfr_add (result->value.real, result->value.real, p->value.real,
+-                      GFC_RND_MODE);
+-	    }
+-	  else
+-        mpfr_copysign (result->value.real, result->value.real,
+-                       p->value.real, GFC_RND_MODE);
++	{
++	  if (mpfr_signbit (ar) != mpfr_signbit (pr))
++	    mpfr_add (result->value.real, result->value.real, pr,
++		      GFC_RND_MODE);
++	}
++      else
++	mpfr_copysign (result->value.real, result->value.real, pr,
++		       GFC_RND_MODE);
++    }
++  else
++    {
++      result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
++      mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
+     }
+ 
+   return range_check (result, "MODULO");
+@@ -7578,27 +7708,41 @@ gfc_expr *
+ gfc_simplify_sign (gfc_expr *x, gfc_expr *y)
+ {
+   gfc_expr *result;
++  bool neg;
+ 
+   if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
+     return NULL;
+ 
+   result = gfc_get_constant_expr (x->ts.type, x->ts.kind, &x->where);
+ 
++  switch (y->ts.type)
++    {
++      case BT_INTEGER:
++	neg = (mpz_sgn (y->value.integer) < 0);
++	break;
++
++      case BT_REAL:
++	neg = (mpfr_sgn (y->value.real) < 0);
++	break;
++
++      default:
++	gfc_internal_error ("Bad type in gfc_simplify_sign");
++    }
++
+   switch (x->ts.type)
+     {
+       case BT_INTEGER:
+ 	mpz_abs (result->value.integer, x->value.integer);
+-	if (mpz_sgn (y->value.integer) < 0)
++	if (neg)
+ 	  mpz_neg (result->value.integer, result->value.integer);
+ 	break;
+ 
+       case BT_REAL:
+-	if (flag_sign_zero)
++	if (flag_sign_zero && y->ts.type == BT_REAL)
+ 	  mpfr_copysign (result->value.real, x->value.real, y->value.real,
+-			GFC_RND_MODE);
++			 GFC_RND_MODE);
+ 	else
+-	  mpfr_setsign (result->value.real, x->value.real,
+-			mpfr_sgn (y->value.real) < 0 ? 1 : 0, GFC_RND_MODE);
++	  mpfr_setsign (result->value.real, x->value.real, neg, GFC_RND_MODE);
+ 	break;
+ 
+       default:
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
+new file mode 100644
+index 00000000000..25763852139
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
+@@ -0,0 +1,18 @@
++! { dg-do compile }
++! { dg-options "-fdec" }
++!
++! Test promotion between integers and reals for mod and modulo where
++! A is a constant array and P is zero.
++!
++! Compilation errors are expected
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program promotion_int_real_array_const
++          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "shall not be zero" }
++          a = mod([12.0, 34.0], 0)*4          ! { dg-error "shall not be zero" }
++          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
++          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "shall not be zero" }
++      end program
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
+new file mode 100644
+index 00000000000..b78a46054f4
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
+@@ -0,0 +1,18 @@
++! { dg-do compile }
++! { dg-options "-fdec-promotion" }
++!
++! Test promotion between integers and reals for mod and modulo where
++! A is a constant array and P is zero.
++!
++! Compilation errors are expected
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program promotion_int_real_array_const
++          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "shall not be zero" }
++          a = mod([12.0, 34.0], 0)*4          ! { dg-error "shall not be zero" }
++          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
++          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "shall not be zero" }
++      end program
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
+new file mode 100644
+index 00000000000..318ab5db97e
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
+@@ -0,0 +1,18 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-promotion" }
++!
++! Test promotion between integers and reals for mod and modulo where
++! A is a constant array and P is zero.
++!
++! Compilation errors are expected
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program promotion_int_real_array_const
++          real a(2) = mod([12, 34], 0.0)*4    ! { dg-error "'a' and 'p' arguments of 'mod'" }
++          a = mod([12.0, 34.0], 0)*4          ! { dg-error "'a' and 'p' arguments of 'mod'" }
++          real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "'a' and 'p' arguments of 'modulo'" }
++          b = modulo([12.0, 34.0], 0)*4       ! { dg-error "'a' and 'p' arguments of 'modulo'" }
++      end program
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
+new file mode 100644
+index 00000000000..27eb2582bb2
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
+@@ -0,0 +1,90 @@
++! { dg-do run }
++! { dg-options "-fdec -finit-real=snan" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real_const
++        ! array_nan 4th position value is NAN
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(4, 3)
++        if (m_i .ne. 1) STOP 1
++        m_r = MOD(4.0, 3.0)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
++        m_r = MOD(4, 3.0)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(4.0, 3)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++
++        md_i = MODULO(4, 3)
++        if (md_i .ne. 1) STOP 5
++        md_r = MODULO(4.0, 3.0)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
++        md_r = MODULO(4, 3.0)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
++        md_r = MODULO(4.0, 3)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
++
++        d_i = DIM(4, 3)
++        if (d_i .ne. 1) STOP 9
++        d_r = DIM(4.0, 3.0)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
++        d_r = DIM(4.0, 3)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
++        d_r = DIM(3, 4.0)
++        if (abs(d_r) > 1.0D-6) STOP 12
++
++        s_i = SIGN(-4, 3)
++        if (s_i .ne. 4) STOP 13
++        s_r = SIGN(4.0, -3.0)
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
++        s_r = SIGN(4.0, -3)
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
++        s_r = SIGN(-4, 3.0)
++        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
++
++        mx_i = MAX(-4, -3, 2, 1)
++        if (mx_i .ne. 2) STOP 17
++        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
++        mx_r = MAX(-4, -3.0, 2.0, 1)
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 20
++
++        mn_i = MIN(-4, -3, 2, 1)
++        if (mn_i .ne. -4) STOP 21
++        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
++        mn_r = MIN(-4, -3.0, 2.0, 1)
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 24
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
+new file mode 100644
+index 00000000000..bdd017b7280
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
+@@ -0,0 +1,90 @@
++! { dg-do run }
++! { dg-options "-fdec-promotion -finit-real=snan" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real_const
++        ! array_nan 4th position value is NAN
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(4, 3)
++        if (m_i .ne. 1) STOP 1
++        m_r = MOD(4.0, 3.0)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
++        m_r = MOD(4, 3.0)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(4.0, 3)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++
++        md_i = MODULO(4, 3)
++        if (md_i .ne. 1) STOP 5
++        md_r = MODULO(4.0, 3.0)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
++        md_r = MODULO(4, 3.0)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
++        md_r = MODULO(4.0, 3)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
++
++        d_i = DIM(4, 3)
++        if (d_i .ne. 1) STOP 9
++        d_r = DIM(4.0, 3.0)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
++        d_r = DIM(4.0, 3)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
++        d_r = DIM(3, 4.0)
++        if (abs(d_r) > 1.0D-6) STOP 12
++
++        s_i = SIGN(-4, 3)
++        if (s_i .ne. 4) STOP 13
++        s_r = SIGN(4.0, -3.0)
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
++        s_r = SIGN(4.0, -3)
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
++        s_r = SIGN(-4, 3.0)
++        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
++
++        mx_i = MAX(-4, -3, 2, 1)
++        if (mx_i .ne. 2) STOP 17
++        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
++        mx_r = MAX(-4, -3.0, 2.0, 1)
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 20
++
++        mn_i = MIN(-4, -3, 2, 1)
++        if (mn_i .ne. -4) STOP 21
++        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
++        mn_r = MIN(-4, -3.0, 2.0, 1)
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 24
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
+new file mode 100644
+index 00000000000..ce90a5667d6
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
+@@ -0,0 +1,92 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-promotion -finit-real=snan" }
++!
++! Test that there is no promotion between integers and reals in
++! intrinsic operations.
++!
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real_const
++        ! array_nan 4th position value is NAN
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(4, 3)
++        if (m_i .ne. 1) STOP 1
++        m_r = MOD(4.0, 3.0)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 2
++        m_r = MOD(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++
++        md_i = MODULO(4, 3)
++        if (md_i .ne. 1) STOP 5
++        md_r = MODULO(4.0, 3.0)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 6
++        md_r = MODULO(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 7
++        md_r = MODULO(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 8
++
++        d_i = DIM(4, 3)
++        if (d_i .ne. 1) STOP 9
++        d_r = DIM(4.0, 3.0)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 10
++        d_r = DIM(4.0, 3) ! { dg-error "'x' and 'y' arguments" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 11
++        d_r = DIM(3, 4.0) ! { dg-error "'x' and 'y' arguments" }
++        if (abs(d_r) > 1.0D-6) STOP 12
++
++        s_i = SIGN(-4, 3)
++        if (s_i .ne. 4) STOP 13
++        s_r = SIGN(4.0, -3.0)
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
++        s_r = SIGN(4.0, -3) ! { dg-error "'b' argument" }
++        if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
++        s_r = SIGN(-4, 3.0) ! { dg-error "'b' argument" }
++        if (abs(s_r - 4.0) > 1.0D-6) STOP 16
++
++        mx_i = MAX(-4, -3, 2, 1)
++        if (mx_i .ne. 2) STOP 17
++        mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
++        mx_r = MAX(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
++        if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 20
++
++        mn_i = MIN(-4, -3, 2, 1)
++        if (mn_i .ne. -4) STOP 21
++        mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
++        mn_r = MIN(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
++        if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 24
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
+new file mode 100644
+index 00000000000..5c2cd931a4b
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
+@@ -0,0 +1,130 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        INTEGER a_i/4/
++        INTEGER*4 a2_i/4/
++        INTEGER b_i/3/
++        INTEGER*8 b2_i/3/
++        INTEGER x_i/2/
++        INTEGER y_i/1/
++        REAL a_r/4.0/
++        REAL*4 a2_r/4.0/
++        REAL b_r/3.0/
++        REAL*8 b2_r/3.0/
++        REAL x_r/2.0/
++        REAL y_r/1.0/
++
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        ! array_nan 4th position value is NAN
++        array_nan(4) = 0/l
++
++        m_i = MOD(a_i, b_i)
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_i, b2_i)
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_r, b_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_r, b2_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_i, b_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_r, b_i)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_i, b_i)
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_i, b2_i)
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_r, b_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_r, b2_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_i, b_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_r, b_i)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_i, b_i)
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_i, b2_i)
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_r, b_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_r, b2_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_r, b_i)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_i, a_r)
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_i, b_i)
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_i, b2_i)
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_r, -b_r)
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
++        s_r = SIGN(a2_r, -b2_r)
++        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
++        s_r = SIGN(a_r, -b_i)
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
++        s_r = SIGN(-a_i, b_r)
++        if (abs(s_r - a_r) > 1.0D-6) STOP 24
++
++        mx_i = MAX(-a_i, -b_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 25
++        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 26
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
++        mx_r = MAX(-a_i, -b_r, x_r, y_i)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 30
++
++        mn_i = MIN(-a_i, -b_i, x_i, y_i)
++        if (mn_i .ne. -a_i) STOP 31
++        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
++        if (mn_i .ne. -a2_i) STOP 32
++        mn_r = MIN(-a_r, -b_r, x_r, y_r)
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
++        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
++        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
++        mn_r = MIN(-a_i, -b_r, x_r, y_i)
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 36
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
+new file mode 100644
+index 00000000000..d64d468f7d1
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
+@@ -0,0 +1,130 @@
++! { dg-do run }
++! { dg-options "-fdec-promotion" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        INTEGER a_i/4/
++        INTEGER*4 a2_i/4/
++        INTEGER b_i/3/
++        INTEGER*8 b2_i/3/
++        INTEGER x_i/2/
++        INTEGER y_i/1/
++        REAL a_r/4.0/
++        REAL*4 a2_r/4.0/
++        REAL b_r/3.0/
++        REAL*8 b2_r/3.0/
++        REAL x_r/2.0/
++        REAL y_r/1.0/
++
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        ! array_nan 4th position value is NAN
++        array_nan(4) = 0/l
++
++        m_i = MOD(a_i, b_i)
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_i, b2_i)
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_r, b_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_r, b2_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_i, b_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_r, b_i)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_i, b_i)
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_i, b2_i)
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_r, b_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_r, b2_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_i, b_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_r, b_i)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_i, b_i)
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_i, b2_i)
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_r, b_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_r, b2_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_r, b_i)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_i, a_r)
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_i, b_i)
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_i, b2_i)
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_r, -b_r)
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
++        s_r = SIGN(a2_r, -b2_r)
++        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
++        s_r = SIGN(a_r, -b_i)
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
++        s_r = SIGN(-a_i, b_r)
++        if (abs(s_r - a_r) > 1.0D-6) STOP 24
++
++        mx_i = MAX(-a_i, -b_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 25
++        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 26
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
++        mx_r = MAX(-a_i, -b_r, x_r, y_i)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 30
++
++        mn_i = MIN(-a_i, -b_i, x_i, y_i)
++        if (mn_i .ne. -a_i) STOP 31
++        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
++        if (mn_i .ne. -a2_i) STOP 32
++        mn_r = MIN(-a_r, -b_r, x_r, y_r)
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
++        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
++        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
++        mn_r = MIN(-a_i, -b_r, x_r, y_i)
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 36
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
+new file mode 100644
+index 00000000000..0708b666633
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
+@@ -0,0 +1,130 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-promotion" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        INTEGER a_i/4/
++        INTEGER*4 a2_i/4/
++        INTEGER b_i/3/
++        INTEGER*8 b2_i/3/
++        INTEGER x_i/2/
++        INTEGER y_i/1/
++        REAL a_r/4.0/
++        REAL*4 a2_r/4.0/
++        REAL b_r/3.0/
++        REAL*8 b2_r/3.0/
++        REAL x_r/2.0/
++        REAL y_r/1.0/
++
++        REAL array_nan(4)
++        DATA array_nan(1)/-4.0/
++        DATA array_nan(2)/3.0/
++        DATA array_nan(3)/-2/
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        ! array_nan 4th position value is NAN
++        array_nan(4) = 0/l
++
++        m_i = MOD(a_i, b_i)
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_i, b2_i)
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_r, b_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_r, b2_r)
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_i, b_i)
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_i, b2_i)
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_r, b_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_r, b2_r)
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_i, b_i)
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_i, b2_i)
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_r, b_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_r, b2_r)
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_r, b_i) ! { dg-error "'x' and 'y' arguments" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_i, a_r) ! { dg-error "'x' and 'y' arguments" }
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_i, b_i)
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_i, b2_i) ! { dg-error "'b' argument" }
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_r, -b_r)
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
++        s_r = SIGN(a2_r, -b2_r) ! { dg-error "'b' argument" }
++        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
++        s_r = SIGN(a_r, -b_i) ! { dg-error "'b' argument" }
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
++        s_r = SIGN(-a_i, b_r) ! { dg-error "'b' argument" }
++        if (abs(s_r - a_r) > 1.0D-6) STOP 24
++
++        mx_i = MAX(-a_i, -b_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 25
++        mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
++        if (mx_i .ne. x_i) STOP 26
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
++        mx_r = MAX(-a_r, -b_r, x_r, y_r)
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
++        mx_r = MAX(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
++        mx_i = MAXLOC(array_nan, 1)
++        if (mx_i .ne. 2) STOP 30
++
++        mn_i = MIN(-a_i, -b_i, x_i, y_i)
++        if (mn_i .ne. -a_i) STOP 31
++        mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
++        if (mn_i .ne. -a2_i) STOP 32
++        mn_r = MIN(-a_r, -b_r, x_r, y_r)
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
++        mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
++        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
++        mn_r = MIN(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
++        mn_i = MINLOC(array_nan, 1)
++        if (mn_i .ne. 1) STOP 36
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
+new file mode 100644
+index 00000000000..efa4f236410
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
+@@ -0,0 +1,118 @@
++! { dg-do compile }
++! { dg-options "-fdec" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        LOGICAL a_l
++        LOGICAL*4 a2_l
++        LOGICAL b_l
++        LOGICAL*8 b2_l
++        LOGICAL x_l
++        LOGICAL y_l
++        CHARACTER a_c
++        CHARACTER*4 a2_c
++        CHARACTER b_c
++        CHARACTER*8 b2_c
++        CHARACTER x_c
++        CHARACTER y_c
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(a_l, b_l)                     ! { dg-error "" }
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_l, b2_l)                   ! { dg-error "" }
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_c, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_c, b2_c)                   ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_l, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_c, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_l, b_l)                 ! { dg-error "" }
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_l, b2_l)               ! { dg-error "" }
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_c, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_c, b2_c)               ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_l, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_c, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_l, b_l)                     ! { dg-error "" }
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_l, b2_l)                   ! { dg-error "" }
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_c, b_c)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_c, b2_c)                   ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_c, b_l)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_l, a_c)                     ! { dg-error "" }
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_l, b_l)                   ! { dg-error "" }
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_l, b2_l)                 ! { dg-error "" }
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_c, -b_c)                   ! { dg-error "" }
++        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
++        s_r = SIGN(a2_c, -b2_c)                 ! { dg-error "" }
++        if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
++        s_r = SIGN(a_c, -b_l)                   ! { dg-error "" }
++        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
++        s_r = SIGN(-a_l, b_c)                   ! { dg-error "" }
++        if (abs(s_r - a_c) > 1.0D-6) STOP 24    ! { dg-error "" }
++
++        mx_i = MAX(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
++        if (mx_i .ne. x_l) STOP 25              ! { dg-error "" }
++        mx_i = MAX(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
++        if (mx_i .ne. x_l) STOP 26              ! { dg-error "" }
++        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 27   ! { dg-error "" }
++        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 28   ! { dg-error "" }
++        mx_r = MAX(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 29   ! { dg-error "" }
++
++        mn_i = MIN(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
++        if (mn_i .ne. -a_l) STOP 31             ! { dg-error "" }
++        mn_i = MIN(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
++        if (mn_i .ne. -a2_l) STOP 32            ! { dg-error "" }
++        mn_r = MIN(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
++        mn_r = MIN(-a2_c, -b2_c, x_c, y_c)      ! { dg-error "" }
++        if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
++        mn_r = MIN(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
++        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
+new file mode 100644
+index 00000000000..d023af5086d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
+@@ -0,0 +1,118 @@
++! { dg-do compile }
++! { dg-options "-fdec-promotion" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        LOGICAL a_l
++        LOGICAL*4 a2_l
++        LOGICAL b_l
++        LOGICAL*8 b2_l
++        LOGICAL x_l
++        LOGICAL y_l
++        CHARACTER a_c
++        CHARACTER*4 a2_c
++        CHARACTER b_c
++        CHARACTER*8 b2_c
++        CHARACTER x_c
++        CHARACTER y_c
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(a_l, b_l)                     ! { dg-error "" }
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_l, b2_l)                   ! { dg-error "" }
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_c, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_c, b2_c)                   ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_l, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_c, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_l, b_l)                 ! { dg-error "" }
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_l, b2_l)               ! { dg-error "" }
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_c, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_c, b2_c)               ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_l, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_c, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_l, b_l)                     ! { dg-error "" }
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_l, b2_l)                   ! { dg-error "" }
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_c, b_c)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_c, b2_c)                   ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_c, b_l)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_l, a_c)                     ! { dg-error "" }
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_l, b_l)                   ! { dg-error "" }
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_l, b2_l)                 ! { dg-error "" }
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_c, -b_c)                   ! { dg-error "" }
++        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
++        s_r = SIGN(a2_c, -b2_c)                 ! { dg-error "" }
++        if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
++        s_r = SIGN(a_c, -b_l)                   ! { dg-error "" }
++        if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
++        s_r = SIGN(-a_l, b_c)                   ! { dg-error "" }
++        if (abs(s_r - a_c) > 1.0D-6) STOP 24    ! { dg-error "" }
++
++        mx_i = MAX(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
++        if (mx_i .ne. x_l) STOP 25              ! { dg-error "" }
++        mx_i = MAX(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
++        if (mx_i .ne. x_l) STOP 26              ! { dg-error "" }
++        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 27   ! { dg-error "" }
++        mx_r = MAX(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 28   ! { dg-error "" }
++        mx_r = MAX(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_c) > 1.0D-6) STOP 29   ! { dg-error "" }
++
++        mn_i = MIN(-a_l, -b_l, x_l, y_l)        ! { dg-error "" }
++        if (mn_i .ne. -a_l) STOP 31             ! { dg-error "" }
++        mn_i = MIN(-a2_l, -b2_l, x_l, y_l)      ! { dg-error "" }
++        if (mn_i .ne. -a2_l) STOP 32            ! { dg-error "" }
++        mn_r = MIN(-a_c, -b_c, x_c, y_c)        ! { dg-error "" }
++        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
++        mn_r = MIN(-a2_c, -b2_c, x_c, y_c)      ! { dg-error "" }
++        if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
++        mn_r = MIN(-a_l, -b_c, x_c, y_l)        ! { dg-error "" }
++        if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
+new file mode 100644
+index 00000000000..00f8fb88f1b
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
+@@ -0,0 +1,118 @@
++! { dg-do compile }
++! { dg-options "-fdec" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        INTEGER a_i/4/
++        INTEGER*4 a2_i/4/
++        CHARACTER b_c
++        CHARACTER*8 b2_c
++        INTEGER x_i/2/
++        CHARACTER y_c
++        REAL a_r/4.0/
++        REAL*4 a2_r/4.0/
++        LOGICAL b_l
++        LOGICAL*8 b2_l
++        REAL x_r/2.0/
++        LOGICAL y_l
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(a_i, b_c)                     ! { dg-error "" }
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_i, b2_c)                   ! { dg-error "" }
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_r, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_r, b2_l)                   ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_i, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_r, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_i, b_c)                 ! { dg-error "" }
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_i, b2_c)               ! { dg-error "" }
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_r, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_r, b2_l)               ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_i, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_r, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_i, b_c)                     ! { dg-error "" }
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_i, b2_c)                   ! { dg-error "" }
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_r, b_l)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_r, b2_l)                   ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_r, b_c)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_c, a_r)                     ! { dg-error "" }
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_i, b_c)                   ! { dg-error "" }
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_i, b2_c)                 ! { dg-error "" }
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_r, -b_l)                   ! { dg-error "" }
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
++        s_r = SIGN(a2_r, -b2_l)                 ! { dg-error "" }
++        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
++        s_r = SIGN(a_r, -b_c)                   ! { dg-error "" }
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
++        s_r = SIGN(-a_i, b_l)                   ! { dg-error "" }
++        if (abs(s_r - a_r) > 1.0D-6) STOP 24
++
++        mx_i = MAX(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
++        if (mx_i .ne. x_i) STOP 25
++        mx_i = MAX(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
++        if (mx_i .ne. x_i) STOP 26
++        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
++        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
++        mx_r = MAX(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
++
++        mn_i = MIN(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
++        if (mn_i .ne. -a_i) STOP 31
++        mn_i = MIN(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
++        if (mn_i .ne. -a2_i) STOP 32
++        mn_r = MIN(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
++        mn_r = MIN(-a2_r, -b2_l, x_r, y_l)      ! { dg-error "" }
++        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
++        mn_r = MIN(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
+new file mode 100644
+index 00000000000..1d4150d81c0
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
+@@ -0,0 +1,118 @@
++! { dg-do compile }
++! { dg-options "-fdec-promotion" }
++!
++! Test promotion between integers and reals in intrinsic operations.
++! These operations are: mod, modulo, dim, sign, min, max, minloc and
++! maxloc.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++!             and Jeff Law <law@redhat.com>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      PROGRAM promotion_int_real
++        REAL l/0.0/
++        INTEGER a_i/4/
++        INTEGER*4 a2_i/4/
++        CHARACTER b_c
++        CHARACTER*8 b2_c
++        INTEGER x_i/2/
++        CHARACTER y_c
++        REAL a_r/4.0/
++        REAL*4 a2_r/4.0/
++        LOGICAL b_l
++        LOGICAL*8 b2_l
++        REAL x_r/2.0/
++        LOGICAL y_l
++
++        INTEGER m_i/0/
++        REAL m_r/0.0/
++
++        INTEGER md_i/0/
++        REAL md_r/0.0/
++
++        INTEGER d_i/0/
++        REAL d_r/0.0/
++
++        INTEGER s_i/0/
++        REAL s_r/0.0/
++
++        INTEGER mn_i/0/
++        REAL mn_r/0.0/
++
++        INTEGER mx_i/0/
++        REAL mx_r/0.0/
++
++        m_i = MOD(a_i, b_c)                     ! { dg-error "" }
++        if (m_i .ne. 1) STOP 1
++        m_i = MOD(a2_i, b2_c)                   ! { dg-error "" }
++        if (m_i .ne. 1) STOP 2
++        m_r = MOD(a_r, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 3
++        m_r = MOD(a2_r, b2_l)                   ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 4
++        m_r = MOD(a_i, b_l)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 5
++        m_r = MOD(a_r, b_c)                     ! { dg-error "" }
++        if (abs(m_r - 1.0) > 1.0D-6) STOP 6
++
++        md_i = MODULO(a_i, b_c)                 ! { dg-error "" }
++        if (md_i .ne. 1) STOP 7
++        md_i = MODULO(a2_i, b2_c)               ! { dg-error "" }
++        if (md_i .ne. 1) STOP 8
++        md_r = MODULO(a_r, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 9
++        md_r = MODULO(a2_r, b2_l)               ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 10
++        md_r = MODULO(a_i, b_l)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 11
++        md_r = MODULO(a_r, b_c)                 ! { dg-error "" }
++        if (abs(md_r - 1.0) > 1.0D-6) STOP 12
++
++        d_i = DIM(a_i, b_c)                     ! { dg-error "" }
++        if (d_i .ne. 1) STOP 13
++        d_i = DIM(a2_i, b2_c)                   ! { dg-error "" }
++        if (d_i .ne. 1) STOP 14
++        d_r = DIM(a_r, b_l)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 15
++        d_r = DIM(a2_r, b2_l)                   ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 16
++        d_r = DIM(a_r, b_c)                     ! { dg-error "" }
++        if (abs(d_r - 1.0) > 1.0D-6) STOP 17
++        d_r = DIM(b_c, a_r)                     ! { dg-error "" }
++        if (abs(d_r) > 1.0D-6) STOP 18
++
++        s_i = SIGN(-a_i, b_c)                   ! { dg-error "" }
++        if (s_i .ne. 4) STOP 19
++        s_i = SIGN(-a2_i, b2_c)                 ! { dg-error "" }
++        if (s_i .ne. 4) STOP 20
++        s_r = SIGN(a_r, -b_l)                   ! { dg-error "" }
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
++        s_r = SIGN(a2_r, -b2_l)                 ! { dg-error "" }
++        if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
++        s_r = SIGN(a_r, -b_c)                   ! { dg-error "" }
++        if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
++        s_r = SIGN(-a_i, b_l)                   ! { dg-error "" }
++        if (abs(s_r - a_r) > 1.0D-6) STOP 24
++
++        mx_i = MAX(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
++        if (mx_i .ne. x_i) STOP 25
++        mx_i = MAX(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
++        if (mx_i .ne. x_i) STOP 26
++        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 27
++        mx_r = MAX(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 28
++        mx_r = MAX(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
++        if (abs(mx_r - x_r) > 1.0D-6) STOP 29
++
++        mn_i = MIN(-a_i, -b_c, x_i, y_c)        ! { dg-error "" }
++        if (mn_i .ne. -a_i) STOP 31
++        mn_i = MIN(-a2_i, -b2_c, x_i, y_c)      ! { dg-error "" }
++        if (mn_i .ne. -a2_i) STOP 32
++        mn_r = MIN(-a_r, -b_l, x_r, y_l)        ! { dg-error "" }
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
++        mn_r = MIN(-a2_r, -b2_l, x_r, y_l)      ! { dg-error "" }
++        if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
++        mn_r = MIN(-a_i, -b_l, x_r, y_c)        ! { dg-error "" }
++        if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
++      END PROGRAM
+diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
+new file mode 100644
+index 00000000000..435bf98350c
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
+@@ -0,0 +1,40 @@
++!{ dg-do run }
++!{ dg-options "-fdec" }
++!
++! integer types of a smaller kind than expected should be
++! accepted by type specific intrinsic functions
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program test_small_type_promtion
++        implicit none
++        integer(1) :: a = 1
++        integer :: i
++        if (iiabs(-9_1).ne.9) stop 1
++        if (iabs(-9_1).ne.9) stop 2
++        if (iabs(-9_2).ne.9) stop 3
++        if (jiabs(-9_1).ne.9) stop 4
++        if (jiabs(-9_2).ne.9) stop 5
++        if (iishft(1_1, 2).ne.4) stop 6
++        if (jishft(1_1, 2).ne.4) stop 7
++        if (jishft(1_2, 2).ne.4) stop 8
++        if (kishft(1_1, 2).ne.4) stop 9
++        if (kishft(1_2, 2).ne.4) stop 10
++        if (kishft(1_4, 2).ne.4) stop 11
++        if (imod(17_1, 3).ne.2) stop 12
++        if (jmod(17_1, 3).ne.2) stop 13
++        if (jmod(17_2, 3).ne.2) stop 14
++        if (kmod(17_1, 3).ne.2) stop 15
++        if (kmod(17_2, 3).ne.2) stop 16
++        if (kmod(17_4, 3).ne.2) stop 17
++        if (inot(5_1).ne.-6) stop 18
++        if (jnot(5_1).ne.-6) stop 19
++        if (jnot(5_2).ne.-6) stop 20
++        if (knot(5_1).ne.-6) stop 21
++        if (knot(5_2).ne.-6) stop 22
++        if (knot(5_4).ne.-6) stop 23
++        if (isign(-77_1, 1).ne.77) stop 24
++        if (isign(-77_1, -1).ne.-77) stop 25
++        if (isign(-77_2, 1).ne.77) stop 26
++        if (isign(-77_2, -1).ne.-77) stop 27
++      end program
+diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
+new file mode 100644
+index 00000000000..7b1697ca665
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
+@@ -0,0 +1,40 @@
++!{ dg-do run }
++!{ dg-options "-fdec-intrinsic-ints -fdec-promotion" }
++!
++! integer types of a smaller kind than expected should be
++! accepted by type specific intrinsic functions
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program test_small_type_promtion
++        implicit none
++        integer(1) :: a = 1
++        integer :: i
++        if (iiabs(-9_1).ne.9) stop 1
++        if (iabs(-9_1).ne.9) stop 2
++        if (iabs(-9_2).ne.9) stop 3
++        if (jiabs(-9_1).ne.9) stop 4
++        if (jiabs(-9_2).ne.9) stop 5
++        if (iishft(1_1, 2).ne.4) stop 6
++        if (jishft(1_1, 2).ne.4) stop 7
++        if (jishft(1_2, 2).ne.4) stop 8
++        if (kishft(1_1, 2).ne.4) stop 9
++        if (kishft(1_2, 2).ne.4) stop 10
++        if (kishft(1_4, 2).ne.4) stop 11
++        if (imod(17_1, 3).ne.2) stop 12
++        if (jmod(17_1, 3).ne.2) stop 13
++        if (jmod(17_2, 3).ne.2) stop 14
++        if (kmod(17_1, 3).ne.2) stop 15
++        if (kmod(17_2, 3).ne.2) stop 16
++        if (kmod(17_4, 3).ne.2) stop 17
++        if (inot(5_1).ne.-6) stop 18
++        if (jnot(5_1).ne.-6) stop 19
++        if (jnot(5_2).ne.-6) stop 20
++        if (knot(5_1).ne.-6) stop 21
++        if (knot(5_2).ne.-6) stop 22
++        if (knot(5_4).ne.-6) stop 23
++        if (isign(-77_1, 1).ne.77) stop 24
++        if (isign(-77_1, -1).ne.-77) stop 25
++        if (isign(-77_2, 1).ne.77) stop 26
++        if (isign(-77_2, -1).ne.-77) stop 27
++      end program
+diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
+new file mode 100644
+index 00000000000..db8dff6c55d
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
+@@ -0,0 +1,39 @@
++!{ dg-do compile }
++!{ dg-options "-fdec -fno-dec-promotion" }
++!
++! integer types of a smaller kind than expected should be
++! accepted by type specific intrinsic functions
++!
++! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
++!
++      program test_small_type_promtion
++        integer(1) :: a = 1
++        integer :: i
++        if (iiabs(-9_1).ne.9) stop 1
++        if (iabs(-9_1).ne.9) stop 2 ! { dg-error "type mismatch in argument" }
++        if (iabs(-9_2).ne.9) stop 3 ! { dg-error "type mismatch in argument" }
++        if (jiabs(-9_1).ne.9) stop 4
++        if (jiabs(-9_2).ne.9) stop 5
++        if (iishft(1_1, 2).ne.4) stop 6
++        if (jishft(1_1, 2).ne.4) stop 7
++        if (jishft(1_2, 2).ne.4) stop 8
++        if (kishft(1_1, 2).ne.4) stop 9
++        if (kishft(1_2, 2).ne.4) stop 10
++        if (kishft(1_4, 2).ne.4) stop 11
++        if (imod(17_1, 3).ne.2) stop 12
++        if (jmod(17_1, 3).ne.2) stop 13
++        if (jmod(17_2, 3).ne.2) stop 14
++        if (kmod(17_1, 3).ne.2) stop 15
++        if (kmod(17_2, 3).ne.2) stop 16
++        if (kmod(17_4, 3).ne.2) stop 17
++        if (inot(5_1).ne.-6) stop 18
++        if (jnot(5_1).ne.-6) stop 19
++        if (jnot(5_2).ne.-6) stop 20
++        if (knot(5_1).ne.-6) stop 21
++        if (knot(5_2).ne.-6) stop 22
++        if (knot(5_4).ne.-6) stop 23
++        if (isign(-77_1, 1).ne.77) stop 24 ! { dg-error "type mismatch in argument" }
++        if (isign(-77_1, -1).ne.-77) stop 25 ! { dg-error "type mismatch in argument" }
++        if (isign(-77_2, 1).ne.77) stop 26 ! { dg-error "type mismatch in argument" }
++        if (isign(-77_2, -1).ne.-77) stop 27 ! { dg-error "type mismatch in argument" }
++      end program
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-fdec-sequence.patch b/gcc12-fortran-fdec-sequence.patch
new file mode 100644
index 0000000..7b9ce71
--- /dev/null
+++ b/gcc12-fortran-fdec-sequence.patch
@@ -0,0 +1,262 @@
+From bb76446db10c21860a4e19569ce3e350d8a2b59f Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 15:00:44 +0000
+Subject: [PATCH 09/10] Add the SEQUENCE attribute by default if it's not
+ present.
+
+Use -fdec-sequence to enable this feature. Also enabled by -fdec.
+---
+ gcc/fortran/lang.opt                          |  4 ++
+ gcc/fortran/options.c                         |  1 +
+ gcc/fortran/resolve.c                         | 13 ++++-
+ ...dd_SEQUENCE_to_COMMON_block_by_default_1.f | 57 +++++++++++++++++++
+ ...dd_SEQUENCE_to_COMMON_block_by_default_2.f | 57 +++++++++++++++++++
+ ...dd_SEQUENCE_to_COMMON_block_by_default_3.f | 57 +++++++++++++++++++
+ 6 files changed, 186 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 4ca2f93f2df..019c798cf09 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -509,6 +509,10 @@ fdec-promotion
+ Fortran Var(flag_dec_promotion)
+ Add support for type promotion in intrinsic arguments.
+ 
++fdec-sequence
++Fortran Var(flag_dec_sequence)
++Add the SEQUENCE attribute by default if it's not present.
++
+ fdec-structure
+ Fortran Var(flag_dec_structure)
+ Enable support for DEC STRUCTURE/RECORD.
+diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
+index 15079c7e95a..050f56fdc25 100644
+--- a/gcc/fortran/options.c
++++ b/gcc/fortran/options.c
+@@ -83,6 +83,7 @@ set_dec_flags (int value)
+   SET_BITFLAG (flag_dec_override_kind, value, value);
+   SET_BITFLAG (flag_dec_non_logical_if, value, value);
+   SET_BITFLAG (flag_dec_promotion, value, value);
++  SET_BITFLAG (flag_dec_sequence, value, value);
+ }
+ 
+ /* Finalize DEC flags.  */
+diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
+index 07dd039f3bf..fe7d0cc5944 100644
+--- a/gcc/fortran/resolve.c
++++ b/gcc/fortran/resolve.c
+@@ -978,9 +978,16 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common)
+ 
+       if (!(csym->ts.u.derived->attr.sequence
+ 	    || csym->ts.u.derived->attr.is_bind_c))
+-	gfc_error_now ("Derived type variable %qs in COMMON at %L "
+-		       "has neither the SEQUENCE nor the BIND(C) "
+-		       "attribute", csym->name, &csym->declared_at);
++	{
++	  if (flag_dec_sequence)
++	    /* Assume sequence. */
++	    csym->ts.u.derived->attr.sequence = 1;
++	  else
++	    gfc_error_now ("Derived type variable '%s' in COMMON at %L "
++			   "has neither the SEQUENCE nor the BIND(C) "
++			   "attribute", csym->name, &csym->declared_at);
++	}
++
+       if (csym->ts.u.derived->attr.alloc_comp)
+ 	gfc_error_now ("Derived type variable %qs in COMMON at %L "
+ 		       "has an ultimate component that is "
+diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
+new file mode 100644
+index 00000000000..fe7b39625eb
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
+@@ -0,0 +1,57 @@
++! { dg-do run }
++! { dg-options "-fdec" }
++!
++! Test add default SEQUENCE attribute derived types appearing in
++! COMMON blocks and EQUIVALENCE statements.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        MODULE SEQ
++          TYPE STRUCT1
++            INTEGER*4     ID
++            INTEGER*4     TYPE
++            INTEGER*8     DEFVAL
++            CHARACTER*(4) NAME
++            LOGICAL*1     NIL
++          END TYPE STRUCT1
++        END MODULE
++
++        SUBROUTINE A
++          USE SEQ
++          TYPE (STRUCT1) S
++          COMMON /BLOCK1/ S
++          IF (S%ID.NE.5) STOP 1
++          IF (S%TYPE.NE.1000) STOP 2
++          IF (S%DEFVAL.NE.-99) STOP 3
++          IF (S%NAME.NE."JANE") STOP 4
++          IF (S%NIL.NEQV..FALSE.) STOP 5
++        END SUBROUTINE
++
++        PROGRAM sequence_att_common
++          USE SEQ
++          IMPLICIT NONE
++          TYPE (STRUCT1) S1
++          TYPE (STRUCT1) S2
++          TYPE (STRUCT1) S3
++
++          EQUIVALENCE (S1,S2)
++          COMMON /BLOCK1/ S3
++
++          S1%ID = 5
++          S1%TYPE = 1000
++          S1%DEFVAL = -99
++          S1%NAME = "JANE"
++          S1%NIL = .FALSE.
++
++          IF (S2%ID.NE.5) STOP 1
++          IF (S2%TYPE.NE.1000) STOP 2
++          IF (S2%DEFVAL.NE.-99) STOP 3
++          IF (S2%NAME.NE."JANE") STOP 4
++          IF (S2%NIL.NEQV..FALSE.) STOP 5
++
++          S3 = S1
++
++          CALL A
++          
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
+new file mode 100644
+index 00000000000..83512f0f3a2
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
+@@ -0,0 +1,57 @@
++! { dg-do run }
++! { dg-options "-fdec-sequence" }
++!
++! Test add default SEQUENCE attribute derived types appearing in
++! COMMON blocks and EQUIVALENCE statements.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        MODULE SEQ
++          TYPE STRUCT1
++            INTEGER*4     ID
++            INTEGER*4     TYPE
++            INTEGER*8     DEFVAL
++            CHARACTER*(4) NAME
++            LOGICAL*1     NIL
++          END TYPE STRUCT1
++        END MODULE
++
++        SUBROUTINE A
++          USE SEQ
++          TYPE (STRUCT1) S
++          COMMON /BLOCK1/ S
++          IF (S%ID.NE.5) STOP 1
++          IF (S%TYPE.NE.1000) STOP 2
++          IF (S%DEFVAL.NE.-99) STOP 3
++          IF (S%NAME.NE."JANE") STOP 4
++          IF (S%NIL.NEQV..FALSE.) STOP 5
++        END SUBROUTINE
++
++        PROGRAM sequence_att_common
++          USE SEQ
++          IMPLICIT NONE
++          TYPE (STRUCT1) S1
++          TYPE (STRUCT1) S2
++          TYPE (STRUCT1) S3
++
++          EQUIVALENCE (S1,S2)
++          COMMON /BLOCK1/ S3
++
++          S1%ID = 5
++          S1%TYPE = 1000
++          S1%DEFVAL = -99
++          S1%NAME = "JANE"
++          S1%NIL = .FALSE.
++
++          IF (S2%ID.NE.5) STOP 1
++          IF (S2%TYPE.NE.1000) STOP 2
++          IF (S2%DEFVAL.NE.-99) STOP 3
++          IF (S2%NAME.NE."JANE") STOP 4
++          IF (S2%NIL.NEQV..FALSE.) STOP 5
++
++          S3 = S1
++
++          CALL A
++          
++        END
+diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
+new file mode 100644
+index 00000000000..26cd59f9090
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
+@@ -0,0 +1,57 @@
++! { dg-do compile }
++! { dg-options "-fdec -fno-dec-sequence" }
++!
++! Test add default SEQUENCE attribute derived types appearing in
++! COMMON blocks and EQUIVALENCE statements.
++!
++! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
++! Modified by Mark Eggleston <mark.eggleston@codethink.com>
++!
++        MODULE SEQ
++          TYPE STRUCT1
++            INTEGER*4     ID
++            INTEGER*4     TYPE
++            INTEGER*8     DEFVAL
++            CHARACTER*(4) NAME
++            LOGICAL*1     NIL
++          END TYPE STRUCT1
++        END MODULE
++
++        SUBROUTINE A
++          USE SEQ
++          TYPE (STRUCT1) S ! { dg-error "Derived type variable" }
++          COMMON /BLOCK1/ S
++          IF (S%ID.NE.5) STOP 1
++          IF (S%TYPE.NE.1000) STOP 2
++          IF (S%DEFVAL.NE.-99) STOP 3
++          IF (S%NAME.NE."JANE") STOP 4
++          IF (S%NIL.NEQV..FALSE.) STOP 5
++        END SUBROUTINE
++
++        PROGRAM sequence_att_common
++          USE SEQ
++          IMPLICIT NONE
++          TYPE (STRUCT1) S1
++          TYPE (STRUCT1) S2
++          TYPE (STRUCT1) S3 ! { dg-error "Derived type variable" }
++
++          EQUIVALENCE (S1,S2) ! { dg-error "Derived type variable" }
++          COMMON /BLOCK1/ S3
++
++          S1%ID = 5
++          S1%TYPE = 1000
++          S1%DEFVAL = -99
++          S1%NAME = "JANE"
++          S1%NIL = .FALSE.
++
++          IF (S2%ID.NE.5) STOP 1
++          IF (S2%TYPE.NE.1000) STOP 2
++          IF (S2%DEFVAL.NE.-99) STOP 3
++          IF (S2%NAME.NE."JANE") STOP 4
++          IF (S2%NIL.NEQV..FALSE.) STOP 5
++
++          S3 = S1
++
++          CALL A
++          
++        END
+-- 
+2.27.0
+

diff --git a/gcc12-fortran-flogical-as-integer.patch b/gcc12-fortran-flogical-as-integer.patch
new file mode 100644
index 0000000..41cbf60
--- /dev/null
+++ b/gcc12-fortran-flogical-as-integer.patch
@@ -0,0 +1,305 @@
+From 9b45f3063dfd2b893e7963a4828c1b0afecdc68a Mon Sep 17 00:00:00 2001
+From: Mark Eggleston <markeggleston@gcc.gnu.org>
+Date: Fri, 22 Jan 2021 12:41:46 +0000
+Subject: [PATCH 02/10] Convert LOGICAL to INTEGER for arithmetic ops, and vice
+ versa
+
+We allow converting LOGICAL types to INTEGER when doing arithmetic
+operations, and converting INTEGER types to LOGICAL for use in
+boolean operations.
+
+This feature is enabled with the -flogical-as-integer flag.
+
+Note: using this feature will disable bitwise logical operations enabled by
+-fdec.
+---
+ gcc/fortran/lang.opt                          |  4 ++
+ gcc/fortran/resolve.c                         | 55 ++++++++++++++++++-
+ .../logical_to_integer_and_vice_versa_1.f     | 31 +++++++++++
+ .../logical_to_integer_and_vice_versa_2.f     | 31 +++++++++++
+ .../logical_to_integer_and_vice_versa_3.f     | 33 +++++++++++
+ .../logical_to_integer_and_vice_versa_4.f     | 33 +++++++++++
+ 6 files changed, 186 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
+ create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
+ create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
+ create mode 100644 gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
+
+diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
+index 52bd522051e..c4da248f07c 100644
+--- a/gcc/fortran/lang.opt
++++ b/gcc/fortran/lang.opt
+@@ -497,6 +497,10 @@ fdec-static
+ Fortran Var(flag_dec_static)
+ Enable DEC-style STATIC and AUTOMATIC attributes.
+ 
++flogical-as-integer
++Fortran Var(flag_logical_as_integer)
++Convert from integer to logical or logical to integer for arithmetic operations.
++
+ fdefault-double-8
+ Fortran Var(flag_default_double)
+ Set the default double precision kind to an 8 byte wide type.
+diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
+index c075d0fa0c4..4b90cb59902 100644
+--- a/gcc/fortran/resolve.c
++++ b/gcc/fortran/resolve.c
+@@ -3915,7 +3915,6 @@ lookup_uop_fuzzy (const char *op, gfc_symtree *uop)
+   return gfc_closest_fuzzy_match (op, candidates);
+ }
+ 
+-
+ /* Callback finding an impure function as an operand to an .and. or
+    .or.  expression.  Remember the last function warned about to
+    avoid double warnings when recursing.  */
+@@ -3975,6 +3974,22 @@ convert_hollerith_to_character (gfc_expr *e)
+     }
+ }
+ 
++/* If E is a logical, convert it to an integer and issue a warning
++   for the conversion.  */
++
++static void
++convert_integer_to_logical (gfc_expr *e)
++{
++  if (e->ts.type == BT_INTEGER)
++    {
++      /* Convert to LOGICAL */
++      gfc_typespec t;
++      t.type = BT_LOGICAL;
++      t.kind = 1;
++      gfc_convert_type_warn (e, &t, 2, 1);
++    }
++}
++
+ /* Convert to numeric and issue a warning for the conversion.  */
+ 
+ static void
+@@ -3987,6 +4002,22 @@ convert_to_numeric (gfc_expr *a, gfc_expr *b)
+   gfc_convert_type_warn (a, &t, 2, 1);
+ }
+ 
++/* If E is a logical, convert it to an integer and issue a warning
++   for the conversion.  */
++
++static void
++convert_logical_to_integer (gfc_expr *e)
++{
++  if (e->ts.type == BT_LOGICAL)
++    {
++      /* Convert to INTEGER */
++      gfc_typespec t;
++      t.type = BT_INTEGER;
++      t.kind = 1;
++      gfc_convert_type_warn (e, &t, 2, 1);
++    }
++}
++
+ /* Resolve an operator expression node.  This can involve replacing the
+    operation with a user defined function call.  */
+ 
+@@ -4072,6 +4103,12 @@ resolve_operator (gfc_expr *e)
+     case INTRINSIC_TIMES:
+     case INTRINSIC_DIVIDE:
+     case INTRINSIC_POWER:
++      if (flag_logical_as_integer)
++	{
++	  convert_logical_to_integer (op1);
++	  convert_logical_to_integer (op2);
++	}
++
+       if (gfc_numeric_ts (&op1->ts) && gfc_numeric_ts (&op2->ts))
+ 	{
+ 	  gfc_type_convert_binary (e, 1);
+@@ -4108,6 +4145,13 @@ resolve_operator (gfc_expr *e)
+     case INTRINSIC_OR:
+     case INTRINSIC_EQV:
+     case INTRINSIC_NEQV:
++
++      if (flag_logical_as_integer)
++	{
++	  convert_integer_to_logical (op1);
++	  convert_integer_to_logical (op2);
++	}
++
+       if (op1->ts.type == BT_LOGICAL && op2->ts.type == BT_LOGICAL)
+ 	{
+ 	  e->ts.type = BT_LOGICAL;
+@@ -4158,6 +4202,9 @@ resolve_operator (gfc_expr *e)
+ 	  goto simplify_op;
+ 	}
+ 
++      if (flag_logical_as_integer)
++	convert_integer_to_logical (op1);
++
+       if (op1->ts.type == BT_LOGICAL)
+ 	{
+ 	  e->ts.type = BT_LOGICAL;
+@@ -4198,6 +4245,12 @@ resolve_operator (gfc_expr *e)
+ 	  convert_hollerith_to_character (op2);
+ 	}
+ 
++      if (flag_logical_as_integer)
++	{
++	  convert_logical_to_integer (op1);
++	  convert_logical_to_integer (op2);
++	}
++
+       if (op1->ts.type == BT_CHARACTER && op2->ts.type == BT_CHARACTER
+ 	  && op1->ts.kind == op2->ts.kind)
+ 	{
+diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
+new file mode 100644
+index 00000000000..938a91d9e9a
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_1.f
+@@ -0,0 +1,31 @@
++! { dg-do run }
++! { dg-options "-std=legacy -flogical-as-integer" }
++!
++! Test conversion between logical and integer for logical operators
++!
++! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
++! Modified for -flogical-as-integer by Mark Eggleston
++! <mark.eggleston@codethink.com>
++!
++        PROGRAM logical_integer_conversion
++          LOGICAL lpos /.true./
++          INTEGER ineg/0/
++          INTEGER ires
++          LOGICAL lres
++
++          ! Test Logicals converted to Integers
++          if ((lpos.AND.ineg).EQ.1) STOP 3
++          if ((ineg.AND.lpos).NE.0) STOP 4
++          ires = (.true..AND.0)
++          if (ires.NE.0) STOP 5
++          ires = (1.AND..false.)
++          if (ires.EQ.1) STOP 6
++
++          ! Test Integers converted to Logicals
++          if (lpos.EQ.ineg) STOP 7
++          if (ineg.EQ.lpos) STOP 8
++          lres = (.true..EQ.0)
++          if (lres) STOP 9
++          lres = (1.EQ..false.)
++          if (lres) STOP 10
++        END
+diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
+new file mode 100644
+index 00000000000..9f146202ba5
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_2.f
+@@ -0,0 +1,31 @@
++! { dg-do compile }
++! { dg-options "-std=legacy -flogical-as-integer -fno-logical-as-integer" }
++!
++! Based on logical_to_integer_and_vice_versa_1.f but with option disabled
++! to test for error messages.
++!
++! Test case contributed by by Mark Eggleston <mark.eggleston@codethink.com>
++!
++!
++        PROGRAM logical_integer_conversion
++          LOGICAL lpos /.true./
++          INTEGER ineg/0/
++          INTEGER ires
++          LOGICAL lres
++
++          ! Test Logicals converted to Integers
++          if ((lpos.AND.ineg).EQ.1) STOP 3 ! { dg-error "Operands of logical operator" }
++          if ((ineg.AND.lpos).NE.0) STOP 4 ! { dg-error "Operands of logical operator" }
++          ires = (.true..AND.0) ! { dg-error "Operands of logical operator" }
++          if (ires.NE.0) STOP 5
++          ires = (1.AND..false.) ! { dg-error "Operands of logical operator" }
++          if (ires.EQ.1) STOP 6
++
++          ! Test Integers converted to Logicals
++          if (lpos.EQ.ineg) STOP 7 ! { dg-error "Operands of comparison operator" }
++          if (ineg.EQ.lpos) STOP 8 ! { dg-error "Operands of comparison operator" }
++          lres = (.true..EQ.0) ! { dg-error "Operands of comparison operator" }
++          if (lres) STOP 9
++          lres = (1.EQ..false.) ! { dg-error "Operands of comparison operator" }
++          if (lres) STOP 10
++        END
+diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
+new file mode 100644
+index 00000000000..446873eb2dc
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_3.f
+@@ -0,0 +1,33 @@
++! { dg-do compile }
++! { dg-options "-std=legacy -flogical-as-integer" }
++!
++! Test conversion between logical and integer for logical operators
++!
++        program test
++          logical f /.false./
++          logical t /.true./
++          real x
++
++          x = 7.7
++          x = x + t*3.0
++          if (abs(x - 10.7).gt.0.00001) stop 1
++          x = x + .false.*5.0
++          if (abs(x - 10.7).gt.0.00001) stop 2
++          x = x - .true.*5.0
++          if (abs(x - 5.7).gt.0.00001) stop 3
++          x = x + t
++          if (abs(x - 6.7).gt.0.00001) stop 4
++          x = x + f
++          if (abs(x - 6.7).gt.0.00001) stop 5
++          x = x - t
++          if (abs(x - 5.7).gt.0.00001) stop 6
++          x = x - f
++          if (abs(x - 5.7).gt.0.00001) stop 7
++          x = x**.true.
++          if (abs(x - 5.7).gt.0.00001) stop 8
++          x = x**.false.
++          if (abs(x - 1.0).gt.0.00001) stop 9
++          x = x/t
++          if (abs(x - 1.0).gt.0.00001) stop 10
++          if ((x/.false.).le.huge(x)) stop 11
++        end
+diff --git a/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
+new file mode 100644
+index 00000000000..4301a4988d8
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/logical_to_integer_and_vice_versa_4.f
+@@ -0,0 +1,33 @@
++! { dg-do compile }
++! { dg-options "-std=legacy -flogical-as-integer -fno-logical-as-integer" }
++!
++! Test conversion between logical and integer for logical operators
++!
++        program test
++          logical f /.false./
++          logical t /.true./
++          real x
++
++          x = 7.7
++          x = x + t*3.0 ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 10.7).gt.0.00001) stop 1
++          x = x + .false.*5.0 ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 10.7).gt.0.00001) stop 2
++          x = x - .true.*5.0 ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 5.7).gt.0.00001) stop 3
++          x = x + t ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 6.7).gt.0.00001) stop 4
++          x = x + f ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 6.7).gt.0.00001) stop 5
++          x = x - t ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 5.7).gt.0.00001) stop 6
++          x = x - f ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 5.7).gt.0.00001) stop 7
++          x = x**.true. ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 5.7).gt.0.00001) stop 8
++          x = x**.false. ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 1.0).gt.0.00001) stop 9
++          x = x/t ! { dg-error "Operands of binary numeric" }
++          if (abs(x - 1.0).gt.0.00001) stop 10
++          if ((x/.false.).le.huge(x)) stop 11 ! { dg-error "Operands of binary numeric" }
++        end
+-- 
+2.27.0
+

diff --git a/gcc12-hack.patch b/gcc12-hack.patch
new file mode 100644
index 0000000..3a5f3f3
--- /dev/null
+++ b/gcc12-hack.patch
@@ -0,0 +1,126 @@
+--- libada/Makefile.in.jj	2019-01-09 13:01:18.015608205 +0100
++++ libada/Makefile.in	2019-01-11 18:16:23.441726931 +0100
+@@ -71,18 +71,40 @@ version := $(shell @get_gcc_base_ver@ $(
+ libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)$(MULTISUBDIR)
+ ADA_RTS_DIR=$(GCC_DIR)/ada/rts$(subst /,_,$(MULTISUBDIR))
+ 
++DEFAULTMULTIFLAGS :=
++ifeq ($(MULTISUBDIR),)
++targ:=$(subst -, ,$(target))
++arch:=$(word 1,$(targ))
++ifeq ($(words $(targ)),2)
++osys:=$(word 2,$(targ))
++else
++osys:=$(word 3,$(targ))
++endif
++ifeq ($(strip $(filter-out i%86 x86_64 powerpc% ppc% s390% sparc% linux%, $(arch) $(osys))),)
++ifeq ($(shell $(CC) $(CFLAGS) -print-multi-os-directory),../lib64)
++DEFAULTMULTIFLAGS := -m64
++else
++ifeq ($(strip $(filter-out s390%, $(arch))),)
++DEFAULTMULTIFLAGS := -m31
++else
++DEFAULTMULTIFLAGS := -m32
++endif
++endif
++endif
++endif
++
+ # exeext should not be used because it's the *host* exeext.  We're building
+ # a *target* library, aren't we?!?  Likewise for CC.  Still, provide bogus
+ # definitions just in case something slips through the safety net provided
+ # by recursive make invocations in gcc/ada/Makefile.in
+ LIBADA_FLAGS_TO_PASS = \
+         "MAKEOVERRIDES=" \
+-        "LDFLAGS=$(LDFLAGS)" \
++        "LDFLAGS=$(LDFLAGS) $(DEFAULTMULTIFLAGS)" \
+         "LN_S=$(LN_S)" \
+         "SHELL=$(SHELL)" \
+-        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \
+-        "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
+-        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \
++        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
++        "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
++        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS) $(DEFAULTMULTIFLAGS)" \
+         "PICFLAG_FOR_TARGET=$(PICFLAG)" \
+         "THREAD_KIND=$(THREAD_KIND)" \
+         "TRACE=$(TRACE)" \
+@@ -93,7 +115,7 @@ LIBADA_FLAGS_TO_PASS = \
+         "exeext=.exeext.should.not.be.used " \
+ 	'CC=the.host.compiler.should.not.be.needed' \
+ 	"GCC_FOR_TARGET=$(CC)" \
+-        "CFLAGS=$(CFLAGS)"
++        "CFLAGS=$(CFLAGS) $(DEFAULTMULTIFLAGS)"
+ 
+ .PHONY: libada gnatlib gnatlib-shared gnatlib-sjlj gnatlib-zcx osconstool
+ 
+--- config-ml.in.jj	2019-01-09 12:50:16.646501448 +0100
++++ config-ml.in	2019-01-11 18:16:23.442726914 +0100
+@@ -511,6 +511,8 @@ multi-do:
+ 				ADAFLAGS="$(ADAFLAGS) $${flags}" \
+ 				prefix="$(prefix)" \
+ 				exec_prefix="$(exec_prefix)" \
++				mandir="$(mandir)" \
++				infodir="$(infodir)" \
+ 				GOCFLAGS="$(GOCFLAGS) $${flags}" \
+ 				GDCFLAGS="$(GDCFLAGS) $${flags}" \
+ 				CXXFLAGS="$(CXXFLAGS) $${flags}" \
+--- libcpp/macro.c.jj	2019-01-09 13:01:21.420552123 +0100
++++ libcpp/macro.c	2019-01-11 18:18:17.736876285 +0100
+@@ -3256,8 +3256,6 @@ static cpp_macro *
+ create_iso_definition (cpp_reader *pfile)
+ {
+   bool following_paste_op = false;
+-  const char *paste_op_error_msg =
+-    N_("'##' cannot appear at either end of a macro expansion");
+   unsigned int num_extra_tokens = 0;
+   unsigned nparms = 0;
+   cpp_hashnode **params = NULL;
+@@ -3382,7 +3380,9 @@ create_iso_definition (cpp_reader *pfile
+ 	     function-like macros, but not at the end.  */
+ 	  if (following_paste_op)
+ 	    {
+-	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
++	      cpp_error (pfile, CPP_DL_ERROR,
++			 "'##' cannot appear at either end of a macro "
++			 "expansion");
+ 	      goto out;
+ 	    }
+ 	  if (!vaopt_tracker.completed ())
+@@ -3397,7 +3397,9 @@ create_iso_definition (cpp_reader *pfile
+ 	     function-like macros, but not at the beginning.  */
+ 	  if (macro->count == 1)
+ 	    {
+-	      cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
++	      cpp_error (pfile, CPP_DL_ERROR,
++			 "'##' cannot appear at either end of a macro "
++			 "expansion");
+ 	      goto out;
+ 	    }
+ 
+--- libcpp/expr.c.jj	2019-01-09 13:01:22.415535734 +0100
++++ libcpp/expr.c	2019-01-11 18:16:23.444726882 +0100
+@@ -803,16 +803,17 @@ cpp_classify_number (cpp_reader *pfile,
+       if ((result & CPP_N_WIDTH) == CPP_N_LARGE
+ 	  && CPP_OPTION (pfile, cpp_warn_long_long))
+         {
+-          const char *message = CPP_OPTION (pfile, cplusplus) 
+-				? N_("use of C++11 long long integer constant")
+-		                : N_("use of C99 long long integer constant");
+-
+ 	  if (CPP_OPTION (pfile, c99))
+             cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location,
+-				   0, message);
++				   0, CPP_OPTION (pfile, cplusplus)
++				      ? N_("use of C++11 long long integer constant")
++				      : N_("use of C99 long long integer constant"));
+           else
+             cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG,
+-				      virtual_location, 0, message);
++				      virtual_location, 0,
++				      CPP_OPTION (pfile, cplusplus)
++				      ? N_("use of C++11 long long integer constant")
++				      : N_("use of C99 long long integer constant"));
+         }
+ 
+       if ((result & CPP_N_SIZE_T) == CPP_N_SIZE_T

diff --git a/gcc12-isl-dl.patch b/gcc12-isl-dl.patch
new file mode 100644
index 0000000..b3982f9
--- /dev/null
+++ b/gcc12-isl-dl.patch
@@ -0,0 +1,716 @@
+--- gcc/Makefile.in.jj	2015-06-06 10:00:25.000000000 +0200
++++ gcc/Makefile.in	2015-11-04 14:56:02.643536437 +0100
+@@ -1063,7 +1063,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+ # and the system's installed libraries.
+ LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
+ 	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+-BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
++BACKENDLIBS = $(if $(ISLLIBS),-ldl) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
+ 	$(ZLIB) $(ZSTD_LIB)
+ # Any system libraries needed just for GNAT.
+ SYSLIBS = @GNAT_LIBEXC@
+@@ -2302,6 +2302,15 @@ $(out_object_file): $(out_file)
+ $(common_out_object_file): $(common_out_file)
+ 	$(COMPILE) $<
+ 	$(POSTCOMPILE)
++
++graphite%.o : \
++  ALL_CFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CFLAGS))
++graphite.o : \
++  ALL_CFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CFLAGS))
++graphite%.o : \
++  ALL_CXXFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CXXFLAGS))
++graphite.o : \
++  ALL_CXXFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CXXFLAGS))
+ #\f
+ # Generate header and source files from the machine description,
+ # and compile them.
+--- gcc/graphite.h.jj	2016-01-27 12:44:06.000000000 +0100
++++ gcc/graphite.h	2016-01-27 13:26:38.309876856 +0100
+@@ -24,6 +24,591 @@ along with GCC; see the file COPYING3.
+ 
+ #include "sese.h"
+ 
++#include <isl/version.h>
++#include <dlfcn.h>
++
++#define DYNSYMS \
++  DYNSYM (isl_aff_add_coefficient_si); \
++  DYNSYM (isl_aff_free); \
++  DYNSYM (isl_aff_get_space); \
++  DYNSYM (isl_aff_set_coefficient_si); \
++  DYNSYM (isl_aff_set_constant_si); \
++  DYNSYM (isl_aff_zero_on_domain); \
++  DYNSYM (isl_band_free); \
++  DYNSYM (isl_band_get_children); \
++  DYNSYM (isl_band_get_partial_schedule); \
++  DYNSYM (isl_band_has_children); \
++  DYNSYM (isl_band_list_free); \
++  DYNSYM (isl_band_list_get_band); \
++  DYNSYM (isl_band_list_get_ctx); \
++  DYNSYM (isl_band_list_n_band); \
++  DYNSYM (isl_band_n_member); \
++  DYNSYM (isl_basic_map_add_constraint); \
++  DYNSYM (isl_basic_map_project_out); \
++  DYNSYM (isl_basic_map_universe); \
++  DYNSYM (isl_constraint_set_coefficient_si); \
++  DYNSYM (isl_constraint_set_constant_si); \
++  DYNSYM (isl_ctx_alloc); \
++  DYNSYM (isl_ctx_free); \
++  DYNSYM (isl_equality_alloc); \
++  DYNSYM (isl_id_alloc); \
++  DYNSYM (isl_id_copy); \
++  DYNSYM (isl_id_free); \
++  DYNSYM (isl_inequality_alloc); \
++  DYNSYM (isl_local_space_copy); \
++  DYNSYM (isl_local_space_free); \
++  DYNSYM (isl_local_space_from_space); \
++  DYNSYM (isl_local_space_range); \
++  DYNSYM (isl_map_add_constraint); \
++  DYNSYM (isl_map_add_dims); \
++  DYNSYM (isl_map_align_params); \
++  DYNSYM (isl_map_apply_range); \
++  DYNSYM (isl_map_copy); \
++  DYNSYM (isl_map_dim); \
++  DYNSYM (isl_map_dump); \
++  DYNSYM (isl_map_equate); \
++  DYNSYM (isl_map_fix_si); \
++  DYNSYM (isl_map_flat_product); \
++  DYNSYM (isl_map_flat_range_product); \
++  DYNSYM (isl_map_free); \
++  DYNSYM (isl_map_from_basic_map); \
++  DYNSYM (isl_map_from_pw_aff); \
++  DYNSYM (isl_map_from_union_map); \
++  DYNSYM (isl_map_get_ctx); \
++  DYNSYM (isl_map_get_space); \
++  DYNSYM (isl_map_get_tuple_id); \
++  DYNSYM (isl_map_insert_dims); \
++  DYNSYM (isl_map_intersect); \
++  DYNSYM (isl_map_intersect_domain); \
++  DYNSYM (isl_map_intersect_range); \
++  DYNSYM (isl_map_is_empty); \
++  DYNSYM (isl_map_lex_ge); \
++  DYNSYM (isl_map_lex_le); \
++  DYNSYM (isl_map_n_out); \
++  DYNSYM (isl_map_range); \
++  DYNSYM (isl_map_set_tuple_id); \
++  DYNSYM (isl_map_universe); \
++  DYNSYM (isl_options_set_on_error); \
++  DYNSYM (isl_options_set_schedule_serialize_sccs); \
++  DYNSYM (isl_printer_set_yaml_style); \
++  DYNSYM (isl_options_set_schedule_max_constant_term); \
++  DYNSYM (isl_options_set_schedule_maximize_band_depth); \
++  DYNSYM (isl_printer_free); \
++  DYNSYM (isl_printer_print_aff); \
++  DYNSYM (isl_printer_print_constraint); \
++  DYNSYM (isl_printer_print_map); \
++  DYNSYM (isl_printer_print_set); \
++  DYNSYM (isl_printer_to_file); \
++  DYNSYM (isl_pw_aff_add); \
++  DYNSYM (isl_pw_aff_alloc); \
++  DYNSYM (isl_pw_aff_copy); \
++  DYNSYM (isl_pw_aff_eq_set); \
++  DYNSYM (isl_pw_aff_free); \
++  DYNSYM (isl_pw_aff_from_aff); \
++  DYNSYM (isl_pw_aff_ge_set); \
++  DYNSYM (isl_pw_aff_gt_set); \
++  DYNSYM (isl_pw_aff_is_cst); \
++  DYNSYM (isl_pw_aff_le_set); \
++  DYNSYM (isl_pw_aff_lt_set); \
++  DYNSYM (isl_pw_aff_mul); \
++  DYNSYM (isl_pw_aff_ne_set); \
++  DYNSYM (isl_pw_aff_nonneg_set); \
++  DYNSYM (isl_pw_aff_set_tuple_id); \
++  DYNSYM (isl_pw_aff_sub); \
++  DYNSYM (isl_pw_aff_zero_set); \
++  DYNSYM (isl_schedule_free); \
++  DYNSYM (isl_schedule_get_band_forest); \
++  DYNSYM (isl_set_add_constraint); \
++  DYNSYM (isl_set_add_dims); \
++  DYNSYM (isl_set_apply); \
++  DYNSYM (isl_set_coalesce); \
++  DYNSYM (isl_set_copy); \
++  DYNSYM (isl_set_dim); \
++  DYNSYM (isl_set_fix_si); \
++  DYNSYM (isl_set_free); \
++  DYNSYM (isl_set_get_space); \
++  DYNSYM (isl_set_get_tuple_id); \
++  DYNSYM (isl_set_intersect); \
++  DYNSYM (isl_set_is_empty); \
++  DYNSYM (isl_set_n_dim); \
++  DYNSYM (isl_set_nat_universe); \
++  DYNSYM (isl_set_project_out); \
++  DYNSYM (isl_set_set_tuple_id); \
++  DYNSYM (isl_set_universe); \
++  DYNSYM (isl_space_add_dims); \
++  DYNSYM (isl_space_alloc); \
++  DYNSYM (isl_space_copy); \
++  DYNSYM (isl_space_dim); \
++  DYNSYM (isl_space_domain); \
++  DYNSYM (isl_space_find_dim_by_id); \
++  DYNSYM (isl_space_free); \
++  DYNSYM (isl_space_from_domain); \
++  DYNSYM (isl_space_get_tuple_id); \
++  DYNSYM (isl_space_params_alloc); \
++  DYNSYM (isl_space_range); \
++  DYNSYM (isl_space_set_alloc); \
++  DYNSYM (isl_space_set_dim_id); \
++  DYNSYM (isl_space_set_tuple_id); \
++  DYNSYM (isl_union_map_add_map); \
++  DYNSYM (isl_union_map_align_params); \
++  DYNSYM (isl_union_map_apply_domain); \
++  DYNSYM (isl_union_map_apply_range); \
++  DYNSYM (isl_union_map_compute_flow); \
++  DYNSYM (isl_union_map_copy); \
++  DYNSYM (isl_union_map_empty); \
++  DYNSYM (isl_union_map_flat_range_product); \
++  DYNSYM (isl_union_map_foreach_map); \
++  DYNSYM (isl_union_map_free); \
++  DYNSYM (isl_union_map_from_map); \
++  DYNSYM (isl_union_map_get_ctx); \
++  DYNSYM (isl_union_map_get_space); \
++  DYNSYM (isl_union_map_gist_domain); \
++  DYNSYM (isl_union_map_gist_range); \
++  DYNSYM (isl_union_map_intersect_domain); \
++  DYNSYM (isl_union_map_is_empty); \
++  DYNSYM (isl_union_map_subtract); \
++  DYNSYM (isl_union_map_union); \
++  DYNSYM (isl_union_set_add_set); \
++  DYNSYM (isl_union_set_compute_schedule); \
++  DYNSYM (isl_union_set_copy); \
++  DYNSYM (isl_union_set_empty); \
++  DYNSYM (isl_union_set_from_set); \
++  DYNSYM (isl_aff_add_constant_val); \
++  DYNSYM (isl_aff_get_coefficient_val); \
++  DYNSYM (isl_aff_get_ctx); \
++  DYNSYM (isl_aff_mod_val); \
++  DYNSYM (isl_ast_build_ast_from_schedule); \
++  DYNSYM (isl_ast_build_free); \
++  DYNSYM (isl_ast_build_from_context); \
++  DYNSYM (isl_ast_build_get_ctx); \
++  DYNSYM (isl_ast_build_get_schedule); \
++  DYNSYM (isl_ast_build_get_schedule_space); \
++  DYNSYM (isl_ast_build_set_before_each_for); \
++  DYNSYM (isl_ast_build_set_options); \
++  DYNSYM (isl_ast_expr_free); \
++  DYNSYM (isl_ast_expr_from_val); \
++  DYNSYM (isl_ast_expr_get_ctx); \
++  DYNSYM (isl_ast_expr_get_id); \
++  DYNSYM (isl_ast_expr_get_op_arg); \
++  DYNSYM (isl_ast_expr_get_op_n_arg); \
++  DYNSYM (isl_ast_expr_get_op_type); \
++  DYNSYM (isl_ast_expr_get_type); \
++  DYNSYM (isl_ast_expr_get_val); \
++  DYNSYM (isl_ast_expr_sub); \
++  DYNSYM (isl_ast_node_block_get_children); \
++  DYNSYM (isl_ast_node_for_get_body); \
++  DYNSYM (isl_ast_node_for_get_cond); \
++  DYNSYM (isl_ast_node_for_get_inc); \
++  DYNSYM (isl_ast_node_for_get_init); \
++  DYNSYM (isl_ast_node_for_get_iterator); \
++  DYNSYM (isl_ast_node_free); \
++  DYNSYM (isl_ast_node_get_annotation); \
++  DYNSYM (isl_ast_node_get_type); \
++  DYNSYM (isl_ast_node_if_get_cond); \
++  DYNSYM (isl_ast_node_if_get_else); \
++  DYNSYM (isl_ast_node_if_get_then); \
++  DYNSYM (isl_ast_node_list_free); \
++  DYNSYM (isl_ast_node_list_get_ast_node); \
++  DYNSYM (isl_ast_node_list_n_ast_node); \
++  DYNSYM (isl_ast_node_user_get_expr); \
++  DYNSYM (isl_constraint_set_coefficient_val); \
++  DYNSYM (isl_constraint_set_constant_val); \
++  DYNSYM (isl_id_get_user); \
++  DYNSYM (isl_local_space_get_ctx); \
++  DYNSYM (isl_map_fix_val); \
++  DYNSYM (isl_options_set_ast_build_atomic_upper_bound); \
++  DYNSYM (isl_printer_print_ast_node); \
++  DYNSYM (isl_printer_print_str); \
++  DYNSYM (isl_printer_set_output_format); \
++  DYNSYM (isl_pw_aff_mod_val); \
++  DYNSYM (isl_schedule_constraints_compute_schedule); \
++  DYNSYM (isl_schedule_constraints_on_domain); \
++  DYNSYM (isl_schedule_constraints_set_coincidence); \
++  DYNSYM (isl_schedule_constraints_set_proximity); \
++  DYNSYM (isl_schedule_constraints_set_validity); \
++  DYNSYM (isl_set_get_dim_id); \
++  DYNSYM (isl_set_max_val); \
++  DYNSYM (isl_set_min_val); \
++  DYNSYM (isl_set_params); \
++  DYNSYM (isl_space_align_params); \
++  DYNSYM (isl_space_map_from_domain_and_range); \
++  DYNSYM (isl_space_set_tuple_name); \
++  DYNSYM (isl_space_wrap); \
++  DYNSYM (isl_union_map_from_domain_and_range); \
++  DYNSYM (isl_union_map_range); \
++  DYNSYM (isl_union_set_union); \
++  DYNSYM (isl_union_set_universe); \
++  DYNSYM (isl_val_2exp); \
++  DYNSYM (isl_val_add_ui); \
++  DYNSYM (isl_val_copy); \
++  DYNSYM (isl_val_free); \
++  DYNSYM (isl_val_int_from_si); \
++  DYNSYM (isl_val_int_from_ui); \
++  DYNSYM (isl_val_mul); \
++  DYNSYM (isl_val_neg); \
++  DYNSYM (isl_val_sub); \
++  DYNSYM (isl_printer_print_union_map); \
++  DYNSYM (isl_pw_aff_get_ctx); \
++  DYNSYM (isl_val_is_int); \
++  DYNSYM (isl_ctx_get_max_operations); \
++  DYNSYM (isl_ctx_set_max_operations); \
++  DYNSYM (isl_ctx_last_error); \
++  DYNSYM (isl_ctx_reset_operations); \
++  DYNSYM (isl_map_coalesce); \
++  DYNSYM (isl_printer_print_schedule); \
++  DYNSYM (isl_set_set_dim_id); \
++  DYNSYM (isl_union_map_coalesce); \
++  DYNSYM (isl_multi_val_set_val); \
++  DYNSYM (isl_multi_val_zero); \
++  DYNSYM (isl_options_set_schedule_max_coefficient); \
++  DYNSYM (isl_options_set_tile_scale_tile_loops); \
++  DYNSYM (isl_schedule_copy); \
++  DYNSYM (isl_schedule_get_map); \
++  DYNSYM (isl_schedule_map_schedule_node_bottom_up); \
++  DYNSYM (isl_schedule_node_band_get_permutable); \
++  DYNSYM (isl_schedule_node_band_get_space); \
++  DYNSYM (isl_schedule_node_band_tile); \
++  DYNSYM (isl_schedule_node_child); \
++  DYNSYM (isl_schedule_node_free); \
++  DYNSYM (isl_schedule_node_get_child); \
++  DYNSYM (isl_schedule_node_get_ctx); \
++  DYNSYM (isl_schedule_node_get_type); \
++  DYNSYM (isl_schedule_node_n_children); \
++  DYNSYM (isl_union_map_is_equal); \
++  DYNSYM (isl_union_access_info_compute_flow); \
++  DYNSYM (isl_union_access_info_from_sink); \
++  DYNSYM (isl_union_access_info_set_may_source); \
++  DYNSYM (isl_union_access_info_set_must_source); \
++  DYNSYM (isl_union_access_info_set_schedule); \
++  DYNSYM (isl_union_flow_free); \
++  DYNSYM (isl_union_flow_get_may_dependence); \
++  DYNSYM (isl_union_flow_get_must_dependence); \
++  DYNSYM (isl_aff_var_on_domain); \
++  DYNSYM (isl_multi_aff_from_aff); \
++  DYNSYM (isl_schedule_get_ctx); \
++  DYNSYM (isl_multi_aff_set_tuple_id); \
++  DYNSYM (isl_multi_aff_dim); \
++  DYNSYM (isl_schedule_get_domain); \
++  DYNSYM (isl_union_set_is_empty); \
++  DYNSYM (isl_union_set_get_space); \
++  DYNSYM (isl_union_pw_multi_aff_empty); \
++  DYNSYM (isl_union_set_foreach_set); \
++  DYNSYM (isl_union_set_free); \
++  DYNSYM (isl_multi_union_pw_aff_from_union_pw_multi_aff); \
++  DYNSYM (isl_multi_union_pw_aff_apply_multi_aff); \
++  DYNSYM (isl_schedule_insert_partial_schedule); \
++  DYNSYM (isl_union_pw_multi_aff_free); \
++  DYNSYM (isl_pw_multi_aff_project_out_map); \
++  DYNSYM (isl_union_pw_multi_aff_add_pw_multi_aff); \
++  DYNSYM (isl_schedule_from_domain); \
++  DYNSYM (isl_schedule_sequence); \
++  DYNSYM (isl_ast_build_node_from_schedule); \
++  DYNSYM (isl_ast_node_mark_get_node); \
++  DYNSYM (isl_schedule_node_band_member_get_ast_loop_type); \
++  DYNSYM (isl_schedule_node_band_member_set_ast_loop_type); \
++  DYNSYM (isl_val_n_abs_num_chunks); \
++  DYNSYM (isl_val_get_abs_num_chunks); \
++  DYNSYM (isl_val_int_from_chunks); \
++  DYNSYM (isl_val_is_neg); \
++  DYNSYM (isl_version); \
++  DYNSYM (isl_options_get_on_error); \
++  DYNSYM (isl_ctx_reset_error);
++
++extern struct isl_pointers_s__
++{
++  bool inited;
++  void *h;
++#define DYNSYM(x) __typeof (x) *p_##x
++  DYNSYMS
++#undef DYNSYM
++} isl_pointers__;
++
++#define isl_aff_add_coefficient_si (*isl_pointers__.p_isl_aff_add_coefficient_si)
++#define isl_aff_free (*isl_pointers__.p_isl_aff_free)
++#define isl_aff_get_space (*isl_pointers__.p_isl_aff_get_space)
++#define isl_aff_set_coefficient_si (*isl_pointers__.p_isl_aff_set_coefficient_si)
++#define isl_aff_set_constant_si (*isl_pointers__.p_isl_aff_set_constant_si)
++#define isl_aff_zero_on_domain (*isl_pointers__.p_isl_aff_zero_on_domain)
++#define isl_band_free (*isl_pointers__.p_isl_band_free)
++#define isl_band_get_children (*isl_pointers__.p_isl_band_get_children)
++#define isl_band_get_partial_schedule (*isl_pointers__.p_isl_band_get_partial_schedule)
++#define isl_band_has_children (*isl_pointers__.p_isl_band_has_children)
++#define isl_band_list_free (*isl_pointers__.p_isl_band_list_free)
++#define isl_band_list_get_band (*isl_pointers__.p_isl_band_list_get_band)
++#define isl_band_list_get_ctx (*isl_pointers__.p_isl_band_list_get_ctx)
++#define isl_band_list_n_band (*isl_pointers__.p_isl_band_list_n_band)
++#define isl_band_n_member (*isl_pointers__.p_isl_band_n_member)
++#define isl_basic_map_add_constraint (*isl_pointers__.p_isl_basic_map_add_constraint)
++#define isl_basic_map_project_out (*isl_pointers__.p_isl_basic_map_project_out)
++#define isl_basic_map_universe (*isl_pointers__.p_isl_basic_map_universe)
++#define isl_constraint_set_coefficient_si (*isl_pointers__.p_isl_constraint_set_coefficient_si)
++#define isl_constraint_set_constant_si (*isl_pointers__.p_isl_constraint_set_constant_si)
++#define isl_ctx_alloc (*isl_pointers__.p_isl_ctx_alloc)
++#define isl_ctx_free (*isl_pointers__.p_isl_ctx_free)
++#define isl_equality_alloc (*isl_pointers__.p_isl_equality_alloc)
++#define isl_id_alloc (*isl_pointers__.p_isl_id_alloc)
++#define isl_id_copy (*isl_pointers__.p_isl_id_copy)
++#define isl_id_free (*isl_pointers__.p_isl_id_free)
++#define isl_inequality_alloc (*isl_pointers__.p_isl_inequality_alloc)
++#define isl_local_space_copy (*isl_pointers__.p_isl_local_space_copy)
++#define isl_local_space_free (*isl_pointers__.p_isl_local_space_free)
++#define isl_local_space_from_space (*isl_pointers__.p_isl_local_space_from_space)
++#define isl_local_space_range (*isl_pointers__.p_isl_local_space_range)
++#define isl_map_add_constraint (*isl_pointers__.p_isl_map_add_constraint)
++#define isl_map_add_dims (*isl_pointers__.p_isl_map_add_dims)
++#define isl_map_align_params (*isl_pointers__.p_isl_map_align_params)
++#define isl_map_apply_range (*isl_pointers__.p_isl_map_apply_range)
++#define isl_map_copy (*isl_pointers__.p_isl_map_copy)
++#define isl_map_dim (*isl_pointers__.p_isl_map_dim)
++#define isl_map_dump (*isl_pointers__.p_isl_map_dump)
++#define isl_map_equate (*isl_pointers__.p_isl_map_equate)
++#define isl_map_fix_si (*isl_pointers__.p_isl_map_fix_si)
++#define isl_map_flat_product (*isl_pointers__.p_isl_map_flat_product)
++#define isl_map_flat_range_product (*isl_pointers__.p_isl_map_flat_range_product)
++#define isl_map_free (*isl_pointers__.p_isl_map_free)
++#define isl_map_from_basic_map (*isl_pointers__.p_isl_map_from_basic_map)
++#define isl_map_from_pw_aff (*isl_pointers__.p_isl_map_from_pw_aff)
++#define isl_map_from_union_map (*isl_pointers__.p_isl_map_from_union_map)
++#define isl_map_get_ctx (*isl_pointers__.p_isl_map_get_ctx)
++#define isl_map_get_space (*isl_pointers__.p_isl_map_get_space)
++#define isl_map_get_tuple_id (*isl_pointers__.p_isl_map_get_tuple_id)
++#define isl_map_insert_dims (*isl_pointers__.p_isl_map_insert_dims)
++#define isl_map_intersect (*isl_pointers__.p_isl_map_intersect)
++#define isl_map_intersect_domain (*isl_pointers__.p_isl_map_intersect_domain)
++#define isl_map_intersect_range (*isl_pointers__.p_isl_map_intersect_range)
++#define isl_map_is_empty (*isl_pointers__.p_isl_map_is_empty)
++#define isl_map_lex_ge (*isl_pointers__.p_isl_map_lex_ge)
++#define isl_map_lex_le (*isl_pointers__.p_isl_map_lex_le)
++#define isl_map_n_out (*isl_pointers__.p_isl_map_n_out)
++#define isl_map_range (*isl_pointers__.p_isl_map_range)
++#define isl_map_set_tuple_id (*isl_pointers__.p_isl_map_set_tuple_id)
++#define isl_map_universe (*isl_pointers__.p_isl_map_universe)
++#define isl_options_set_on_error (*isl_pointers__.p_isl_options_set_on_error)
++#define isl_options_set_schedule_serialize_sccs (*isl_pointers__.p_isl_options_set_schedule_serialize_sccs)
++#define isl_printer_set_yaml_style (*isl_pointers__.p_isl_printer_set_yaml_style)
++#define isl_options_set_schedule_max_constant_term (*isl_pointers__.p_isl_options_set_schedule_max_constant_term)
++#define isl_options_set_schedule_maximize_band_depth (*isl_pointers__.p_isl_options_set_schedule_maximize_band_depth)
++#define isl_printer_free (*isl_pointers__.p_isl_printer_free)
++#define isl_printer_print_aff (*isl_pointers__.p_isl_printer_print_aff)
++#define isl_printer_print_constraint (*isl_pointers__.p_isl_printer_print_constraint)
++#define isl_printer_print_map (*isl_pointers__.p_isl_printer_print_map)
++#define isl_printer_print_set (*isl_pointers__.p_isl_printer_print_set)
++#define isl_printer_to_file (*isl_pointers__.p_isl_printer_to_file)
++#define isl_pw_aff_add (*isl_pointers__.p_isl_pw_aff_add)
++#define isl_pw_aff_alloc (*isl_pointers__.p_isl_pw_aff_alloc)
++#define isl_pw_aff_copy (*isl_pointers__.p_isl_pw_aff_copy)
++#define isl_pw_aff_eq_set (*isl_pointers__.p_isl_pw_aff_eq_set)
++#define isl_pw_aff_free (*isl_pointers__.p_isl_pw_aff_free)
++#define isl_pw_aff_from_aff (*isl_pointers__.p_isl_pw_aff_from_aff)
++#define isl_pw_aff_ge_set (*isl_pointers__.p_isl_pw_aff_ge_set)
++#define isl_pw_aff_gt_set (*isl_pointers__.p_isl_pw_aff_gt_set)
++#define isl_pw_aff_is_cst (*isl_pointers__.p_isl_pw_aff_is_cst)
++#define isl_pw_aff_le_set (*isl_pointers__.p_isl_pw_aff_le_set)
++#define isl_pw_aff_lt_set (*isl_pointers__.p_isl_pw_aff_lt_set)
++#define isl_pw_aff_mul (*isl_pointers__.p_isl_pw_aff_mul)
++#define isl_pw_aff_ne_set (*isl_pointers__.p_isl_pw_aff_ne_set)
++#define isl_pw_aff_nonneg_set (*isl_pointers__.p_isl_pw_aff_nonneg_set)
++#define isl_pw_aff_set_tuple_id (*isl_pointers__.p_isl_pw_aff_set_tuple_id)
++#define isl_pw_aff_sub (*isl_pointers__.p_isl_pw_aff_sub)
++#define isl_pw_aff_zero_set (*isl_pointers__.p_isl_pw_aff_zero_set)
++#define isl_schedule_free (*isl_pointers__.p_isl_schedule_free)
++#define isl_schedule_get_band_forest (*isl_pointers__.p_isl_schedule_get_band_forest)
++#define isl_set_add_constraint (*isl_pointers__.p_isl_set_add_constraint)
++#define isl_set_add_dims (*isl_pointers__.p_isl_set_add_dims)
++#define isl_set_apply (*isl_pointers__.p_isl_set_apply)
++#define isl_set_coalesce (*isl_pointers__.p_isl_set_coalesce)
++#define isl_set_copy (*isl_pointers__.p_isl_set_copy)
++#define isl_set_dim (*isl_pointers__.p_isl_set_dim)
++#define isl_set_fix_si (*isl_pointers__.p_isl_set_fix_si)
++#define isl_set_free (*isl_pointers__.p_isl_set_free)
++#define isl_set_get_space (*isl_pointers__.p_isl_set_get_space)
++#define isl_set_get_tuple_id (*isl_pointers__.p_isl_set_get_tuple_id)
++#define isl_set_intersect (*isl_pointers__.p_isl_set_intersect)
++#define isl_set_is_empty (*isl_pointers__.p_isl_set_is_empty)
++#define isl_set_n_dim (*isl_pointers__.p_isl_set_n_dim)
++#define isl_set_nat_universe (*isl_pointers__.p_isl_set_nat_universe)
++#define isl_set_project_out (*isl_pointers__.p_isl_set_project_out)
++#define isl_set_set_tuple_id (*isl_pointers__.p_isl_set_set_tuple_id)
++#define isl_set_universe (*isl_pointers__.p_isl_set_universe)
++#define isl_space_add_dims (*isl_pointers__.p_isl_space_add_dims)
++#define isl_space_alloc (*isl_pointers__.p_isl_space_alloc)
++#define isl_space_copy (*isl_pointers__.p_isl_space_copy)
++#define isl_space_dim (*isl_pointers__.p_isl_space_dim)
++#define isl_space_domain (*isl_pointers__.p_isl_space_domain)
++#define isl_space_find_dim_by_id (*isl_pointers__.p_isl_space_find_dim_by_id)
++#define isl_space_free (*isl_pointers__.p_isl_space_free)
++#define isl_space_from_domain (*isl_pointers__.p_isl_space_from_domain)
++#define isl_space_get_tuple_id (*isl_pointers__.p_isl_space_get_tuple_id)
++#define isl_space_params_alloc (*isl_pointers__.p_isl_space_params_alloc)
++#define isl_space_range (*isl_pointers__.p_isl_space_range)
++#define isl_space_set_alloc (*isl_pointers__.p_isl_space_set_alloc)
++#define isl_space_set_dim_id (*isl_pointers__.p_isl_space_set_dim_id)
++#define isl_space_set_tuple_id (*isl_pointers__.p_isl_space_set_tuple_id)
++#define isl_union_map_add_map (*isl_pointers__.p_isl_union_map_add_map)
++#define isl_union_map_align_params (*isl_pointers__.p_isl_union_map_align_params)
++#define isl_union_map_apply_domain (*isl_pointers__.p_isl_union_map_apply_domain)
++#define isl_union_map_apply_range (*isl_pointers__.p_isl_union_map_apply_range)
++#define isl_union_map_compute_flow (*isl_pointers__.p_isl_union_map_compute_flow)
++#define isl_union_map_copy (*isl_pointers__.p_isl_union_map_copy)
++#define isl_union_map_empty (*isl_pointers__.p_isl_union_map_empty)
++#define isl_union_map_flat_range_product (*isl_pointers__.p_isl_union_map_flat_range_product)
++#define isl_union_map_foreach_map (*isl_pointers__.p_isl_union_map_foreach_map)
++#define isl_union_map_free (*isl_pointers__.p_isl_union_map_free)
++#define isl_union_map_from_map (*isl_pointers__.p_isl_union_map_from_map)
++#define isl_union_map_get_ctx (*isl_pointers__.p_isl_union_map_get_ctx)
++#define isl_union_map_get_space (*isl_pointers__.p_isl_union_map_get_space)
++#define isl_union_map_gist_domain (*isl_pointers__.p_isl_union_map_gist_domain)
++#define isl_union_map_gist_range (*isl_pointers__.p_isl_union_map_gist_range)
++#define isl_union_map_intersect_domain (*isl_pointers__.p_isl_union_map_intersect_domain)
++#define isl_union_map_is_empty (*isl_pointers__.p_isl_union_map_is_empty)
++#define isl_union_map_subtract (*isl_pointers__.p_isl_union_map_subtract)
++#define isl_union_map_union (*isl_pointers__.p_isl_union_map_union)
++#define isl_union_set_add_set (*isl_pointers__.p_isl_union_set_add_set)
++#define isl_union_set_compute_schedule (*isl_pointers__.p_isl_union_set_compute_schedule)
++#define isl_union_set_copy (*isl_pointers__.p_isl_union_set_copy)
++#define isl_union_set_empty (*isl_pointers__.p_isl_union_set_empty)
++#define isl_union_set_from_set (*isl_pointers__.p_isl_union_set_from_set)
++#define isl_aff_add_constant_val (*isl_pointers__.p_isl_aff_add_constant_val)
++#define isl_aff_get_coefficient_val (*isl_pointers__.p_isl_aff_get_coefficient_val)
++#define isl_aff_get_ctx (*isl_pointers__.p_isl_aff_get_ctx)
++#define isl_aff_mod_val (*isl_pointers__.p_isl_aff_mod_val)
++#define isl_ast_build_ast_from_schedule (*isl_pointers__.p_isl_ast_build_ast_from_schedule)
++#define isl_ast_build_free (*isl_pointers__.p_isl_ast_build_free)
++#define isl_ast_build_from_context (*isl_pointers__.p_isl_ast_build_from_context)
++#define isl_ast_build_get_ctx (*isl_pointers__.p_isl_ast_build_get_ctx)
++#define isl_ast_build_get_schedule (*isl_pointers__.p_isl_ast_build_get_schedule)
++#define isl_ast_build_get_schedule_space (*isl_pointers__.p_isl_ast_build_get_schedule_space)
++#define isl_ast_build_set_before_each_for (*isl_pointers__.p_isl_ast_build_set_before_each_for)
++#define isl_ast_build_set_options (*isl_pointers__.p_isl_ast_build_set_options)
++#define isl_ast_expr_free (*isl_pointers__.p_isl_ast_expr_free)
++#define isl_ast_expr_from_val (*isl_pointers__.p_isl_ast_expr_from_val)
++#define isl_ast_expr_get_ctx (*isl_pointers__.p_isl_ast_expr_get_ctx)
++#define isl_ast_expr_get_id (*isl_pointers__.p_isl_ast_expr_get_id)
++#define isl_ast_expr_get_op_arg (*isl_pointers__.p_isl_ast_expr_get_op_arg)
++#define isl_ast_expr_get_op_n_arg (*isl_pointers__.p_isl_ast_expr_get_op_n_arg)
++#define isl_ast_expr_get_op_type (*isl_pointers__.p_isl_ast_expr_get_op_type)
++#define isl_ast_expr_get_type (*isl_pointers__.p_isl_ast_expr_get_type)
++#define isl_ast_expr_get_val (*isl_pointers__.p_isl_ast_expr_get_val)
++#define isl_ast_expr_sub (*isl_pointers__.p_isl_ast_expr_sub)
++#define isl_ast_node_block_get_children (*isl_pointers__.p_isl_ast_node_block_get_children)
++#define isl_ast_node_for_get_body (*isl_pointers__.p_isl_ast_node_for_get_body)
++#define isl_ast_node_for_get_cond (*isl_pointers__.p_isl_ast_node_for_get_cond)
++#define isl_ast_node_for_get_inc (*isl_pointers__.p_isl_ast_node_for_get_inc)
++#define isl_ast_node_for_get_init (*isl_pointers__.p_isl_ast_node_for_get_init)
++#define isl_ast_node_for_get_iterator (*isl_pointers__.p_isl_ast_node_for_get_iterator)
++#define isl_ast_node_free (*isl_pointers__.p_isl_ast_node_free)
++#define isl_ast_node_get_annotation (*isl_pointers__.p_isl_ast_node_get_annotation)
++#define isl_ast_node_get_type (*isl_pointers__.p_isl_ast_node_get_type)
++#define isl_ast_node_if_get_cond (*isl_pointers__.p_isl_ast_node_if_get_cond)
++#define isl_ast_node_if_get_else (*isl_pointers__.p_isl_ast_node_if_get_else)
++#define isl_ast_node_if_get_then (*isl_pointers__.p_isl_ast_node_if_get_then)
++#define isl_ast_node_list_free (*isl_pointers__.p_isl_ast_node_list_free)
++#define isl_ast_node_list_get_ast_node (*isl_pointers__.p_isl_ast_node_list_get_ast_node)
++#define isl_ast_node_list_n_ast_node (*isl_pointers__.p_isl_ast_node_list_n_ast_node)
++#define isl_ast_node_user_get_expr (*isl_pointers__.p_isl_ast_node_user_get_expr)
++#define isl_constraint_set_coefficient_val (*isl_pointers__.p_isl_constraint_set_coefficient_val)
++#define isl_constraint_set_constant_val (*isl_pointers__.p_isl_constraint_set_constant_val)
++#define isl_id_get_user (*isl_pointers__.p_isl_id_get_user)
++#define isl_local_space_get_ctx (*isl_pointers__.p_isl_local_space_get_ctx)
++#define isl_map_fix_val (*isl_pointers__.p_isl_map_fix_val)
++#define isl_options_set_ast_build_atomic_upper_bound (*isl_pointers__.p_isl_options_set_ast_build_atomic_upper_bound)
++#define isl_printer_print_ast_node (*isl_pointers__.p_isl_printer_print_ast_node)
++#define isl_printer_print_str (*isl_pointers__.p_isl_printer_print_str)
++#define isl_printer_set_output_format (*isl_pointers__.p_isl_printer_set_output_format)
++#define isl_pw_aff_mod_val (*isl_pointers__.p_isl_pw_aff_mod_val)
++#define isl_schedule_constraints_compute_schedule (*isl_pointers__.p_isl_schedule_constraints_compute_schedule)
++#define isl_schedule_constraints_on_domain (*isl_pointers__.p_isl_schedule_constraints_on_domain)
++#define isl_schedule_constraints_set_coincidence (*isl_pointers__.p_isl_schedule_constraints_set_coincidence)
++#define isl_schedule_constraints_set_proximity (*isl_pointers__.p_isl_schedule_constraints_set_proximity)
++#define isl_schedule_constraints_set_validity (*isl_pointers__.p_isl_schedule_constraints_set_validity)
++#define isl_set_get_dim_id (*isl_pointers__.p_isl_set_get_dim_id)
++#define isl_set_max_val (*isl_pointers__.p_isl_set_max_val)
++#define isl_set_min_val (*isl_pointers__.p_isl_set_min_val)
++#define isl_set_params (*isl_pointers__.p_isl_set_params)
++#define isl_space_align_params (*isl_pointers__.p_isl_space_align_params)
++#define isl_space_map_from_domain_and_range (*isl_pointers__.p_isl_space_map_from_domain_and_range)
++#define isl_space_set_tuple_name (*isl_pointers__.p_isl_space_set_tuple_name)
++#define isl_space_wrap (*isl_pointers__.p_isl_space_wrap)
++#define isl_union_map_from_domain_and_range (*isl_pointers__.p_isl_union_map_from_domain_and_range)
++#define isl_union_map_range (*isl_pointers__.p_isl_union_map_range)
++#define isl_union_set_union (*isl_pointers__.p_isl_union_set_union)
++#define isl_union_set_universe (*isl_pointers__.p_isl_union_set_universe)
++#define isl_val_2exp (*isl_pointers__.p_isl_val_2exp)
++#define isl_val_add_ui (*isl_pointers__.p_isl_val_add_ui)
++#define isl_val_copy (*isl_pointers__.p_isl_val_copy)
++#define isl_val_free (*isl_pointers__.p_isl_val_free)
++#define isl_val_int_from_si (*isl_pointers__.p_isl_val_int_from_si)
++#define isl_val_int_from_ui (*isl_pointers__.p_isl_val_int_from_ui)
++#define isl_val_mul (*isl_pointers__.p_isl_val_mul)
++#define isl_val_neg (*isl_pointers__.p_isl_val_neg)
++#define isl_val_sub (*isl_pointers__.p_isl_val_sub)
++#define isl_printer_print_union_map (*isl_pointers__.p_isl_printer_print_union_map)
++#define isl_pw_aff_get_ctx (*isl_pointers__.p_isl_pw_aff_get_ctx)
++#define isl_val_is_int (*isl_pointers__.p_isl_val_is_int)
++#define isl_ctx_get_max_operations (*isl_pointers__.p_isl_ctx_get_max_operations)
++#define isl_ctx_set_max_operations (*isl_pointers__.p_isl_ctx_set_max_operations)
++#define isl_ctx_last_error (*isl_pointers__.p_isl_ctx_last_error)
++#define isl_ctx_reset_operations (*isl_pointers__.p_isl_ctx_reset_operations)
++#define isl_map_coalesce (*isl_pointers__.p_isl_map_coalesce)
++#define isl_printer_print_schedule (*isl_pointers__.p_isl_printer_print_schedule)
++#define isl_set_set_dim_id (*isl_pointers__.p_isl_set_set_dim_id)
++#define isl_union_map_coalesce (*isl_pointers__.p_isl_union_map_coalesce)
++#define isl_multi_val_set_val (*isl_pointers__.p_isl_multi_val_set_val)
++#define isl_multi_val_zero (*isl_pointers__.p_isl_multi_val_zero)
++#define isl_options_set_schedule_max_coefficient (*isl_pointers__.p_isl_options_set_schedule_max_coefficient)
++#define isl_options_set_tile_scale_tile_loops (*isl_pointers__.p_isl_options_set_tile_scale_tile_loops)
++#define isl_schedule_copy (*isl_pointers__.p_isl_schedule_copy)
++#define isl_schedule_get_map (*isl_pointers__.p_isl_schedule_get_map)
++#define isl_schedule_map_schedule_node_bottom_up (*isl_pointers__.p_isl_schedule_map_schedule_node_bottom_up)
++#define isl_schedule_node_band_get_permutable (*isl_pointers__.p_isl_schedule_node_band_get_permutable)
++#define isl_schedule_node_band_get_space (*isl_pointers__.p_isl_schedule_node_band_get_space)
++#define isl_schedule_node_band_tile (*isl_pointers__.p_isl_schedule_node_band_tile)
++#define isl_schedule_node_child (*isl_pointers__.p_isl_schedule_node_child)
++#define isl_schedule_node_free (*isl_pointers__.p_isl_schedule_node_free)
++#define isl_schedule_node_get_child (*isl_pointers__.p_isl_schedule_node_get_child)
++#define isl_schedule_node_get_ctx (*isl_pointers__.p_isl_schedule_node_get_ctx)
++#define isl_schedule_node_get_type (*isl_pointers__.p_isl_schedule_node_get_type)
++#define isl_schedule_node_n_children (*isl_pointers__.p_isl_schedule_node_n_children)
++#define isl_union_map_is_equal (*isl_pointers__.p_isl_union_map_is_equal)
++#define isl_union_access_info_compute_flow (*isl_pointers__.p_isl_union_access_info_compute_flow)
++#define isl_union_access_info_from_sink (*isl_pointers__.p_isl_union_access_info_from_sink)
++#define isl_union_access_info_set_may_source (*isl_pointers__.p_isl_union_access_info_set_may_source)
++#define isl_union_access_info_set_must_source (*isl_pointers__.p_isl_union_access_info_set_must_source)
++#define isl_union_access_info_set_schedule (*isl_pointers__.p_isl_union_access_info_set_schedule)
++#define isl_union_flow_free (*isl_pointers__.p_isl_union_flow_free)
++#define isl_union_flow_get_may_dependence (*isl_pointers__.p_isl_union_flow_get_may_dependence)
++#define isl_union_flow_get_must_dependence (*isl_pointers__.p_isl_union_flow_get_must_dependence)
++#define isl_aff_var_on_domain (*isl_pointers__.p_isl_aff_var_on_domain)
++#define isl_multi_aff_from_aff (*isl_pointers__.p_isl_multi_aff_from_aff)
++#define isl_schedule_get_ctx (*isl_pointers__.p_isl_schedule_get_ctx)
++#define isl_multi_aff_set_tuple_id (*isl_pointers__.p_isl_multi_aff_set_tuple_id)
++#define isl_multi_aff_dim (*isl_pointers__.p_isl_multi_aff_dim)
++#define isl_schedule_get_domain (*isl_pointers__.p_isl_schedule_get_domain)
++#define isl_union_set_is_empty (*isl_pointers__.p_isl_union_set_is_empty)
++#define isl_union_set_get_space (*isl_pointers__.p_isl_union_set_get_space)
++#define isl_union_pw_multi_aff_empty (*isl_pointers__.p_isl_union_pw_multi_aff_empty)
++#define isl_union_set_foreach_set (*isl_pointers__.p_isl_union_set_foreach_set)
++#define isl_union_set_free (*isl_pointers__.p_isl_union_set_free)
++#define isl_multi_union_pw_aff_from_union_pw_multi_aff (*isl_pointers__.p_isl_multi_union_pw_aff_from_union_pw_multi_aff)
++#define isl_multi_union_pw_aff_apply_multi_aff (*isl_pointers__.p_isl_multi_union_pw_aff_apply_multi_aff)
++#define isl_schedule_insert_partial_schedule (*isl_pointers__.p_isl_schedule_insert_partial_schedule)
++#define isl_union_pw_multi_aff_free (*isl_pointers__.p_isl_union_pw_multi_aff_free)
++#define isl_pw_multi_aff_project_out_map (*isl_pointers__.p_isl_pw_multi_aff_project_out_map)
++#define isl_union_pw_multi_aff_add_pw_multi_aff (*isl_pointers__.p_isl_union_pw_multi_aff_add_pw_multi_aff)
++#define isl_schedule_from_domain (*isl_pointers__.p_isl_schedule_from_domain)
++#define isl_schedule_sequence (*isl_pointers__.p_isl_schedule_sequence)
++#define isl_ast_build_node_from_schedule (*isl_pointers__.p_isl_ast_build_node_from_schedule)
++#define isl_ast_node_mark_get_node (*isl_pointers__.p_isl_ast_node_mark_get_node)
++#define isl_schedule_node_band_member_get_ast_loop_type (*isl_pointers__.p_isl_schedule_node_band_member_get_ast_loop_type)
++#define isl_schedule_node_band_member_set_ast_loop_type (*isl_pointers__.p_isl_schedule_node_band_member_set_ast_loop_type)
++#define isl_val_n_abs_num_chunks (*isl_pointers__.p_isl_val_n_abs_num_chunks)
++#define isl_val_get_abs_num_chunks (*isl_pointers__.p_isl_val_get_abs_num_chunks)
++#define isl_val_int_from_chunks (*isl_pointers__.p_isl_val_int_from_chunks)
++#define isl_val_is_neg (*isl_pointers__.p_isl_val_is_neg)
++#define isl_version (*isl_pointers__.p_isl_version)
++#define isl_options_get_on_error (*isl_pointers__.p_isl_options_get_on_error)
++#define isl_ctx_reset_error (*isl_pointers__.p_isl_ctx_reset_error)
++
+ typedef struct poly_dr *poly_dr_p;
+ 
+ typedef struct poly_bb *poly_bb_p;
+@@ -448,5 +1033,6 @@ extern tree cached_scalar_evolution_in_r
+ extern void dot_all_sese (FILE *, vec<sese_l> &);
+ extern void dot_sese (sese_l &);
+ extern void dot_cfg ();
++extern const char *get_isl_version (bool);
+ 
+ #endif
+--- gcc/graphite.c.jj	2015-11-04 14:15:32.000000000 +0100
++++ gcc/graphite.c	2015-11-04 14:56:02.645536409 +0100
+@@ -60,6 +60,35 @@ along with GCC; see the file COPYING3.
+ #include "tree-into-ssa.h"
+ #include "graphite.h"
+ 
++__typeof (isl_pointers__) isl_pointers__;
++
++static bool
++init_isl_pointers (void)
++{
++  void *h;
++
++  if (isl_pointers__.inited)
++    return isl_pointers__.h != NULL;
++  h = dlopen ("libisl.so.15", RTLD_LAZY);
++  isl_pointers__.h = h;
++  if (h == NULL)
++    return false;
++#define DYNSYM(x) \
++  do \
++    { \
++      union { __typeof (isl_pointers__.p_##x) p; void *q; } u; \
++      u.q = dlsym (h, #x); \
++      if (u.q == NULL) \
++	return false; \
++      isl_pointers__.p_##x = u.p; \
++    } \
++  while (0)
++  DYNSYMS
++#undef DYNSYM
++  isl_pointers__.inited = true;
++  return true;
++}
++
+ /* Print global statistics to FILE.  */
+ 
+ static void
+@@ -365,6 +394,15 @@ graphite_transform_loops (void)
+   if (parallelized_function_p (cfun->decl))
+     return;
+ 
++  if (number_of_loops (cfun) <= 1)
++    return;
++
++  if (!init_isl_pointers ())
++    {
++      sorry ("Graphite loop optimizations cannot be used");
++      return;
++    }
++
+   calculate_dominance_info (CDI_DOMINATORS);
+ 
+   /* We rely on post-dominators during merging of SESE regions so those
+@@ -455,6 +493,14 @@ graphite_transform_loops (void)
+     }
+ }
+ 
++const char *
++get_isl_version (bool force)
++{
++  if (force)
++    init_isl_pointers ();
++  return (isl_pointers__.inited && isl_version) ? isl_version () : "none";
++}
++
+ #else /* If isl is not available: #ifndef HAVE_isl.  */
+ 
+ static void
+--- gcc/toplev.c.jj	2017-02-19 13:02:31.000000000 +0100
++++ gcc/toplev.c	2017-02-19 16:50:25.536301350 +0100
+@@ -94,6 +94,7 @@ along with GCC; see the file COPYING3.
+ 
+ #ifdef HAVE_isl
+ #include <isl/version.h>
++extern const char *get_isl_version (bool);
+ #endif
+ 
+ static void general_init (const char *, bool);
+@@ -683,7 +684,7 @@ print_version (FILE *file, const char *i
+ #ifndef HAVE_isl
+ 	   "none"
+ #else
+-	   isl_version ()
++	   get_isl_version (*indent == 0)
+ #endif
+ 	   );
+   if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))

diff --git a/gcc12-isl-dl2.patch b/gcc12-isl-dl2.patch
new file mode 100644
index 0000000..e16672c
--- /dev/null
+++ b/gcc12-isl-dl2.patch
@@ -0,0 +1,71 @@
+2011-04-04  Jakub Jelinek  <jakub@redhat.com>
+
+	* toplev.c (toplev_main_argv): New variable.
+	(toplev_main): Initialize it.
+	* graphite.c (init_isl_pointers): Load libisl.so.15 from gcc's private
+	directory.
+
+--- gcc/toplev.c.jj	2008-12-09 23:59:10.000000000 +0100
++++ gcc/toplev.c	2009-01-27 14:33:52.000000000 +0100
+@@ -113,6 +113,8 @@ static void finalize (bool);
+ static void crash_signal (int) ATTRIBUTE_NORETURN;
+ static void compile_file (void);
+ 
++const char **toplev_main_argv;
++
+ /* Decoded options, and number of such options.  */
+ struct cl_decoded_option *save_decoded_options;
+ unsigned int save_decoded_options_count;
+@@ -2239,6 +2241,8 @@ toplev::main (int argc, char **argv)
+ 
+   expandargv (&argc, &argv);
+ 
++  toplev_main_argv = CONST_CAST2 (const char **, char **, argv);
++
+   /* Initialization of GCC's environment, and diagnostics.  */
+   general_init (argv[0], m_init_signals);
+ 
+--- gcc/graphite.c.jj	2010-12-01 10:24:32.000000000 -0500
++++ gcc/graphite.c	2010-12-01 11:46:07.832118193 -0500
+@@ -64,11 +64,39 @@ __typeof (isl_pointers__) isl_pointers__
+ static bool
+ init_isl_pointers (void)
+ {
+-  void *h;
++  void *h = NULL;
++  extern const char **toplev_main_argv;
++  char *buf, *p;
++  size_t len;
+ 
+   if (isl_pointers__.inited)
+     return isl_pointers__.h != NULL;
+-  h = dlopen ("libisl.so.15", RTLD_LAZY);
++  len = progname - toplev_main_argv[0];
++  buf = XALLOCAVAR (char, len + sizeof "libisl.so.15");
++  memcpy (buf, toplev_main_argv[0], len);
++  strcpy (buf + len, "libisl.so.15");
++  len += sizeof "libisl.so.15";
++  p = strstr (buf, "/libexec/");
++  if (p != NULL)
++    {
++      while (1)
++	{
++	  char *q = strstr (p + 8, "/libexec/");
++	  if (q == NULL)
++	    break;
++	  p = q;
++	}
++      memmove (p + 4, p + 8, len - (p + 8 - buf));
++      h = dlopen (buf, RTLD_LAZY);
++      if (h == NULL)
++	{
++	  len = progname - toplev_main_argv[0];
++	  memcpy (buf, toplev_main_argv[0], len);
++	  strcpy (buf + len, "libisl.so.15");
++	}
++    }
++  if (h == NULL)
++    h = dlopen (buf, RTLD_LAZY);
+   isl_pointers__.h = h;
+   if (h == NULL)
+     return false;

diff --git a/gcc12-libgomp-omp_h-multilib.patch b/gcc12-libgomp-omp_h-multilib.patch
new file mode 100644
index 0000000..d0e98d1
--- /dev/null
+++ b/gcc12-libgomp-omp_h-multilib.patch
@@ -0,0 +1,17 @@
+2008-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+	* omp.h.in (omp_nest_lock_t): Fix up for Linux multilibs.
+
+--- libgomp/omp.h.in.jj	2008-06-09 13:34:05.000000000 +0200
++++ libgomp/omp.h.in	2008-06-09 13:34:48.000000000 +0200
+@@ -42,8 +42,8 @@ typedef struct
+ 
+ typedef struct
+ {
+-  unsigned char _x[@OMP_NEST_LOCK_SIZE@] 
+-    __attribute__((__aligned__(@OMP_NEST_LOCK_ALIGN@)));
++  unsigned char _x[8 + sizeof (void *)] 
++    __attribute__((__aligned__(sizeof (void *))));
+ } omp_nest_lock_t;
+ #endif
+ 

diff --git a/gcc12-libstdc++-docs.patch b/gcc12-libstdc++-docs.patch
new file mode 100644
index 0000000..25aa718
--- /dev/null
+++ b/gcc12-libstdc++-docs.patch
@@ -0,0 +1,24 @@
+--- libstdc++-v3/doc/html/index.html.jj	2011-01-03 12:53:21.282829010 +0100
++++ libstdc++-v3/doc/html/index.html	2011-01-04 18:06:28.999851145 +0100
+@@ -5,6 +5,8 @@
+       <a class="link" href="https://www.fsf.org" target="_top">FSF
+       </a>
+     </p><p>
++      Release 12.0.0
++    </p><p>
+       Permission is granted to copy, distribute and/or modify this
+       document under the terms of the GNU Free Documentation
+       License, Version 1.2 or any later version published by the
+--- libstdc++-v3/doc/html/api.html.jj	2011-01-03 12:53:21.000000000 +0100
++++ libstdc++-v3/doc/html/api.html	2011-01-04 18:12:01.672757784 +0100
+@@ -20,7 +20,9 @@
+   member functions for the library classes, finding out what is in a
+   particular include file, looking at inheritance diagrams, etc.
+ </p><p>
+-  The API documentation, rendered into HTML, can be viewed online
++  The API documentation, rendered into HTML, can be viewed locally
++  <a class="link" href="api/index.html" target="_top">for the 12.0.0 release</a>,
++  online
+   <a class="link" href="http://gcc.gnu.org/onlinedocs/" target="_top">for each GCC release</a>
+   and
+   <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html" target="_top">

diff --git a/gcc12-libtool-no-rpath.patch b/gcc12-libtool-no-rpath.patch
new file mode 100644
index 0000000..466c661
--- /dev/null
+++ b/gcc12-libtool-no-rpath.patch
@@ -0,0 +1,27 @@
+libtool sucks.
+--- ltmain.sh.jj	2007-12-07 14:53:21.000000000 +0100
++++ ltmain.sh	2008-09-05 21:51:48.000000000 +0200
+@@ -5394,6 +5394,7 @@ EOF
+ 	  rpath="$finalize_rpath"
+ 	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+ 	  for libdir in $rpath; do
++	    case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
+ 	    if test -n "$hardcode_libdir_flag_spec"; then
+ 	      if test -n "$hardcode_libdir_separator"; then
+ 		if test -z "$hardcode_libdirs"; then
+@@ -6071,6 +6072,7 @@ EOF
+       rpath=
+       hardcode_libdirs=
+       for libdir in $compile_rpath $finalize_rpath; do
++	case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
+ 	if test -n "$hardcode_libdir_flag_spec"; then
+ 	  if test -n "$hardcode_libdir_separator"; then
+ 	    if test -z "$hardcode_libdirs"; then
+@@ -6120,6 +6122,7 @@ EOF
+       rpath=
+       hardcode_libdirs=
+       for libdir in $finalize_rpath; do
++	case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
+ 	if test -n "$hardcode_libdir_flag_spec"; then
+ 	  if test -n "$hardcode_libdir_separator"; then
+ 	    if test -z "$hardcode_libdirs"; then

diff --git a/gcc12-no-add-needed.patch b/gcc12-no-add-needed.patch
new file mode 100644
index 0000000..5817299
--- /dev/null
+++ b/gcc12-no-add-needed.patch
@@ -0,0 +1,37 @@
+2010-02-08  Roland McGrath  <roland@redhat.com>
+
+	* config/gnu-user.h (LINK_EH_SPEC): Pass --no-add-needed to the linker.
+	* config/alpha/elf.h (LINK_EH_SPEC): Likewise.
+	* config/ia64/linux.h (LINK_EH_SPEC): Likewise.
+
+--- gcc/config/alpha/elf.h.jj	2011-01-03 12:52:31.118056764 +0100
++++ gcc/config/alpha/elf.h	2011-01-04 18:14:10.931874160 +0100
+@@ -168,5 +168,5 @@ extern int alpha_this_gpdisp_sequence_nu
+    I imagine that other systems will catch up.  In the meantime, it
+    doesn't harm to make sure that the data exists to be used later.  */
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
++#define LINK_EH_SPEC "--no-add-needed %{!static|static-pie:--eh-frame-hdr} "
+ #endif
+--- gcc/config/ia64/linux.h.jj	2011-01-03 13:02:11.462994522 +0100
++++ gcc/config/ia64/linux.h	2011-01-04 18:14:10.931874160 +0100
+@@ -76,7 +76,7 @@ do {						\
+    Signalize that because we have fde-glibc, we don't need all C shared libs
+    linked against -lgcc_s.  */
+ #undef LINK_EH_SPEC
+-#define LINK_EH_SPEC ""
++#define LINK_EH_SPEC "--no-add-needed "
+ 
+ #undef TARGET_INIT_LIBFUNCS
+ #define TARGET_INIT_LIBFUNCS ia64_soft_fp_init_libfuncs
+--- gcc/config/gnu-user.h.jj	2011-01-03 12:53:03.739057299 +0100
++++ gcc/config/gnu-user.h	2011-01-04 18:14:10.932814884 +0100
+@@ -106,7 +106,7 @@ see the files COPYING3 and COPYING.RUNTI
+ #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
+ 
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
++#define LINK_EH_SPEC "--no-add-needed %{!static|static-pie:--eh-frame-hdr} "
+ #endif
+ 
+ #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \

diff --git a/gcc12-rh1574936.patch b/gcc12-rh1574936.patch
new file mode 100644
index 0000000..6b4be0c
--- /dev/null
+++ b/gcc12-rh1574936.patch
@@ -0,0 +1,30 @@
+crt files and statically linked libgcc objects cause false positives
+in annobin coverage, so we add the assembler flag to generate notes
+for them.
+
+The patch also adds notes to libgcc_s.so, but this is harmless because
+these notes only confer that there is no other annobin markup.
+
+2018-07-25  Florian Weimer  <fweimer@redhat.com>
+
+	* Makefile.in (LIBGCC2_CFLAGS, CRTSTUFF_CFLAGS): Add
+	-Wa,--generate-missing-build-notes=yes.
+
+--- libgcc/Makefile.in	2018-01-13 13:05:41.000000000 +0100
++++ libgcc/Makefile.in	2018-07-25 13:15:02.036226940 +0200
+@@ -246,6 +246,7 @@ LIBGCC2_DEBUG_CFLAGS = -g
+ LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
+ 		 $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
+ 		 -fbuilding-libgcc -fno-stack-protector \
++		 -Wa,--generate-missing-build-notes=yes \
+ 		 $(INHIBIT_LIBC_CFLAGS)
+ 
+ # Additional options to use when compiling libgcc2.a.
+@@ -301,6 +302,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(IN
+   $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
+   -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
+   -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
++  -Wa,--generate-missing-build-notes=yes \
+   $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
+ 
+ # Extra flags to use when compiling crt{begin,end}.o.

diff --git a/gcc12-sparc-config-detection.patch b/gcc12-sparc-config-detection.patch
new file mode 100644
index 0000000..bb06b35
--- /dev/null
+++ b/gcc12-sparc-config-detection.patch
@@ -0,0 +1,40 @@
+--- gcc/config.gcc.jj	2008-04-24 15:42:46.000000000 -0500
++++ gcc/config.gcc	2008-04-24 15:44:51.000000000 -0500
+@@ -2790,7 +2790,7 @@ sparc-*-rtems*)
+ 	tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp-elf.h sparc/rtemself.h rtems.h newlib-stdint.h"
+ 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-rtems"
+ 	;;
+-sparc-*-linux*)
++sparc-*-linux* | sparcv9-*-linux*)
+ 	tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/tso.h"
+ 	extra_options="${extra_options} sparc/long-double-switch.opt"
+ 	case ${target} in
+@@ -2844,7 +2844,7 @@ sparc64-*-rtems*)
+ 	extra_options="${extra_options}"
+ 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-rtems-64"
+ 	;;
+-sparc64-*-linux*)
++sparc64*-*-linux*)
+ 	tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/default64.h sparc/linux64.h sparc/tso.h"
+ 	extra_options="${extra_options} sparc/long-double-switch.opt"
+ 	tmake_file="${tmake_file} sparc/t-sparc sparc/t-linux64"
+--- libgcc/config.host.jj	2008-04-24 15:46:19.000000000 -0500
++++ libgcc/config.host	2008-04-24 15:46:49.000000000 -0500
+@@ -1002,7 +1002,7 @@ sparc-*-elf*)
+ 	tmake_file="${tmake_file} t-fdpbit t-crtfm"
+ 	extra_parts="$extra_parts crti.o crtn.o crtfastmath.o"
+ 	;;
+-sparc-*-linux*)		# SPARC's running GNU/Linux, libc6
++sparc-*-linux* | sparcv9-*-linux*)		# SPARC's running GNU/Linux, libc6
+ 	tmake_file="${tmake_file} t-crtfm"
+ 	if test "${host_address}" = 64; then
+ 		tmake_file="$tmake_file sparc/t-linux64"
+@@ -1050,7 +1050,7 @@ sparc64-*-freebsd*|ultrasparc-*-freebsd*
+ 	tmake_file="$tmake_file t-crtfm"
+ 	extra_parts="$extra_parts crtfastmath.o"
+ 	;;
+-sparc64-*-linux*)		# 64-bit SPARC's running GNU/Linux
++sparc64*-*-linux*)		# 64-bit SPARC's running GNU/Linux
+ 	extra_parts="$extra_parts crtfastmath.o"
+ 	tmake_file="${tmake_file} t-crtfm sparc/t-linux"
+ 	if test "${host_address}" = 64; then

diff --git a/sources b/sources
index a7e012b..102dae1 100644
--- a/sources
+++ b/sources
@@ -1,4 +1,4 @@
-SHA512 (gcc-11.2.1-20211203.tar.xz) = 3cf64d3af541b9e80a2d5dd95a1257afefda554cfa16b757a7f861701e3da2d6917dbb1f4cd74301ffaf45e92c441642b8c589a10698a9103a216620f0849626
+SHA512 (gcc-12.0.0-20220108.tar.xz) = 4248211feab3970d24b0862ad61f8c089ae21311c2b56b2ac0a298cf9126b2255a4f8ba44677683bb5862e34e34d433e3c6a20747b55e242c57981fafc9e9641
 SHA512 (isl-0.18.tar.bz2) = 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c41b2de5f351025370e57448b63b2b8a8cf8a0843a089c3263f9baee1542d5c2e1cb37ed39d94
 SHA512 (newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz) = 002a48a7b689a81abbf16161bcaec001a842e67dfbe372e9e109092703bfc666675f16198f60ca429370e8850d564547dc505df81bc3aaca4ce6defbc014ad6c
 SHA512 (nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz) = f6d10db94fa1570ae0f94df073fa3c73c8e5ee16d59070b53d94f7db0de8a031bc44d7f3f1852533da04b625ce758e022263855ed43cfc6867e0708d001e53c7

diff --git a/update-gcc.sh b/update-gcc.sh
index 644b209..4592048 100755
--- a/update-gcc.sh
+++ b/update-gcc.sh
@@ -3,5 +3,5 @@
 git clone --depth 1 git://gcc.gnu.org/git/gcc.git gcc-dir.tmp
 git --git-dir=gcc-dir.tmp/.git fetch --depth 1 origin $1
 d=`date --iso | sed 's/-//g'`
-git --git-dir=gcc-dir.tmp/.git archive --prefix=gcc-11.2.1-$d/ $1 | xz -9e > gcc-11.2.1-$d.tar.xz
+git --git-dir=gcc-dir.tmp/.git archive --prefix=gcc-12.0.0-$d/ $1 | xz -9e > gcc-12.0.0-$d.tar.xz
 rm -rf gcc-dir.tmp

                 reply	other threads:[~2026-06-29 12:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178273617297.1.9271392077375959065.rpms-gcc-cdf92292afdc@fedoraproject.org \
    --to=jakub@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox