Patchwork C++ testsuite PATCH to overhaul running of tests in C++11 mode

login
register
mail settings
Submitter Jason Merrill
Date Nov. 9, 2011, 5:47 p.m.
Message ID <4EBABCB6.2070109@redhat.com>
Download mbox | patch
Permalink /patch/124644/
State New
Headers show

Comments

Jason Merrill - Nov. 9, 2011, 5:47 p.m.
While working on an earlier PR I noticed that make check-c++0x wasn't 
actually running a lot of tests in C++11 mode because the -std=c++11 
that it added came before the default arguments, so any test without a { 
dg-options } line would still be run in C++98 mode.  So I've reworked 
the C++ testsuite to run in both modes:  If a test specifies a -std, 
then we use that, otherwise we do both.

I've also added c++98 and c++11 as effective target keywords, so a test 
line can say e.g.

// { dg-error "foo" "bar" { target c++98 } }

if it's only ill-formed in C++98.

The check-c++0x target is now obsolete, so the toplevel check-c++ 
doesn't use it anymore.

Tested x86_64-pc-linux-gnu, applying to trunk.
Joseph S. Myers - Nov. 9, 2011, 6:02 p.m.
On Wed, 9 Nov 2011, Jason Merrill wrote:

> While working on an earlier PR I noticed that make check-c++0x wasn't actually
> running a lot of tests in C++11 mode because the -std=c++11 that it added came
> before the default arguments, so any test without a { dg-options } line would
> still be run in C++98 mode.  So I've reworked the C++ testsuite to run in both
> modes:  If a test specifies a -std, then we use that, otherwise we do both.

To confirm: what do the PASS or FAIL lines look like?  They need to be 
different for the two modes; it's bad to have

PASS: g++.dg/whatever
PASS: g++.dg/whatever

as that breaks automatic comparisons; you need

PASS: g++.dg/whatever
PASS: g++.dg/whatever -std=c++11

or something similar with unique names for the two versions of each test.
Jason Merrill - Nov. 9, 2011, 6:05 p.m.
On 11/09/2011 01:02 PM, Joseph S. Myers wrote:
> To confirm: what do the PASS or FAIL lines look like?

For tests run in both modes, they look like

PASS: g++.dg/whatever -std=c++98
PASS: g++.dg/whatever -std=c++11

Jason
Fabien ChĂȘne - Nov. 9, 2011, 9:01 p.m.
Hi,

2011/11/9 Jason Merrill <jason@redhat.com>:
> On 11/09/2011 01:02 PM, Joseph S. Myers wrote:
>>
>> To confirm: what do the PASS or FAIL lines look like?
>
> For tests run in both modes, they look like
>
> PASS: g++.dg/whatever -std=c++98
> PASS: g++.dg/whatever -std=c++11

Nice, but ... is there a way to launch the testsuite with only one
mode at a time ?

Thanks,
Jason Merrill - Nov. 9, 2011, 9:45 p.m.
On 11/09/2011 04:01 PM, Fabien ChĂȘne wrote:
> Nice, but ... is there a way to launch the testsuite with only one
> mode at a time ?

Not currently.

Jason

Patch

commit b714f79ddd8bec09cd3758e93d7315207dfd02e3
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Nov 8 11:48:26 2011 -0500

    	Run most tests in both C++98 and C++11 modes.
    gcc/testsuite/
    	* lib/target-supports.exp (check_effective_target_c++11): New.
    	(check_effective_target_c++98): New.
    	* lib/g++-dg.exp (g++-dg-runtest): New.
    	* [various.exp]: Use g++-dg-runtest.
    	* [various.C]: Fix for C++11 mode.
    gcc/cp/
    	* Make-lang.in (check_g++_parallelize): Add dg-torture.exp.
    	(check-c++0x): Obsolete.
    /
    	* Makefile.def (language=c++): Remove check-c++0x.
    	* Makefile.in (check-gcc-c++): Regenerate.

diff --git a/Makefile.def b/Makefile.def
index b94dabf..b4236ba 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -513,7 +513,7 @@  dependencies = { module=configure-target-newlib; on=all-ld; };
 dependencies = { module=configure-target-libgfortran; on=all-target-libquadmath; };
 
 languages = { language=c;	gcc-check-target=check-gcc; };
-languages = { language=c++;	gcc-check-target="check-c++ check-c++0x";
+languages = { language=c++;	gcc-check-target=check-c++;
 				lib-check-target=check-target-libstdc++-v3;
 				lib-check-target=check-target-libmudflap-c++; };
 languages = { language=fortran;	gcc-check-target=check-fortran;
diff --git a/Makefile.in b/Makefile.in
index 900c325..c377f57 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40661,7 +40661,7 @@  check-gcc-c++:
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	(cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++ check-c++0x);
+	(cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++);
 check-c++: check-gcc-c++ check-target-libstdc++-v3 check-target-libmudflap-c++
 
 .PHONY: check-gcc-fortran check-fortran
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 650fc38..0ce01ac 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -152,8 +152,7 @@  c++.srcman: doc/g++.1
 check-c++ : check-g++
 # Run the testsute in C++0x mode.
 check-c++0x:
-	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,-std=gnu++0x" \
-	  TESTSUITEDIR="$(TESTSUITEDIR).c++0x" check-g++
+	@echo Normal 'make check' now runs the testsuite in C++11 mode as well as C++98.
 # Run the testsuite with garbage collection at every opportunity.
 check-g++-strict-gc:
 	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
@@ -163,7 +162,7 @@  check-c++-subtargets : check-g++-subtargets
 lang_checks += check-g++
 lang_checks_parallelized += check-g++
 # For description see comment above check_gcc_parallelize in gcc/Makefile.in.
-check_g++_parallelize = old-deja.exp dg.exp
+check_g++_parallelize = old-deja.exp dg.exp dg-torture.exp
 
 #
 # Install hooks:
diff --git a/gcc/testsuite/g++.dg/abi/mangle4.C b/gcc/testsuite/g++.dg/abi/mangle4.C
deleted file mode 100644
index 3ce2247..0000000
--- a/gcc/testsuite/g++.dg/abi/mangle4.C
+++ /dev/null
@@ -1,24 +0,0 @@ 
-// Test mangling of type casts
-// { dg-do compile }
-
-class A {};
-class B : public A {};
-
-template<const A* a> class C {};
-template<const B* b> class D {};
-template<B* b> class E {};
-
-template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {} // { dg-error "" }
-template<const B* b> void g(D<b> &, E<const_cast<B*>(b)> &) {} // { dg-error "" }
-
-B b;
-
-int main()
-{
-  C<static_cast<const A*>(&b)> c; // { dg-error "" }
-  D<&b> d;
-  E<const_cast<B*>(&b)> e; // { dg-error "" }
-  f(d, c);
-  g(d, e);
-}
-
diff --git a/gcc/testsuite/g++.dg/charset/charset.exp b/gcc/testsuite/g++.dg/charset/charset.exp
index 7d409d3..fe35f6a 100644
--- a/gcc/testsuite/g++.dg/charset/charset.exp
+++ b/gcc/testsuite/g++.dg/charset/charset.exp
@@ -37,8 +37,8 @@  if ![info exists DEFAULT_CHARSETCFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cc,S} ]] \
-        "" $DEFAULT_CHARSETCFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cc,S} ]] \
+        $DEFAULT_CHARSETCFLAGS
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic60.C b/gcc/testsuite/g++.dg/cpp0x/variadic60.C
index b86711f..8e1681e 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic60.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic60.C
@@ -1 +1 @@ 
-template<typename... Args> class tuple; // { dg-error "variadic templates" }
+template<typename... Args> class tuple; // { dg-error "variadic templates" "" { target c++98 } }
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
index 37dd794..7b112ac 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
@@ -35,8 +35,8 @@  set comp_output [g++_target_compile \
 if { ! [string match "*: target system does not support the * debug format*" \
     $comp_output] } {
     remove-build-file "trivial.S"
-    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/dwarf2/*.c]] \
-	    "" $DEFAULT_CFLAGS
+    g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/dwarf2/*.c]] \
+	    $DEFAULT_CFLAGS
 }
 
 # All done.
diff --git a/gcc/testsuite/g++.dg/dfp/dfp.exp b/gcc/testsuite/g++.dg/dfp/dfp.exp
index 4b15ca5..4d235e5 100644
--- a/gcc/testsuite/g++.dg/dfp/dfp.exp
+++ b/gcc/testsuite/g++.dg/dfp/dfp.exp
@@ -49,11 +49,11 @@  set DEFAULT_CXXFLAGS ""
 dg-init
 
 # Main loop.  Run the tests that are specific to C++.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C]] \
-        "" $DEFAULT_CXXFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C]] \
+        $DEFAULT_CXXFLAGS
 # Run tests that are shared with C testing.
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/dfp/*.c]] \
-        "" $DEFAULT_CXXFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/dfp/*.c]] \
+        $DEFAULT_CXXFLAGS
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp
index ad1f7e2..0730c76 100644
--- a/gcc/testsuite/g++.dg/dg.exp
+++ b/gcc/testsuite/g++.dg/dg.exp
@@ -22,7 +22,7 @@  load_lib g++-dg.exp
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CXXFLAGS
 if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+    set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
 }
 
 # Initialize `dg'.
@@ -52,14 +52,14 @@  set tests [prune $tests $srcdir/$subdir/guality/*]
 set tests [prune $tests $srcdir/$subdir/simulate-thread/*]
 
 # Main loop.
-dg-runtest $tests "" $DEFAULT_CXXFLAGS
+g++-dg-runtest $tests $DEFAULT_CXXFLAGS
 
 # C/C++ common tests.
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/*.\[cSi\]]] \
-	"" ""
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/*.\[cSi\]]] \
+	""
 
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cpp/*.\[cS\]]] \
-	"" ""
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cpp/*.\[cS\]]] \
+	""
 
 
 # All done.
diff --git a/gcc/testsuite/g++.dg/ext/anon-struct4.C b/gcc/testsuite/g++.dg/ext/anon-struct4.C
index fa5bd4b..5d0bf71 100644
--- a/gcc/testsuite/g++.dg/ext/anon-struct4.C
+++ b/gcc/testsuite/g++.dg/ext/anon-struct4.C
@@ -1,5 +1,5 @@ 
 // PR c++/14401
 
 struct { struct { int& i ; } bar ; } foo ; // { dg-error "uninitialized" "uninit" }
-// { dg-warning "anonymous" "anon" { target *-*-* } 3 }
+// { dg-warning "anonymous" "anon" { target c++98 } 3 }
 // { dg-message "should be initialized" "ref-uninit" { target *-*-* } 3 }
diff --git a/gcc/testsuite/g++.dg/gcov/gcov.exp b/gcc/testsuite/g++.dg/gcov/gcov.exp
index 08e00c4..73703dc 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov.exp
+++ b/gcc/testsuite/g++.dg/gcov/gcov.exp
@@ -39,6 +39,6 @@  if { $files != "" } {
 }
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" ""
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] ""
 
 dg-finish
diff --git a/gcc/testsuite/g++.dg/gomp/gomp.exp b/gcc/testsuite/g++.dg/gomp/gomp.exp
index b99d302..445cea8 100644
--- a/gcc/testsuite/g++.dg/gomp/gomp.exp
+++ b/gcc/testsuite/g++.dg/gomp/gomp.exp
@@ -27,7 +27,7 @@  if ![check_effective_target_fopenmp] {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/gomp/*.c]] "" "-fopenmp"
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/gomp/*.c]] "-fopenmp"
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp
index 4b359c9..7c96f58 100644
--- a/gcc/testsuite/g++.dg/graphite/graphite.exp
+++ b/gcc/testsuite/g++.dg/graphite/graphite.exp
@@ -46,14 +46,14 @@  set block_files       [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
 
 # Tests to be compiled.
 set dg-do-what-default compile
-dg-runtest $scop_files        "" "-O2 -fgraphite -fdump-tree-graphite-all"
-dg-runtest $id_files          "" "-O2 -fgraphite-identity -ffast-math"
+g++-dg-runtest $scop_files        "-O2 -fgraphite -fdump-tree-graphite-all"
+g++-dg-runtest $id_files          "-O2 -fgraphite-identity -ffast-math"
 
 # Tests to be run.
 set dg-do-what-default run
-dg-runtest $run_id_files      "" "-O2 -fgraphite-identity"
-dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
-dg-runtest $block_files       "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
+g++-dg-runtest $run_id_files      "-O2 -fgraphite-identity"
+g++-dg-runtest $interchange_files "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all"
+g++-dg-runtest $block_files       "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all"
 
 # The default action for the rest of the files is 'compile'.
 set dg-do-what-default compile
@@ -62,7 +62,7 @@  foreach f $id_files          {lremove wait_to_run_files $f}
 foreach f $run_id_files      {lremove wait_to_run_files $f}
 foreach f $interchange_files {lremove wait_to_run_files $f}
 foreach f $block_files       {lremove wait_to_run_files $f}
-dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
+g++-dg-runtest $wait_to_run_files " -pedantic-errors"
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
diff --git a/gcc/testsuite/g++.dg/init/brace2.C b/gcc/testsuite/g++.dg/init/brace2.C
index 619a20f..fec9c6c 100644
--- a/gcc/testsuite/g++.dg/init/brace2.C
+++ b/gcc/testsuite/g++.dg/init/brace2.C
@@ -5,4 +5,4 @@  const char * y = { "hello" };
 int a = 2;
 int b = { 2,3 }; // { dg-error "requires one element in initializer" }
 int c = { { 2 } } ; // { dg-error "braces around scalar initializer" }
-int d = {}; // { dg-error "initializer" }
+int d = {}; // { dg-error "initializer" "" { target c++98 } }
diff --git a/gcc/testsuite/g++.dg/init/brace6.C b/gcc/testsuite/g++.dg/init/brace6.C
index e01b947..ca39b01 100644
--- a/gcc/testsuite/g++.dg/init/brace6.C
+++ b/gcc/testsuite/g++.dg/init/brace6.C
@@ -18,7 +18,7 @@  int main()
 {
    int i = { 1 };
    int j = { 1, 2 }; /* { dg-error "requires one element" } */
-   A a = { 6 }; /* { dg-error "initialize" } */
+   A a = { 6 }; /* { dg-error "initialize" "" { target c++98 } } */
    B b = { 6 }; /* { dg-error "" } */
    C c = { 6 }; /* { dg-error "too many initializers" } */
    D d = { 6 };
diff --git a/gcc/testsuite/g++.dg/init/null1.C b/gcc/testsuite/g++.dg/init/null1.C
index eff3f61..a76ae2a 100644
--- a/gcc/testsuite/g++.dg/init/null1.C
+++ b/gcc/testsuite/g++.dg/init/null1.C
@@ -1,6 +1,7 @@ 
 // PR c++/16489
+// { dg-do compile { target c++98 } }
 
 const int NULL = 0;
 int main() { 
-  double* p = NULL; 
+  double* p = NULL;
 }
diff --git a/gcc/testsuite/g++.dg/other/anon3.C b/gcc/testsuite/g++.dg/other/anon3.C
index 87116eb..707c2d5 100644
--- a/gcc/testsuite/g++.dg/other/anon3.C
+++ b/gcc/testsuite/g++.dg/other/anon3.C
@@ -4,4 +4,4 @@ 
 
 // { dg-do compile }
 
-enum { a = 3 } x; // { dg-warning "anonymous type" }
+enum { a = 3 } x; // { dg-warning "anonymous type" "" { target c++98 } }
diff --git a/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp b/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp
index f9e6475..01e4aaf 100644
--- a/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp
+++ b/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp
@@ -26,8 +26,8 @@  torture-init
 set-torture-options [list \
 	{ -O0 -g } \
 	{ -O1 -g } \
-	{ -O2 -g } \
-	{ -O3 -g } \
+	{ -O2 -g -std=c++98 } \
+	{ -O3 -g -std=c++11 } \
 	{ -Os -g } ]
 
 if [gdb-exists] {
diff --git a/gcc/testsuite/g++.dg/template/arg2.C b/gcc/testsuite/g++.dg/template/arg2.C
index 9fb7a68..dabefc8 100644
--- a/gcc/testsuite/g++.dg/template/arg2.C
+++ b/gcc/testsuite/g++.dg/template/arg2.C
@@ -10,5 +10,5 @@  template <typename T> class X {};
 void fn ()
 {
   class L {};
-  X<L> f; // { dg-error "uses local type|trying to instantiate|no type|invalid type" "" }
+  X<L> f; // { dg-error "uses local type|trying to instantiate|no type|invalid type" "" { target c++98 } }
 }
diff --git a/gcc/testsuite/g++.dg/template/nontype25.C b/gcc/testsuite/g++.dg/template/nontype25.C
new file mode 100644
index 0000000..bcdcce5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype25.C
@@ -0,0 +1,22 @@ 
+// { dg-do compile }
+
+class A {};
+class B : public A {};
+
+template<const A* a> class C {};
+template<const B* b> class D {};
+template<B* b> class E {};
+
+template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {} // { dg-error "" "" { target c++98 } }
+template<const B* b> void g(D<b> &, E<const_cast<B*>(b)> &) {} // { dg-error "" "" { target c++98 } }
+
+B b;
+
+int main()
+{
+  C<static_cast<const A*>(&b)> c; // { dg-error "" }
+  D<&b> d;
+  E<const_cast<B*>(&b)> e; // { dg-error "" "" { target c++98 } }
+  f(d, c);		   // { dg-error "" "" { target c++11 } }
+  g(d, e);
+}
diff --git a/gcc/testsuite/g++.dg/template/sfinae6_neg.C b/gcc/testsuite/g++.dg/template/sfinae6_neg.C
index 2df4ade..d4be5dd 100644
--- a/gcc/testsuite/g++.dg/template/sfinae6_neg.C
+++ b/gcc/testsuite/g++.dg/template/sfinae6_neg.C
@@ -14,7 +14,7 @@  template<typename T> struct enable_if<false, T> { };
 template<typename F, typename T1, typename T2>
   typename enable_if<sizeof(create_a<F>()(create_a<T1>(), create_a<T2>()), 1),
 		     yes_type>::type
-  check_is_callable2(type<F>, type<T1>, type<T2>);
+  check_is_callable2(type<F>, type<T1>, type<T2>); // { dg-error "within this context" "" { target c++11 } }
 
 no_type check_is_callable2(...);
 
diff --git a/gcc/testsuite/g++.dg/tls/tls.exp b/gcc/testsuite/g++.dg/tls/tls.exp
index 6450ea3..7745cd5 100644
--- a/gcc/testsuite/g++.dg/tls/tls.exp
+++ b/gcc/testsuite/g++.dg/tls/tls.exp
@@ -22,14 +22,14 @@  load_lib g++-dg.exp
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CXXFLAGS
 if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+    set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
 }
 
 # Initialize `dg'.
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" $DEFAULT_CXXFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] $DEFAULT_CXXFLAGS
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/g++.dg/tm/tm.exp b/gcc/testsuite/g++.dg/tm/tm.exp
index d8c76fe..df40cdc 100644
--- a/gcc/testsuite/g++.dg/tm/tm.exp
+++ b/gcc/testsuite/g++.dg/tm/tm.exp
@@ -22,18 +22,18 @@  load_lib g++-dg.exp
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CXXFLAGS
 if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+    set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
 }
 
 # Initialize `dg'.
 dg-init
 
 # Run the tests that are shared with C.
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/tm/*.c]] \
-	"" $DEFAULT_CXXFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/tm/*.c]] \
+	$DEFAULT_CXXFLAGS
 # Run the C++ only tests.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
-	"" $DEFAULT_CXXFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
+	$DEFAULT_CXXFLAGS
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/g++.dg/vect/vect.exp b/gcc/testsuite/g++.dg/vect/vect.exp
index 76bd99a..7cb02d0 100644
--- a/gcc/testsuite/g++.dg/vect/vect.exp
+++ b/gcc/testsuite/g++.dg/vect/vect.exp
@@ -58,10 +58,10 @@  lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.{c,cc,S} ]] \
-        "" $DEFAULT_VECTCFLAGS
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-pr*.{c,cc,S} ]] \
-        "" $VECT_SLP_CFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.{c,cc,S} ]] \
+        $DEFAULT_VECTCFLAGS
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-pr*.{c,cc,S} ]] \
+        $VECT_SLP_CFLAGS
 
 #### Tests with special options
 global SAVED_DEFAULT_VECTCFLAGS
@@ -70,8 +70,8 @@  set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
 # --param max-aliased-vops=0
 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "--param max-aliased-vops=0"
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/param-max-aliased*.\[cS\]]]  \
-        "" $DEFAULT_VECTCFLAGS 
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/param-max-aliased*.\[cS\]]]  \
+        $DEFAULT_VECTCFLAGS
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default} 
diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C b/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C
index 1942ee2..644ae1c 100644
--- a/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C
+++ b/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C
@@ -1,4 +1,5 @@ 
 // PR c++/48420
+// { dg-do compile { target c++98 } }
 
 void foo(int* p);
 
diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C
index d3e121e..d41c26b 100644
--- a/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C
+++ b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 // prms-id: 12475
 
 #include <limits.h>
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C
index 3c98692..5fd31a6 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 // GROUPS passed old-abort
 typedef __SIZE_TYPE__ size_t;
 typedef void (*RF_Ptr)(void *);
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C
index 1327f5a..544d59b 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C
@@ -5,7 +5,7 @@ 
 class Thing
 {
 public:
-      typedef enum { GOOD_THING, BAD_THING, } ThingType ; // { dg-error "" } comma
+      typedef enum { GOOD_THING, BAD_THING, } ThingType ; // { dg-error "" "comma" { target c++98 } }
 	Thing (ThingType type) : thingType (type) { }
 	~Thing () { }
 private:
@@ -15,7 +15,7 @@  private:
 class Group
 {
 public:
-      typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // { dg-error "" } comma
+      typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // { dg-error "" "comma" { target c++98 } }
 	Group (GroupType type) : groupType (type), groupCount (0) { }
 	~Group () { }
 	void append (Thing* const &entry) { groupCount ++ ; }
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C
index 009333a..9c10560 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C
@@ -6,7 +6,7 @@  class X
     {
        oneMask = 0x0000FFFF,
        twoMask  = 0x000F0000,
-       thiMask = 0xFFF00000, // { dg-error "comma at end" }
+       thiMask = 0xFFF00000, // { dg-error "comma at end" "" { target c++98 } }
     };
     unsigned int foo;
 
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C
index ecf6fbf..bbdda4b 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C
@@ -6,7 +6,7 @@  class foo1
    enum foo1_enum
    {
       ENUM1,
-      ENUM2, // { dg-error "comma at end" }
+      ENUM2, // { dg-error "comma at end" "" { target c++98 } }
    };
 };
 
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C
index 88ecc73..d8a7d1b 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C
@@ -2,7 +2,7 @@ 
 // GROUPS passed enums
 enum fig {
     figgy,
-    pudding,  // { dg-error "comma at end" }
+    pudding,  // { dg-error "comma at end" "" { target c++98 } }
 };
 
 class X {
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C
index ecd85b4..209ea8c 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C
@@ -5,7 +5,7 @@  class B {
    friend class A;
 
    enum {
-      bEnum = 1, // { dg-error "comma at end" }
+      bEnum = 1, // { dg-error "comma at end" "" { target c++98 } }
    };
 
    int bArray[ bEnum ];
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init2.C b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C
index 0bf0aba..1b376dc 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/init2.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C
@@ -2,4 +2,4 @@ 
 // GROUPS passed initialization
 // this should give an error in require_required_type about not
 // being allowed to have an initializer list in an argument list.
-int f(int a = {1});// { dg-error "" } .*
+int f(int a = {1});// { dg-error "" "" { target c++98 } }
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init4.C b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C
index aa2bfb6..d3d1ffd 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/init4.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C
@@ -2,4 +2,4 @@ 
 // GROUPS passed initialization
 struct CharList { int i; };
 
-const CharList& terminals = { 1 }; // { dg-error "initializer lists" } c++0x
+const CharList& terminals = { 1 }; // { dg-error "initializer lists" "" { target c++98 } }
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C
index 09242a4..d2e4909 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C
@@ -4,7 +4,7 @@  class X {
 public:
     enum e {
 	New // { dg-error "conflicts with previous" }
-	,   // { dg-error "comma at end" }
+	,   // { dg-error "comma at end" "" { target c++98 } }
     };
 
     static int New(int); // { dg-error "declaration of" }
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cond.C b/gcc/testsuite/g++.old-deja/g++.jason/cond.C
index a6e5ba0..b1e692e 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/cond.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/cond.C
@@ -52,7 +52,7 @@  int main()
   // { dg-error "is initialized like a variable" "var" { target *-*-* } 51 }
     ;
   
-  if (int a[2] = {1, 2})	// { dg-error "extended init" } 
+  if (int a[2] = {1, 2})	// { dg-error "extended init" "" { target c++98 } }
     ;
 
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.law/init1.C b/gcc/testsuite/g++.old-deja/g++.law/init1.C
index 1727e38..3cce388 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/init1.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/init1.C
@@ -9,12 +9,12 @@  public:
 
 class bar {
 public:
-  foo f[3] = { 1, 2, 3 };   // works: f[0] = 1, f[1] = 2, f[2] = 3 // { dg-error "" } ANSI C++ forbids initialization of member f;
+  foo f[3] = { 1, 2, 3 };   // works: f[0] = 1, f[1] = 2, f[2] = 3 // { dg-error "" "" { target c++98 } } ANSI C++ forbids initialization of member f;
 };
 
 class bar2 {
 public:
-      foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" } ANSI C++ forbids initialization of member f;
+      foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" "" { target c++98 } } ANSI C++ forbids initialization of member f;
   // does not compile -- error: field initializer is not constant
 };
 
diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators32.C b/gcc/testsuite/g++.old-deja/g++.law/operators32.C
index 20d148d..9e1a356 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/operators32.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/operators32.C
@@ -7,7 +7,7 @@ 
 //
 
 template <class T>
-void ffree(long rows, T** array) // { dg-message "note" }
+void ffree(long rows, T** array)
 {
 for( long i = 0; i < rows; i++ )
   delete [] array[i];                   // delete row
@@ -21,7 +21,7 @@  return array = new T[size];
 }
 
 template <class T>
-T** allocate2d(long d1, long d2, T**& array) // { dg-message "note" }
+T** allocate2d(long d1, long d2, T**& array)
 {
 if( allocate1d(d1, array) != 0 )
   {
@@ -49,9 +49,7 @@  foo() {std::cout << "foo created" << std::endl; }
 };
 
 foo **f2;
-allocate2d(d1, d2, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
-// { dg-message "candidate" "candidate note" { target *-*-* } 52 }
-ffree(d1, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
-// { dg-message "candidate" "candidate note" { target *-*-* } 54 }
+allocate2d(d1, d2, f2);// { dg-error "" "" { target c++98 } }
+ffree(d1, f2);// { dg-error "" "" { target c++98 } }
 
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon9.C b/gcc/testsuite/g++.old-deja/g++.other/anon9.C
index a364db8..d458b6b 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/anon9.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/anon9.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 // Test that we properly diagnose an attempt to use an anonymous class
 // in declaring an external function.
 
diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage1.C b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
index 556ef97..2fa2dec 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 typedef struct {
   int i;
 } *p;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage2.C b/gcc/testsuite/g++.old-deja/g++.other/linkage2.C
index 2385b22..974cd63 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/linkage2.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/linkage2.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>    
 extern "C" 
 {
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum6.C b/gcc/testsuite/g++.old-deja/g++.pt/enum6.C
index 254b48b..48bdbb0 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/enum6.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/enum6.C
@@ -8,7 +8,7 @@  void fn(T)
 {
   enum tern { H, L, X, U };
 
-  vector<tern> ternvec; // { dg-error "" } composed from a local type
+  vector<tern> ternvec; // { dg-error "" "" { target c++98 } } composed from a local type
 }
 
 template void fn(int);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C
index dc9c6c9..1f53a75 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C
@@ -18,7 +18,7 @@  template int S<int>::t; // { dg-error "duplicate explicit instantiation" }
 template class S<double>;
 template class S<double>; // { dg-error "duplicate explicit instantiation" } 
 
-extern template void f(double); // { dg-error "extern" } extern not allowed
+extern template void f(double); // { dg-error "extern" "" { target c++98 } }
 inline template class S<float>; // { dg-error "inline" } inline not allowed
 
 template <class T>
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C
index 8802e98..19f1591 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C
@@ -13,30 +13,22 @@  public:
 };
 
 template <void (A::*)() >
-void g() {}			// { dg-message "void g" }
+void g() {}
 template <int A::*>
-void h() {}			// { dg-message "void h" }
+void h() {}
 
 
 int main() {
   g<&A::f>();
   h<&A::i>();
   g<&B::f>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 24 }
   h<&B::j>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 26 }
-  g<(void (A::*)()) &A::f>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 28 }
-  h<(int A::*) &A::i>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 30 }
+  g<(void (A::*)()) &A::f>(); // { dg-error "" "" { xfail c++11 } }
+  h<(int A::*) &A::i>(); // { dg-error "" "" { xfail c++11 } }
   g<(void (A::*)()) &B::f>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 32 }
   h<(int A::*) &B::j>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 34 }
-  g<(void (A::*)()) 0>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 36 }
-  h<(int A::*) 0>(); // { dg-error "" } 
-  // { dg-message "candidate" "candidate note" { target *-*-* } 38 }
+  g<(void (A::*)()) 0>(); // { dg-error "" "" { target c++98 } }
+  h<(int A::*) 0>(); // { dg-error "" "" { target c++98 } }
 
   return 0;
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t29.C b/gcc/testsuite/g++.old-deja/g++.pt/t29.C
index bcc94a3..f664f54 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/t29.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/t29.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 
 template <class X, int n> X f (auto X (*x)[n]) { return (*x)[n/2]; }
 extern int i[30];
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t30.C b/gcc/testsuite/g++.old-deja/g++.pt/t30.C
index 45da04c..b0c4f2f 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/t30.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/t30.C
@@ -1,4 +1,4 @@ 
-// { dg-do assemble  }
+// { dg-do assemble { target c++98 } }
 
 template <class X, int n> X f (auto X (*x)[n]) { return (*x)[n/2]; }
 extern int i[30], i2[33];
diff --git a/gcc/testsuite/g++.old-deja/old-deja.exp b/gcc/testsuite/g++.old-deja/old-deja.exp
index ce53b5f..c941f40 100644
--- a/gcc/testsuite/g++.old-deja/old-deja.exp
+++ b/gcc/testsuite/g++.old-deja/old-deja.exp
@@ -21,7 +21,7 @@  load_lib g++-dg.exp
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CXXFLAGS
 if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+    set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
 }
 
 # Initialize `dg'.
@@ -32,7 +32,7 @@  dg-init
 set tests [lsort [find $srcdir/$subdir *.C]]
 
 # Main loop.
-dg-runtest $tests "" $DEFAULT_CXXFLAGS
+g++-dg-runtest $tests $DEFAULT_CXXFLAGS
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp
index ec81d03..e6ef74b 100644
--- a/gcc/testsuite/lib/g++-dg.exp
+++ b/gcc/testsuite/lib/g++-dg.exp
@@ -26,3 +26,36 @@  proc g++-dg-test { prog do_what extra_tool_flags } {
 proc g++-dg-prune { system text } {
     return [gcc-dg-prune $system $text]
 }
+
+# Modified dg-runtest that runs tests in both C++98 and C++11 modes
+# unless they specifically specify one or the other.
+proc g++-dg-runtest { testcases default-extra-flags } {
+    global runtests
+
+    foreach test $testcases {
+	# If we're only testing specific files and this isn't one of them, skip it.
+	if ![runtest_file_p $runtests $test] {
+	    continue
+	}
+
+	# If the testcase specifies a standard, use that one.
+	# If not, run it under both standards, allowing GNU extensions
+	# if there's a dg-options line.
+	if ![search_for $test "-std=*++"] {
+	    if [search_for $test "dg-options"] {
+		set option_list { -std=gnu++98 -std=gnu++11 }
+	    } else {
+		set option_list { -std=c++98 -std=c++11 }
+	    }
+	} else {
+	    set option_list { "" }
+	}
+
+	set nshort [file tail [file dirname $test]]/[file tail $test]
+
+	foreach flags $option_list {
+	    verbose "Testing $nshort, $flags" 1
+	    dg-test $test $flags ${default-extra-flags}
+	}
+    }
+}
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 6e30233..b821231 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4265,6 +4265,24 @@  proc check_effective_target_c++ { } {
  return 0
 }
 
+# Check which language standard is active by checking for the presence of
+# one of the C++11 -std flags.  This assumes that the default for the
+# compiler is C++98, and that there will never be multiple -std= arguments
+# on the command line.
+proc check_effective_target_c++11 { } {
+    if ![check_effective_target_c++] {
+	return 0
+    }
+    return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
+}
+
+proc check_effective_target_c++98 { } {
+    if ![check_effective_target_c++] {
+	return 0
+    }
+    return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
+}
+
 # Return 1 if expensive testcases should be run.
 
 proc check_effective_target_run_expensive_tests { } {

commit 4253850568498b5be099aad24a62dc764d6b5747
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 9 10:50:55 2011 -0500

    	* [various.C]: Adjust for C++11 mode.

diff --git a/gcc/testsuite/g++.dg/eh/new1.C b/gcc/testsuite/g++.dg/eh/new1.C
index 0f86fcc..3126f19 100644
--- a/gcc/testsuite/g++.dg/eh/new1.C
+++ b/gcc/testsuite/g++.dg/eh/new1.C
@@ -9,7 +9,10 @@ 
 int ret = 1;
 
 void *ptr;
-void * operator new[] (std::size_t s) throw (std::bad_alloc)
+void * operator new[] (std::size_t s)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   ptr = operator new (s);
   return ptr;
diff --git a/gcc/testsuite/g++.dg/init/new11.C b/gcc/testsuite/g++.dg/init/new11.C
index bf06aa4..a13f262 100644
--- a/gcc/testsuite/g++.dg/init/new11.C
+++ b/gcc/testsuite/g++.dg/init/new11.C
@@ -5,7 +5,11 @@ 
 #include <new>
 
 bool abort_new;
-void *operator new[](size_t bytes) throw (std::bad_alloc) { 
+void *operator new[](size_t bytes)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
+{
   if (abort_new)
     abort(); 
   return operator new (bytes);
diff --git a/gcc/testsuite/g++.dg/init/pr29571.C b/gcc/testsuite/g++.dg/init/pr29571.C
index c9bfa28..d0dc678 100644
--- a/gcc/testsuite/g++.dg/init/pr29571.C
+++ b/gcc/testsuite/g++.dg/init/pr29571.C
@@ -3,6 +3,11 @@ 
 struct A
 {
   static const int i = 0/0 + ""; // { dg-warning "division by zero" }
-  // { dg-error "field initializer is not constant|not a constant-expression" "" { target *-*-* } 5 }
+  // { dg-error "constant|conversion|initializ" "" { target *-*-* } 5 }
   static const int j = int(i);
 };
+
+// Currently G++ complains about a non-constant initializer for 'j' in
+// C++11 mode, but not C++98.  Either way is correct because it depends on
+// the erroneous initializer for i, so don't require the error.
+// { dg-prune-output ":7:" }
diff --git a/gcc/testsuite/g++.dg/lookup/forscope2.C b/gcc/testsuite/g++.dg/lookup/forscope2.C
index 1fed957..882f102 100644
--- a/gcc/testsuite/g++.dg/lookup/forscope2.C
+++ b/gcc/testsuite/g++.dg/lookup/forscope2.C
@@ -7,3 +7,5 @@  struct S {
     }
 };
 
+// It's OK to error or not on line 6.
+// { dg-prune-output ":6:" }
diff --git a/gcc/testsuite/g++.dg/parse/linkage1.C b/gcc/testsuite/g++.dg/parse/linkage1.C
index 4a0d894..5a53425 100644
--- a/gcc/testsuite/g++.dg/parse/linkage1.C
+++ b/gcc/testsuite/g++.dg/parse/linkage1.C
@@ -1,6 +1,6 @@ 
 // PR c++/26068
 
-extern "C" auto int a; // { dg-error "linkage" }
+extern "C" auto int a; // { dg-error "linkage|two or more data types" }
 extern "C" register int b; // { dg-error "linkage" }
 extern "C" static void c(); // { dg-error "linkage" }
 extern "C" extern void d(); // { dg-error "linkage" }
diff --git a/gcc/testsuite/g++.dg/parse/typedef8.C b/gcc/testsuite/g++.dg/parse/typedef8.C
index 6ff26fe..4c1823e 100644
--- a/gcc/testsuite/g++.dg/parse/typedef8.C
+++ b/gcc/testsuite/g++.dg/parse/typedef8.C
@@ -7,5 +7,5 @@  static typedef int a;   // { dg-error "conflicting" }
 
 int foo()
 {
-  typedef auto int bar; // { dg-error "conflicting" }
+  typedef auto int bar; // { dg-error "conflicting|two or more data types" }
 }
diff --git a/gcc/testsuite/g++.dg/template/error44.C b/gcc/testsuite/g++.dg/template/error44.C
index 4f732cd..51053b2 100644
--- a/gcc/testsuite/g++.dg/template/error44.C
+++ b/gcc/testsuite/g++.dg/template/error44.C
@@ -1,6 +1,6 @@ 
 // PR c++/32056
 
-template <auto int T> struct A {}; // { dg-error "storage class specified" }
+template <auto int T> struct A {}; // { dg-error "storage class specified|two or more" }
 template <extern int T> struct B {}; // { dg-error "storage class specified" }
 template <static int T> struct C {}; // { dg-error "storage class specified" }
 template <register int T> struct D {}; // { dg-error "storage class specified" }
diff --git a/gcc/testsuite/g++.dg/tls/diag-2.C b/gcc/testsuite/g++.dg/tls/diag-2.C
index 484b188..b5d02e7 100644
--- a/gcc/testsuite/g++.dg/tls/diag-2.C
+++ b/gcc/testsuite/g++.dg/tls/diag-2.C
@@ -9,7 +9,7 @@  typedef __thread int g4;	/* { dg-error "multiple storage classes" } */
 void foo()
 {
   __thread int l1;		/* { dg-error "implicitly auto and declared '__thread'" } */
-  auto __thread int l2;		/* { dg-error "multiple storage classes" } */
+  auto __thread int l2;		/* { dg-error "multiple storage classes|data types" } */
   __thread extern int l3;	/* { dg-error "'__thread' before 'extern'" } */
   register __thread int l4;	/* { dg-error "multiple storage classes" } */
 }
diff --git a/gcc/testsuite/g++.dg/tls/diag-4.C b/gcc/testsuite/g++.dg/tls/diag-4.C
index 55e985e..7d07d9de 100644
--- a/gcc/testsuite/g++.dg/tls/diag-4.C
+++ b/gcc/testsuite/g++.dg/tls/diag-4.C
@@ -5,6 +5,6 @@  __thread typedef int g4;	/* { dg-error "multiple storage classes" } */
 
 void foo()
 {
-  __thread auto int l2;		/* { dg-error "multiple storage classes" } */
+  __thread auto int l2;		/* { dg-error "multiple storage classes|data types" } */
   __thread register int l4;	/* { dg-error "multiple storage classes" } */
 }
diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-3.C b/gcc/testsuite/g++.dg/warn/anonymous-namespace-3.C
index 0ba6790..8b72abd 100644
--- a/gcc/testsuite/g++.dg/warn/anonymous-namespace-3.C
+++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-3.C
@@ -11,3 +11,5 @@  struct C		   // { dg-warning "uses the anonymous namespace" }
 {
   std::auto_ptr<A> p;
 };
+
+// { dg-prune-output "auto_ptr. is deprecated" }
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C
index ff19c7e..7efea81 100644
--- a/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C
+++ b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C
@@ -8,7 +8,10 @@ 
 
 void* p;
 
-void* operator new[](size_t s) throw (std::bad_alloc)
+void* operator new[](size_t s)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   // Record the base of the last array allocated.
   p = malloc (s);
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
index 5370fb8..8d098bf 100644
--- a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
+++ b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
@@ -54,7 +54,10 @@  static abi::__cxa_cdtor_return_type dtor (void *x)
 
 // track new and delete
 static int blocks = 0;
-void *operator new[] (std::size_t size) throw (std::bad_alloc)
+void *operator new[] (std::size_t size)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   void *ptr = malloc (size);
   
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new3.C b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C
index 791d00b..55c7dbb 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/new3.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C
@@ -12,7 +12,11 @@ 
 
 int pass = 0;
 
-void *operator new(size_t sz) throw (std::bad_alloc) {
+void *operator new(size_t sz)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
+{
 
   void *p;
 
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new1.C b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
index 4c52cf4..e206f5b 100644
--- a/gcc/testsuite/g++.old-deja/g++.eh/new1.C
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
@@ -32,7 +32,10 @@  A::~A() { created = 0; }
 B::B(A) { }
 void foo (B*) { throw 1; }
 
-void* operator new (size_t size) throw (std::bad_alloc)
+void* operator new (size_t size)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   ++newed;
   return (void *) std::malloc (size);
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new2.C b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
index 2d69df0..d5fd74b 100644
--- a/gcc/testsuite/g++.old-deja/g++.eh/new2.C
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
@@ -33,7 +33,10 @@  A::~A() { created = 0; }
 B::B(A) { throw 1; }
 void foo (B*) { }
 
-void* operator new (size_t size) throw (std::bad_alloc)
+void* operator new (size_t size)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   ++newed;
   return (void *) std::malloc (size);
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new.C b/gcc/testsuite/g++.old-deja/g++.jason/new.C
index 905739b..5f50d2a 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/new.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/new.C
@@ -6,7 +6,11 @@  extern "C" int printf (const char *, ...);
 extern "C" void *malloc (std::size_t);
 std::size_t s;
 
-void * operator new (std::size_t siz) throw (std::bad_alloc) {
+void * operator new (std::size_t siz)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
+{
   if (s == 0)
     s = siz;
   else
diff --git a/gcc/testsuite/g++.old-deja/g++.law/friend1.C b/gcc/testsuite/g++.old-deja/g++.law/friend1.C
index 9cc1d35..aed9bd5 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/friend1.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/friend1.C
@@ -9,7 +9,11 @@ 
 #include <stddef.h>
 #include <new>
 struct Foo {
+#if __cplusplus <= 199711L
   friend void* operator new(size_t) throw (std::bad_alloc);
+#else
+  friend void* operator new(size_t);
+#endif
   friend void operator delete(void*) throw ();
   Foo();
   ~Foo();
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net46.C b/gcc/testsuite/g++.old-deja/g++.mike/net46.C
index 1740228..a236232 100644
--- a/gcc/testsuite/g++.old-deja/g++.mike/net46.C
+++ b/gcc/testsuite/g++.old-deja/g++.mike/net46.C
@@ -8,7 +8,11 @@  int fail = 1;
 
 int in_main = 0;
 
-void *operator new(size_t size) throw (std::bad_alloc) {
+void *operator new(size_t size)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
+{
   if (!in_main) return malloc (size);
   --fail;
   return (void*) 0;
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p755.C b/gcc/testsuite/g++.old-deja/g++.mike/p755.C
index 28eeefa..ee6198d 100644
--- a/gcc/testsuite/g++.old-deja/g++.mike/p755.C
+++ b/gcc/testsuite/g++.old-deja/g++.mike/p755.C
@@ -6,7 +6,11 @@ 
 
 extern "C" void _exit(int);
 
-void* operator new(std::size_t sz) throw (std::bad_alloc) {
+void* operator new(std::size_t sz)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
+{
   void* p = 0;
   _exit(0);
   return p;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/new6.C b/gcc/testsuite/g++.old-deja/g++.other/new6.C
index 3afb2b7..7013337 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/new6.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/new6.C
@@ -8,7 +8,10 @@  extern "C" void *malloc (size_t);
 int special;
 int space = 0xdeadbeef;
 
-void *operator new (size_t size) throw (bad_alloc)
+void *operator new (size_t size)
+#if __cplusplus <= 199711L
+  throw (std::bad_alloc)
+#endif
 {
   if (special)
     return &space;

commit 42e6742fa5d7613bc66bd43a8613bcfa1c8d2a7d
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 9 10:49:59 2011 -0500

    	* pt.c (invalid_nontype_parm_type_p): Avoid printing "<type error>".

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 38c26a7..9d82496 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18976,7 +18976,13 @@  invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain)
     return 0;
 
   if (complain & tf_error)
-    error ("%q#T is not a valid type for a template constant parameter", type);
+    {
+      if (type == error_mark_node)
+	inform (input_location, "invalid template non-type parameter");
+      else
+	error ("%q#T is not a valid type for a template non-type parameter",
+	       type);
+    }
   return 1;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic74.C b/gcc/testsuite/g++.dg/cpp0x/variadic74.C
index 19b6b11..5b502b9 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic74.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic74.C
@@ -1,8 +1,8 @@ 
-// { dg-options "-std=gnu++0x" }
+// { dg-do compile { target c++11 } }
 template <class... Types> class A
 {
 public:
-  template <Types... Values> class X { /* ... */ }; // { dg-error "not a valid type for a template constant parameter" }
+  template <Types... Values> class X { /* ... */ }; // { dg-error "not a valid type for a template non-type parameter" }
 };
 
 template<class... Types> class B
diff --git a/gcc/testsuite/g++.dg/template/crash53.C b/gcc/testsuite/g++.dg/template/crash53.C
index bbd1e7f..a8d7c11 100644
--- a/gcc/testsuite/g++.dg/template/crash53.C
+++ b/gcc/testsuite/g++.dg/template/crash53.C
@@ -5,7 +5,7 @@  template<int> struct A {};
 
 template<typename T> struct B
 {
-  template<T I> B(A<I>);  // { dg-error "template constant parameter" }
+  template<T I> B(A<I>);  // { dg-error "template non-type parameter" }
 };
 
 B<double> a=A<0>();  // { dg-error "non-scalar type" }
diff --git a/gcc/testsuite/g++.dg/template/void9.C b/gcc/testsuite/g++.dg/template/void9.C
index bb2ed66..319a684 100644
--- a/gcc/testsuite/g++.dg/template/void9.C
+++ b/gcc/testsuite/g++.dg/template/void9.C
@@ -1,4 +1,4 @@ 
 //PR c++/28738
 
 template<int,void> struct A {};    // { dg-error "not a valid type" }
-template<int N> struct A<N,0> {};  // { dg-error "not a valid type" }
+template<int N> struct A<N,0> {};  // { dg-message "invalid" }