2017-05-11  Nathan Sidwell  <nathan@acm.org>

	* lib/scanlang.exp: New.
	* lib/gcc-dg.exp: Load scanlang.exp.
	* g++.dg/inherit/covariant7.C: Use scan-lang-dump.

Index: g++.dg/inherit/covariant7.C
===================================================================
--- g++.dg/inherit/covariant7.C	(revision 247902)
+++ g++.dg/inherit/covariant7.C	(working copy)
@@ -36,15 +36,15 @@ struct c6 : c0, c3, c4
 
 // f2 appears four times in the c6 vtables:
 // once in c1-in-c3-in-c6 - covariant, virtual base, uses c1 vcall offset and c0 vbase offset
-// { dg-final { scan-tree-dump "24    .*c6::_ZTcv0_n16_v0_n12_NV2c62f2Ev" "class" { target ilp32 } } }
-// { dg-final { scan-tree-dump "48    .*c6::_ZTcv0_n32_v0_n24_NV2c62f2Ev" "class" { target lp64 } } }
+// { dg-final { scan-lang-dump "24    .*c6::_ZTcv0_n16_v0_n12_NV2c62f2Ev" "class" { target ilp32 } } }
+// { dg-final { scan-lang-dump "48    .*c6::_ZTcv0_n32_v0_n24_NV2c62f2Ev" "class" { target lp64 } } }
 // once in c3-in-c6 - non-covariant, non-virtual base, calls f2 directly
-// { dg-final { scan-tree-dump "28    .*c6::f2" "class" { target ilp32 } } }
-// { dg-final { scan-tree-dump "56    .*c6::f2" "class" { target lp64 } } }
+// { dg-final { scan-lang-dump "28    .*c6::f2" "class" { target ilp32 } } }
+// { dg-final { scan-lang-dump "56    .*c6::f2" "class" { target lp64 } } }
 // once in c1-in-c3-in-c4-in-c6 - lost primary
-// { dg-final { scan-tree-dump "80    .*0" "class" { target ilp32 } } }
-// { dg-final { scan-tree-dump "160   .*0" "class" { target lp64 } } }
+// { dg-final { scan-lang-dump "80    .*0" "class" { target ilp32 } } }
+// { dg-final { scan-lang-dump "160   .*0" "class" { target lp64 } } }
 // once in c3-in-c4-in-c6 - c3 vcall offset
-// { dg-final { scan-tree-dump "84    .*c6::_ZTv0_n16_NV2c62f2Ev" "class" { target ilp32 } } }
-// { dg-final { scan-tree-dump "168   .*c6::_ZTv0_n32_NV2c62f2Ev" "class" { target lp64 } } }
+// { dg-final { scan-lang-dump "84    .*c6::_ZTv0_n16_NV2c62f2Ev" "class" { target ilp32 } } }
+// { dg-final { scan-lang-dump "168   .*c6::_ZTv0_n32_NV2c62f2Ev" "class" { target lp64 } } }
 
Index: lib/gcc-dg.exp
===================================================================
--- lib/gcc-dg.exp	(revision 247902)
+++ lib/gcc-dg.exp	(working copy)
@@ -22,6 +22,7 @@ load_lib scanasm.exp
 load_lib scanrtl.exp
 load_lib scantree.exp
 load_lib scanipa.exp
+load_lib scanlang.exp
 load_lib timeout.exp
 load_lib timeout-dg.exp
 load_lib prune.exp
Index: lib/scanlang.exp
===================================================================
--- lib/scanlang.exp	(revision 0)
+++ lib/scanlang.exp	(working copy)
@@ -0,0 +1,43 @@
+#   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Various utilities for scanning tree dump output, used by gcc-dg.exp and
+# g++-dg.exp.
+
+load_lib scandump.exp
+
+# Utility for scanning compiler result, invoked via dg-final.
+# Call pass if pattern is present, otherwise fail.
+#
+# Argument 0 is the regexp to match
+# Argument 1 is the name of the dumped lang pass
+# Argument 2 handles expected failures and the like
+proc scan-lang-dump { args } {
+
+    if { [llength $args] < 2 } {
+	error "scan-tree-dump: too few arguments"
+	return
+    }
+    if { [llength $args] > 3 } {
+	error "scan-tree-dump: too many arguments"
+	return
+    }
+    if { [llength $args] >= 3 } {
+	scan-dump "lang" [lindex $args 0] "\[0-9\]\[0-9\]\[0-9\]l.[lindex $args 1]" [lindex $args 2]
+    } else {
+	scan-dump "lang" [lindex $args 0] "\[0-9\]\[0-9\]\[0-9\]l.[lindex $args 1]"
+    }
+}
