From d6a85c8dd4854845630569bbec6437170c3bc246 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 10 Mar 2007 02:01:49 +0000 Subject: [PATCH] re PR c++/20599 (variadic template support) 2007-03-09 Douglas Gregor PR c++/20599 * g++.dg/cpp0x/variadic-bind.C: New. * g++.dg/cpp0x/variadic-function.C: New. * g++.dg/cpp0x/variadic-mem_fn.C: New. * g++.dg/cpp0x/variadic-tuple.C: New. * g++.dg/cpp0x/variadic1.C: New. * g++.dg/cpp0x/variadic2.C: New. * g++.dg/cpp0x/variadic3.C: New. * g++.dg/cpp0x/variadic4.C: New. * g++.dg/cpp0x/variadic5.C: New. * g++.dg/cpp0x/variadic6.C: New. * g++.dg/cpp0x/variadic7.C: New. * g++.dg/cpp0x/variadic8.C: New. * g++.dg/cpp0x/variadic9.C: New. * g++.dg/cpp0x/variadic10.C: New. * g++.dg/cpp0x/variadic11.C: New. * g++.dg/cpp0x/variadic12.C: New. * g++.dg/cpp0x/variadic13.C: New. * g++.dg/cpp0x/variadic14.C: New. * g++.dg/cpp0x/variadic15.C: New. * g++.dg/cpp0x/variadic16.C: New. * g++.dg/cpp0x/variadic17.C: New. * g++.dg/cpp0x/variadic18.C: New. * g++.dg/cpp0x/variadic19.C: New. * g++.dg/cpp0x/variadic20.C: New. * g++.dg/cpp0x/variadic21.C: New. * g++.dg/cpp0x/variadic22.C: New. * g++.dg/cpp0x/variadic23.C: New. * g++.dg/cpp0x/variadic24.C: New. * g++.dg/cpp0x/variadic25.C: New. * g++.dg/cpp0x/variadic26.C: New. * g++.dg/cpp0x/variadic27.C: New. * g++.dg/cpp0x/variadic28.C: New. * g++.dg/cpp0x/variadic29.C: New. * g++.dg/cpp0x/variadic30.C: New. * g++.dg/cpp0x/variadic31.C: New. * g++.dg/cpp0x/variadic32.C: New. * g++.dg/cpp0x/variadic33.C: New. * g++.dg/cpp0x/variadic34.C: New. * g++.dg/cpp0x/variadic35.C: New. * g++.dg/cpp0x/variadic36.C: New. * g++.dg/cpp0x/variadic37.C: New. * g++.dg/cpp0x/variadic38.C: New. * g++.dg/cpp0x/variadic39.C: New. * g++.dg/cpp0x/variadic40.C: New. * g++.dg/cpp0x/variadic41.C: New. * g++.dg/cpp0x/variadic42.C: New. * g++.dg/cpp0x/variadic43.C: New. * g++.dg/cpp0x/variadic44.C: New. * g++.dg/cpp0x/variadic45.C: New. * g++.dg/cpp0x/variadic46.C: New. * g++.dg/cpp0x/variadic47.C: New. * g++.dg/cpp0x/variadic48.C: New. * g++.dg/cpp0x/variadic49.C: New. * g++.dg/cpp0x/variadic50.C: New. * g++.dg/cpp0x/variadic51.C: New. * g++.dg/cpp0x/variadic52.C: New. * g++.dg/cpp0x/variadic53.C: New. * g++.dg/cpp0x/variadic54.C: New. * g++.dg/cpp0x/variadic55.C: New. * g++.dg/cpp0x/variadic56.C: New. * g++.dg/cpp0x/variadic57.C: New. * g++.dg/cpp0x/variadic58.C: New. * g++.dg/cpp0x/variadic59.C: New. * g++.dg/cpp0x/variadic60.C : New. * g++.dg/cpp0x/variadic61.C : New. * g++.dg/cpp0x/variadic62.C : New. * g++.dg/cpp0x/variadic63.C : New. * g++.dg/cpp0x/variadic64.C : New. * g++.dg/cpp0x/variadic65.C : New. * g++.dg/cpp0x/variadic66.C : New. * g++.dg/cpp0x/variadic67.C : New. * g++.dg/cpp0x/variadic68.C : New. * g++.dg/cpp0x/variadic69.C : New. * g++.dg/cpp0x/variadic70.C : New. * g++.dg/cpp0x/variadic71.C : New. * g++.dg/cpp0x/variadic72.C : New. * g++.dg/cpp0x/variadic73.C : New. * g++.dg/cpp0x/variadic74.C : New. * g++.dg/cpp0x/variadic75.C : New. * g++.dg/cpp0x/variadic-ex1.C : New. * g++.dg/cpp0x/variadic-ex2.C : New. * g++.dg/cpp0x/variadic-ex3.C : New. * g++.dg/cpp0x/variadic-ex4.C : New. * g++.dg/cpp0x/variadic-ex5.C : New. * g++.dg/cpp0x/variadic-ex6.C : New. * g++.dg/cpp0x/variadic-ex7.C : New. * g++.dg/cpp0x/variadic-ex8.C : New. * g++.dg/cpp0x/variadic-ex9.C : New. * g++.dg/cpp0x/variadic-ex10.C : New. * g++.dg/cpp0x/variadic-ex11.C : New. * g++.dg/cpp0x/variadic-ex12.C : New. * g++.dg/cpp0x/variadic-ex13.C : New. * g++.dg/cpp0x/variadic-ex14.C : New. From-SVN: r122789 --- gcc/testsuite/ChangeLog | 97 ++++ gcc/testsuite/g++.dg/cpp0x/variadic-bind.C | 476 ++++++++++++++++++ gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C | 4 + gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C | 8 + gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C | 39 ++ gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C | 23 + gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C | 8 + gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C | 7 + gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C | 13 + gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C | 13 + gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C | 18 + gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C | 10 + .../g++.dg/cpp0x/variadic-function.C | 96 ++++ gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C | 50 ++ gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C | 294 +++++++++++ gcc/testsuite/g++.dg/cpp0x/variadic1.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic10.C | 22 + gcc/testsuite/g++.dg/cpp0x/variadic11.C | 18 + gcc/testsuite/g++.dg/cpp0x/variadic12.C | 42 ++ gcc/testsuite/g++.dg/cpp0x/variadic13.C | 19 + gcc/testsuite/g++.dg/cpp0x/variadic14.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic15.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic16.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic17.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic18.C | 47 ++ gcc/testsuite/g++.dg/cpp0x/variadic19.C | 19 + gcc/testsuite/g++.dg/cpp0x/variadic2.C | 17 + gcc/testsuite/g++.dg/cpp0x/variadic20.C | 47 ++ gcc/testsuite/g++.dg/cpp0x/variadic21.C | 7 + gcc/testsuite/g++.dg/cpp0x/variadic22.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic23.C | 25 + gcc/testsuite/g++.dg/cpp0x/variadic24.C | 6 + gcc/testsuite/g++.dg/cpp0x/variadic25.C | 16 + gcc/testsuite/g++.dg/cpp0x/variadic26.C | 24 + gcc/testsuite/g++.dg/cpp0x/variadic27.C | 22 + gcc/testsuite/g++.dg/cpp0x/variadic28.C | 25 + gcc/testsuite/g++.dg/cpp0x/variadic29.C | 35 ++ gcc/testsuite/g++.dg/cpp0x/variadic3.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic30.C | 11 + gcc/testsuite/g++.dg/cpp0x/variadic31.C | 11 + gcc/testsuite/g++.dg/cpp0x/variadic32.C | 11 + gcc/testsuite/g++.dg/cpp0x/variadic33.C | 16 + gcc/testsuite/g++.dg/cpp0x/variadic34.C | 11 + gcc/testsuite/g++.dg/cpp0x/variadic35.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic36.C | 15 + gcc/testsuite/g++.dg/cpp0x/variadic37.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic38.C | 6 + gcc/testsuite/g++.dg/cpp0x/variadic39.C | 13 + gcc/testsuite/g++.dg/cpp0x/variadic4.C | 15 + gcc/testsuite/g++.dg/cpp0x/variadic40.C | 3 + gcc/testsuite/g++.dg/cpp0x/variadic41.C | 3 + gcc/testsuite/g++.dg/cpp0x/variadic42.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic43.C | 8 + gcc/testsuite/g++.dg/cpp0x/variadic44.C | 13 + gcc/testsuite/g++.dg/cpp0x/variadic45.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic46.C | 11 + gcc/testsuite/g++.dg/cpp0x/variadic47.C | 18 + gcc/testsuite/g++.dg/cpp0x/variadic48.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic49.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic5.C | 38 ++ gcc/testsuite/g++.dg/cpp0x/variadic50.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic51.C | 10 + gcc/testsuite/g++.dg/cpp0x/variadic52.C | 7 + gcc/testsuite/g++.dg/cpp0x/variadic53.C | 17 + gcc/testsuite/g++.dg/cpp0x/variadic54.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic55.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic56.C | 19 + gcc/testsuite/g++.dg/cpp0x/variadic57.C | 16 + gcc/testsuite/g++.dg/cpp0x/variadic58.C | 16 + gcc/testsuite/g++.dg/cpp0x/variadic59.C | 4 + gcc/testsuite/g++.dg/cpp0x/variadic6.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic60.C | 1 + gcc/testsuite/g++.dg/cpp0x/variadic61.C | 2 + gcc/testsuite/g++.dg/cpp0x/variadic62.C | 2 + gcc/testsuite/g++.dg/cpp0x/variadic63.C | 2 + gcc/testsuite/g++.dg/cpp0x/variadic64.C | 19 + gcc/testsuite/g++.dg/cpp0x/variadic65.C | 8 + gcc/testsuite/g++.dg/cpp0x/variadic66.C | 9 + gcc/testsuite/g++.dg/cpp0x/variadic67.C | 24 + gcc/testsuite/g++.dg/cpp0x/variadic68.C | 23 + gcc/testsuite/g++.dg/cpp0x/variadic69.C | 34 ++ gcc/testsuite/g++.dg/cpp0x/variadic7.C | 33 ++ gcc/testsuite/g++.dg/cpp0x/variadic70.C | 22 + gcc/testsuite/g++.dg/cpp0x/variadic71.C | 12 + gcc/testsuite/g++.dg/cpp0x/variadic72.C | 21 + gcc/testsuite/g++.dg/cpp0x/variadic73.C | 33 ++ gcc/testsuite/g++.dg/cpp0x/variadic74.C | 26 + gcc/testsuite/g++.dg/cpp0x/variadic75.C | 33 ++ gcc/testsuite/g++.dg/cpp0x/variadic8.C | 23 + gcc/testsuite/g++.dg/cpp0x/variadic9.C | 38 ++ 94 files changed, 2473 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-bind.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-function.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic1.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic10.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic11.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic12.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic13.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic14.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic15.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic16.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic17.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic18.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic19.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic20.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic21.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic22.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic23.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic24.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic25.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic26.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic27.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic28.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic29.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic3.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic30.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic31.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic32.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic33.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic34.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic35.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic36.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic37.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic38.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic39.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic4.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic40.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic41.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic42.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic43.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic44.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic45.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic46.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic47.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic48.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic49.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic5.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic50.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic51.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic52.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic53.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic54.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic55.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic56.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic57.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic58.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic59.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic6.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic60.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic61.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic62.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic63.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic64.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic65.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic66.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic67.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic68.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic69.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic7.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic70.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic71.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic72.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic73.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic74.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic75.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic8.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic9.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9c1c3f72e4..d71b94f9810 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,100 @@ +2007-03-09 Douglas Gregor + + PR c++/20599 + * g++.dg/cpp0x/variadic-bind.C: New. + * g++.dg/cpp0x/variadic-function.C: New. + * g++.dg/cpp0x/variadic-mem_fn.C: New. + * g++.dg/cpp0x/variadic-tuple.C: New. + * g++.dg/cpp0x/variadic1.C: New. + * g++.dg/cpp0x/variadic2.C: New. + * g++.dg/cpp0x/variadic3.C: New. + * g++.dg/cpp0x/variadic4.C: New. + * g++.dg/cpp0x/variadic5.C: New. + * g++.dg/cpp0x/variadic6.C: New. + * g++.dg/cpp0x/variadic7.C: New. + * g++.dg/cpp0x/variadic8.C: New. + * g++.dg/cpp0x/variadic9.C: New. + * g++.dg/cpp0x/variadic10.C: New. + * g++.dg/cpp0x/variadic11.C: New. + * g++.dg/cpp0x/variadic12.C: New. + * g++.dg/cpp0x/variadic13.C: New. + * g++.dg/cpp0x/variadic14.C: New. + * g++.dg/cpp0x/variadic15.C: New. + * g++.dg/cpp0x/variadic16.C: New. + * g++.dg/cpp0x/variadic17.C: New. + * g++.dg/cpp0x/variadic18.C: New. + * g++.dg/cpp0x/variadic19.C: New. + * g++.dg/cpp0x/variadic20.C: New. + * g++.dg/cpp0x/variadic21.C: New. + * g++.dg/cpp0x/variadic22.C: New. + * g++.dg/cpp0x/variadic23.C: New. + * g++.dg/cpp0x/variadic24.C: New. + * g++.dg/cpp0x/variadic25.C: New. + * g++.dg/cpp0x/variadic26.C: New. + * g++.dg/cpp0x/variadic27.C: New. + * g++.dg/cpp0x/variadic28.C: New. + * g++.dg/cpp0x/variadic29.C: New. + * g++.dg/cpp0x/variadic30.C: New. + * g++.dg/cpp0x/variadic31.C: New. + * g++.dg/cpp0x/variadic32.C: New. + * g++.dg/cpp0x/variadic33.C: New. + * g++.dg/cpp0x/variadic34.C: New. + * g++.dg/cpp0x/variadic35.C: New. + * g++.dg/cpp0x/variadic36.C: New. + * g++.dg/cpp0x/variadic37.C: New. + * g++.dg/cpp0x/variadic38.C: New. + * g++.dg/cpp0x/variadic39.C: New. + * g++.dg/cpp0x/variadic40.C: New. + * g++.dg/cpp0x/variadic41.C: New. + * g++.dg/cpp0x/variadic42.C: New. + * g++.dg/cpp0x/variadic43.C: New. + * g++.dg/cpp0x/variadic44.C: New. + * g++.dg/cpp0x/variadic45.C: New. + * g++.dg/cpp0x/variadic46.C: New. + * g++.dg/cpp0x/variadic47.C: New. + * g++.dg/cpp0x/variadic48.C: New. + * g++.dg/cpp0x/variadic49.C: New. + * g++.dg/cpp0x/variadic50.C: New. + * g++.dg/cpp0x/variadic51.C: New. + * g++.dg/cpp0x/variadic52.C: New. + * g++.dg/cpp0x/variadic53.C: New. + * g++.dg/cpp0x/variadic54.C: New. + * g++.dg/cpp0x/variadic55.C: New. + * g++.dg/cpp0x/variadic56.C: New. + * g++.dg/cpp0x/variadic57.C: New. + * g++.dg/cpp0x/variadic58.C: New. + * g++.dg/cpp0x/variadic59.C: New. + * g++.dg/cpp0x/variadic60.C : New. + * g++.dg/cpp0x/variadic61.C : New. + * g++.dg/cpp0x/variadic62.C : New. + * g++.dg/cpp0x/variadic63.C : New. + * g++.dg/cpp0x/variadic64.C : New. + * g++.dg/cpp0x/variadic65.C : New. + * g++.dg/cpp0x/variadic66.C : New. + * g++.dg/cpp0x/variadic67.C : New. + * g++.dg/cpp0x/variadic68.C : New. + * g++.dg/cpp0x/variadic69.C : New. + * g++.dg/cpp0x/variadic70.C : New. + * g++.dg/cpp0x/variadic71.C : New. + * g++.dg/cpp0x/variadic72.C : New. + * g++.dg/cpp0x/variadic73.C : New. + * g++.dg/cpp0x/variadic74.C : New. + * g++.dg/cpp0x/variadic75.C : New. + * g++.dg/cpp0x/variadic-ex1.C : New. + * g++.dg/cpp0x/variadic-ex2.C : New. + * g++.dg/cpp0x/variadic-ex3.C : New. + * g++.dg/cpp0x/variadic-ex4.C : New. + * g++.dg/cpp0x/variadic-ex5.C : New. + * g++.dg/cpp0x/variadic-ex6.C : New. + * g++.dg/cpp0x/variadic-ex7.C : New. + * g++.dg/cpp0x/variadic-ex8.C : New. + * g++.dg/cpp0x/variadic-ex9.C : New. + * g++.dg/cpp0x/variadic-ex10.C : New. + * g++.dg/cpp0x/variadic-ex11.C : New. + * g++.dg/cpp0x/variadic-ex12.C : New. + * g++.dg/cpp0x/variadic-ex13.C : New. + * g++.dg/cpp0x/variadic-ex14.C : New. + 2007-03-09 Jerry DeLisle PR libgfortran/31099 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C b/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C new file mode 100644 index 00000000000..b9f9f678c57 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C @@ -0,0 +1,476 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do "run" } +// A basic implementation of TR1's bind using variadic teplates +// Contributed by Douglas Gregor +#include + +// Trivial reference_wrapper +template +struct reference_wrapper +{ + reference_wrapper(T& x) : ptr(&x) { } + + operator T&() const { return *ptr; } + + T& get() const { return *ptr; } + + T* ptr; +}; + +template reference_wrapper ref(T& x) { return x; } +template reference_wrapper cref(const T& x) { return x; } + +// Simple type-traits we'll need +template +struct add_reference +{ + typedef T& type; +}; + +template +struct add_reference +{ + typedef T& type; +}; + +template +struct is_same +{ + static const bool value = false; +}; + +template +struct is_same +{ + static const bool value = true; +}; + +// For creating the constructor parameters of tuple<> +template +struct add_const_reference +{ + typedef const T& type; +}; + +template +struct add_const_reference +{ + typedef T& type; +}; + +// 6.1.3 Class template tuple: Needed for bind() implementation +template +class tuple; + +template<> class tuple<> { }; + +template +class tuple + : private tuple +{ + typedef tuple inherited; + + public: + tuple() { } + + // implicit copy-constructor is okay + + tuple(typename add_const_reference::type v, + typename add_const_reference::type... vtail) + : m_head(v), inherited(vtail...) { } + + template + tuple(const tuple& other) + : m_head(other.head()), inherited(other.tail()) { } + + template + tuple& operator=(const tuple& other) + { + m_head = other.head(); + tail() = other.tail(); + return *this; + } + + typename add_reference::type head() { return m_head; } + typename add_reference::type head() const { return m_head; } + inherited& tail() { return *this; } + const inherited& tail() const { return *this; } + + protected: + Head m_head; +}; + +template +struct make_tuple_result +{ + typedef T type; +}; + +template +struct make_tuple_result > +{ + typedef T& type; +}; + +// 6.1.3.2 Tuple creation functions +struct ignore_t { + template ignore_t& operator=(const T&) { return *this; } +} ignore; + +template +tuple::type...> +make_tuple(const Values&... values) +{ + return tuple::type...>(values...); +} + +template +tuple tie(Values&... values) +{ + return tuple(values...); +} + +// 6.1.3.3 Tuple helper classes +template +struct tuple_size; + +template<> +struct tuple_size > +{ + static const __SIZE_TYPE__ value = 0; +}; + +template +struct tuple_size > +{ + static const __SIZE_TYPE__ value = 1 + tuple_size >::value; +}; + +template +struct tuple_element; + +template +struct tuple_element > +{ + typedef typename tuple_element >::type type; +}; + +template +struct tuple_element<0, tuple > +{ + typedef Head type; +}; + +// 6.1.3.4 Element access +template +class get_impl; + +template +class get_impl > +{ + typedef typename tuple_element >::type Element; + typedef typename add_reference::type RJ; + typedef typename add_const_reference::type PJ; + typedef get_impl > Next; + + public: + static RJ get(tuple& t) + { return Next::get(t.tail()); } + + static PJ get(const tuple& t) + { return Next::get(t.tail()); } +}; + +template +class get_impl<0, tuple > +{ + typedef typename add_reference::type RJ; + typedef typename add_const_reference::type PJ; + + public: + static RJ get(tuple& t) { return t.head(); } + static PJ get(const tuple& t) { return t.head(); } +}; + +template +typename add_reference< + typename tuple_element >::type + >::type +get(tuple& t) +{ + return get_impl >::get(t); +} + +template +typename add_const_reference< + typename tuple_element >::type + >::type +get(const tuple& t) +{ + return get_impl >::get(t); +} + +// 6.1.3.5 Relational operators +inline bool operator==(const tuple<>&, const tuple<>&) { return true; } + +template +bool operator==(const tuple& t, const tuple& u) +{ + return t.head() == u.head() && t.tail() == u.tail(); +} + +template +bool operator!=(const tuple& t, const tuple& u) +{ + return !(t == u); +} + +inline bool operator<(const tuple<>&, const tuple<>&) { return false; } + +template +bool operator<(const tuple& t, const tuple& u) +{ + return (t.head() < u.head() || + (!(t.head() < u.head()) && t.tail() < u.tail())); +} + +template +bool operator>(const tuple& t, const tuple& u) +{ + return u < t; +} + +template +bool operator<=(const tuple& t, const tuple& u) +{ + return !(u < t); +} + +template +bool operator>=(const tuple& t, const tuple& u) +{ + return !(t < u); +} + +// enable_if, the breakfast of champions +template +struct enable_if { + typedef Type type; +}; + +template +struct enable_if { }; + +// 3.6 Function object binders + +// 3.6.1 Class template is_bind_expression +template +struct is_bind_expression { + static const bool value = false; +}; + +// 3.6.2 Class template is_placeholder +template +struct is_placeholder { + static const int value = 0; +}; + +// 3.6.3 Function template bind +template struct placeholder {} ; + +template struct int_c { }; + +// A tuple of integer values +template struct int_tuple {}; + +// make_indexes_impl is a helper for make_indexes +template +struct make_indexes_impl; + + +template +struct make_indexes_impl, T, Types...> +{ + typedef typename make_indexes_impl, + Types...>::type type; +}; + +template +struct make_indexes_impl > { + typedef int_tuple type; +}; + +// make_indexes takes a variable-length number of N types and +// generates an int_tuple that contains <0, 1, 2, ..., N-1>. These can +// be used as indexes for tuple's get or tuple_element operation. +template +struct make_indexes : make_indexes_impl<0, int_tuple<>, Types...> { }; + +// Get the Ith tuple element, but only if I is in bounds. +template +struct safe_tuple_element{ }; + +template +struct safe_tuple_element, + typename enable_if<(I >= 0 && + I < tuple_size >::value) + >::type> +{ + typedef typename tuple_element >::type type; +}; + +// mu maps a bound argument to an actual argument, given a tuple of +// the arguments passed to the function object returned by bind(). + +// Return the stored reference from reference_wrapper +template +inline T& mu(reference_wrapper& bound_arg, const tuple&) +{ + return bound_arg.get(); +} + +// Unwrap a tuple into separate arguments and forward to the function +// object f. +template +inline typename F::result_type +unwrap_and_forward(F& f, int_tuple, const tuple& args) +{ + return f(get(args)...); +} + +// Evaluate the inner bind expression +template +inline typename enable_if::value, + typename Bound::result_type>::type +mu(Bound& bound_arg, const tuple& args) +{ + typedef typename make_indexes::type Indexes; + return unwrap_and_forward(bound_arg, Indexes(), args); +} + +// Retrieve the Ith argument from args +template +inline typename safe_tuple_element::value - 1, + tuple >::type +mu(Bound& bound_arg, const tuple& args) +{ + return get::value-1>(args); +} + +// Return the stored value. +template +struct is_reference_wrapper { + static const bool value = false; +}; + +template +struct is_reference_wrapper > { + static const bool value = true; +}; + +template +inline typename enable_if<(!is_bind_expression::value + && !is_placeholder::value + && !is_reference_wrapper::value), + Bound&>::type +mu(Bound& bound_arg, const tuple&) +{ + return bound_arg; +} + +// +template +typename F::result_type +apply_functor(F& f, tuple& bound_args, int_tuple, + const tuple& args) +{ + return f(mu(get(bound_args), args)...); +} + +template +class bound_functor +{ + typedef typename make_indexes::type indexes; + + public: + typedef typename F::result_type result_type; + + explicit bound_functor(const F& f, const BoundArgs&... bound_args) + : f(f), bound_args(bound_args...) { } + + template + typename F::result_type operator()(Args&... args) { + return apply_functor(f, bound_args, indexes(), tie(args...)); + } + + private: + F f; + tuple bound_args; +}; + +template +struct is_bind_expression > { + static const bool value = true; +}; + +template +inline bound_functor +bind(const F& f, const BoundArgs&... bound_args) +{ + return bound_functor(f, bound_args...); +} + + +// 3.6.4 Placeholders +template +struct is_placeholder > { + static const int value = I; +}; + +placeholder<1> _1; +placeholder<2> _2; +placeholder<3> _3; +placeholder<4> _4; +placeholder<5> _5; +placeholder<6> _6; +placeholder<7> _7; +placeholder<8> _8; +placeholder<9> _9; + +// Test code +template +struct plus { + typedef T result_type; + + T operator()(T x, T y) { return x + y; } +}; + +template +struct multiplies { + typedef T result_type; + + T operator()(T x, T y) { return x * y; } +}; + +template +struct negate { + typedef T result_type; + + T operator()(T x) { return -x; } +}; + +int main() +{ + int seventeen = 17; + int forty_two = 42; + + assert(bind(plus(), _1, _2)(seventeen, forty_two) == 59); + assert(bind(plus(), _1, _1)(seventeen, forty_two) == 34); + assert(bind(plus(), _2, _1)(seventeen, forty_two) == 59); + assert(bind(plus(), 5, _1)(seventeen, forty_two) == 22); + assert(bind(plus(), ref(seventeen), _2)(seventeen, forty_two) == 59); + assert(bind(plus(), bind(multiplies(), 3, _1), _2)(seventeen, forty_two) + == 93); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C new file mode 100644 index 00000000000..d5ebf0def3c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C @@ -0,0 +1,4 @@ +// { dg-options "-std=gnu++0x" } +template class Tuple; +Tuple<>* t; // OK: Elements is empty +Tuple* u; // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C new file mode 100644 index 00000000000..a392bd7d43f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template struct Tuple { }; + +Tuple<> t0; // Types contains no arguments +Tuple t1; // Types contains one argument: int +Tuple t2; // Types contains two arguments: int and float +Tuple<0> error; // { dg-error "mismatch" } +// { dg-error "expected a type" "" { target *-*-* } 7 } +// { dg-error "in declaration" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C new file mode 100644 index 00000000000..57ef2a3d30e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template + void f(Types... args); + +void g() { + f(); // okay: args contains no arguments + f(1); // okay: args contains one int argument + (2, 1.0); // okay: args contains two arguments, an int and a double +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C new file mode 100644 index 00000000000..b97df310203 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template + void f(Types... rest); + +template + void g(Types... rest) { + f(&rest...); // ``&rest...'' is a pack expansion, ``&rest'' is its pattern + } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C new file mode 100644 index 00000000000..f1cce3a4363 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +template struct is_same { + static const bool value = false; +}; + +template struct is_same { + static const bool value = true; +}; + +template struct Tuple {}; +template struct Pair {}; + +template + struct zip { + template + struct with { + typedef Tuple...> type; // { dg-error "mismatched argument pack" } + }; + }; + +static_assert + (is_same::with::type, + Tuple, Pair > >::value, + "zip"); + +typedef zip::with::type T2; // error: different number of arguments specified + // for Args1 and Args2 + +template void f(Args...); + +template void g(Args... args) +{ + f(const_cast(&args)...); // okay: ``Args'' and ``args'' are expanded + f(5 ...); // { dg-error "contains no argument packs" } + f(args); // { dg-error "parameter packs not expanded" } + // { dg-error "args" "" { target *-*-* } 36 } + f(h(args...) + args...); // okay: first ``args'' expanded within h, second ``args'' expanded within f. +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C new file mode 100644 index 00000000000..7050256d437 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } + +template class A { /* ... */ }; +template class B { /* ... */ }; +template class C { /* ... */ }; + +template class P> class X { /* ... */ }; +template class Q> class Y { /* ... */ }; + +X xA; // okay +X xB; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 11 } +// { dg-error "invalid type" "" { target *-*-* } 11 } +X xC; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 14 } +// { dg-error "invalid type" "" { target *-*-* } 14 } +Y yA; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 17 } +// { dg-error "invalid type" "" { target *-*-* } 17 } +Y yB; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 20 } +// { dg-error "invalid type" "" { target *-*-* } 20 } +Y yC; // okay diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C new file mode 100644 index 00000000000..ca5fa271637 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template struct B { // { dg-error "declaration of" } + void f3(); + void f4(); +}; + +template void B::f3() { } // OK +template void B::f4() { } // { dg-error "invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C new file mode 100644 index 00000000000..8b8ca9e312d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template X f(Y); +void g() +{ + int i = f(5.6); + int j = f(5.6); // { dg-error "no matching" } + f(f); + f(f); // { dg-error "no matching" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C new file mode 100644 index 00000000000..69866dcb13d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template X f(Y,Z); +template void f2(); +void g() +{ + f("aa",3.0); + f("aa",3.0); // Z is deduced to be double + f("aa",3.0); // Y is deduced to be char*, and + // Z is deduced to be double + f("aa",3.0); // { dg-error "no matching" } + f2(); // okay +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C new file mode 100644 index 00000000000..2439a51c5a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template void f(Types... values); + +void g() +{ + f(0, 0, 0); // Types is deduced to the sequence int*, float*, int +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C new file mode 100644 index 00000000000..87b1bf20576 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template struct Tuple { }; + +template void f(Types&...); +template void g(Tuple, Tuple); + +void h(int x, float& y) +{ + const int z = x; + f(x, y, z); // Types is deduced to int, const int, float + g(Tuple(), Tuple()); // Types1 is deduced to short, int long + // Types2 is deduced to float, double +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C new file mode 100644 index 00000000000..7ca31f9c67b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template struct Tuple { }; +template char& g(Tuple); // #1 +template short& g(Tuple); // #2 +template int& g(Tuple); // #3 + +void f() { + // char& x1 = g(Tuple<>()); // calls #1 + short& y1 = g(Tuple()); // calls #2 + // int& z1 = g(Tuple()); // calls #3 + // int& z2 = g(Tuple()); // calls #3 + // int& z3 = g(Tuple()); // calls #3 +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C new file mode 100644 index 00000000000..03d28b82535 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template struct X { static const bool primary = true; }; +template struct X { + static const bool primary = false; +}; +template struct Y { static const bool primary = true; }; +template struct Y { + static const bool primary = false; +}; + +static_assert (X::primary, "uses primary template"); +static_assert (!X::primary, + "uses partial specialization"); +static_assert (X::primary, "uses primary template"); +static_assert (Y<>::primary, "uses primary template"); +static_assert (!Y::primary, + "uses partial specialization"); +static_assert (Y::primary, "uses primary template"); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C new file mode 100644 index 00000000000..ec78a7a8e25 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template char& f(Args... args); // #1 +template short& f(T1 a1, Args... args); // #2 +template int& f(T1 a2, T2 a2); // #3 + +void g() { + char& x = f(); // calls #1 + short& y = f(1, 2, 3); // calls #2 + int& z = f(1, 2); // calls #3 +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-function.C b/gcc/testsuite/g++.dg/cpp0x/variadic-function.C new file mode 100644 index 00000000000..0373efde7c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-function.C @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do "run" } +// A basic implementation of TR1's function using variadic teplates +// Contributed by Douglas Gregor +#include + +template +class function; + +template +class invoker_base +{ + public: + virtual ~invoker_base() { } + virtual R invoke(Args...) = 0; + virtual invoker_base* clone() = 0; +}; + +template +class functor_invoker : public invoker_base +{ + public: + explicit functor_invoker(const F& f) : f(f) { } + R invoke(Args... args) { return f(args...); } + functor_invoker* clone() { return new functor_invoker(f); } + + private: + F f; +}; + +template +class function { + public: + typedef R result_type; + + function() : invoker (0) { } + + function(const function& other) : invoker(0) { + if (other.invoker) + invoker = other.invoker->clone(); + } + + template + function(const F& f) : invoker(0) { + invoker = new functor_invoker(f); + } + + ~function() { + if (invoker) + delete invoker; + } + + function& operator=(const function& other) { + function(other).swap(*this); + return *this; + } + + template + function& operator=(const F& f) { + function(f).swap(*this); + return *this; + } + + void swap(function& other) { + invoker_base* tmp = invoker; + invoker = other.invoker; + other.invoker = tmp; + } + + result_type operator()(Args... args) const { + assert(invoker); + return invoker->invoke(args...); + } + + private: + invoker_base* invoker; +}; + +struct plus { + template T operator()(T x, T y) { return x + y; } +}; + +struct multiplies { + template T operator()(T x, T y) { return x * y; } +}; + +int main() +{ + function f1 = plus(); + assert(f1(3, 5) == 8); + + f1 = multiplies(); + assert(f1(3, 5) == 15); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C b/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C new file mode 100644 index 00000000000..6e29d3b3d95 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do "run" } +// A basic implementation of TR1's mem_fn using variadic teplates +// Contributed by Douglas Gregor +#include + +template +class Mem_fn +{ + public: + explicit Mem_fn(R (Class::*pmf)(Args...)) : pmf(pmf) { } + + R operator()(Class& object, Args... args) + { + return (object.*pmf)(args...); + } + + R operator()(Class* object, Args... args) + { + return (object->*pmf)(args...); + } + + R (Class::*pmf)(Args...); +}; + +template +inline Mem_fn +mem_fn(R (Class::* pmf)(Args...)) +{ + return Mem_fn(pmf); +} + +class X { + public: + int negate(int x) { return -x; } + int plus(int x, int y) { return x + y; } +}; + +int main() +{ + X x; + X* xp = &x; + + assert(mem_fn(&X::negate)(x, 17) == -17); + assert(mem_fn(&X::negate)(xp, 17) == -17); + assert(mem_fn(&X::plus)(x, 17, 25) == 42); + assert(mem_fn(&X::plus)(xp, 17, 25) == 42); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C b/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C new file mode 100644 index 00000000000..2c298a132b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C @@ -0,0 +1,294 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do "run" } +// An implementation of TR1's using variadic teplates +// Contributed by Douglas Gregor + +#include +#include +#include + +// Trivial reference_wrapper +template +struct reference_wrapper +{ + reference_wrapper(T& x) : ptr(&x) { } + + operator T&() const { return *ptr; } + + T* ptr; +}; + +template reference_wrapper ref(T& x) { return x; } +template reference_wrapper cref(const T& x) { return x; } + +// Simple type-traits we'll need +template +struct add_reference +{ + typedef T& type; +}; + +template +struct add_reference +{ + typedef T& type; +}; + +template +struct is_same +{ + static const bool value = false; +}; + +template +struct is_same +{ + static const bool value = true; +}; + +// For creating the constructor parameters of tuple<> +template +struct add_const_reference +{ + typedef const T& type; +}; + +template +struct add_const_reference +{ + typedef T& type; +}; + +// 6.1.3 Class template tuple +template +class tuple; + +template<> class tuple<> { }; + +template +class tuple + : private tuple +{ + typedef tuple inherited; + + public: + tuple() { } + + // implicit copy-constructor is okay + + tuple(typename add_const_reference::type v, + typename add_const_reference::type... vtail) + : m_head(v), inherited(vtail...) { } + + template + tuple(const tuple& other) + : m_head(other.head()), inherited(other.tail()) { } + + template + tuple& operator=(const tuple& other) + { + m_head = other.head(); + tail() = other.tail(); + return *this; + } + + typename add_reference::type head() { return m_head; } + typename add_reference::type head() const { return m_head; } + inherited& tail() { return *this; } + const inherited& tail() const { return *this; } + + protected: + Head m_head; +}; + +template +struct make_tuple_result +{ + typedef T type; +}; + +template +struct make_tuple_result > +{ + typedef T& type; +}; + +// 6.1.3.2 Tuple creation functions +struct ignore_t { + template ignore_t& operator=(const T&) { return *this; } +} ignore; + +template +tuple::type...> +make_tuple(const Values&... values) +{ + return tuple::type...>(values...); +} + +template +tuple tie(Values&... values) +{ + return tuple(values...); +} + +// 6.1.3.3 Tuple helper classes +template +struct tuple_size; + +template<> +struct tuple_size > +{ + static const std::size_t value = 0; +}; + +template +struct tuple_size > +{ + static const std::size_t value = 1 + tuple_size >::value; +}; + +template +struct tuple_element; + +template +struct tuple_element > +{ + typedef typename tuple_element >::type type; +}; + +template +struct tuple_element<0, tuple > +{ + typedef Head type; +}; + +// 6.1.3.4 Element access +template +class get_impl; + +template +class get_impl > +{ + typedef typename tuple_element >::type Element; + typedef typename add_reference::type RJ; + typedef typename add_const_reference::type PJ; + typedef get_impl > Next; + + public: + static RJ get(tuple& t) + { return Next::get(t.tail()); } + + static PJ get(const tuple& t) + { return Next::get(t.tail()); } +}; + +template +class get_impl<0, tuple > +{ + typedef typename add_reference::type RJ; + typedef typename add_const_reference::type PJ; + + public: + static RJ get(tuple& t) { return t.head(); } + static PJ get(const tuple& t) { return t.head(); } +}; + +template +typename add_reference< + typename tuple_element >::type + >::type +get(tuple& t) +{ + return get_impl >::get(t); +} + +template +typename add_const_reference< + typename tuple_element >::type + >::type +get(const tuple& t) +{ + return get_impl >::get(t); +} + +// 6.1.3.5 Relational operators +inline bool operator==(const tuple<>&, const tuple<>&) { return true; } + +template +bool operator==(const tuple& t, const tuple& u) +{ + return t.head() == u.head() && t.tail() == u.tail(); +} + +template +bool operator!=(const tuple& t, const tuple& u) +{ + return !(t == u); +} + +inline bool operator<(const tuple<>&, const tuple<>&) { return false; } + +template +bool operator<(const tuple& t, const tuple& u) +{ + return (t.head() < u.head() || + (!(t.head() < u.head()) && t.tail() < u.tail())); +} + +template +bool operator>(const tuple& t, const tuple& u) +{ + return u < t; +} + +template +bool operator<=(const tuple& t, const tuple& u) +{ + return !(u < t); +} + +template +bool operator>=(const tuple& t, const tuple& u) +{ + return !(t < u); +} + +int a0[tuple_size >::value == 0? 1 : -1]; +int a1[tuple_size >::value == 3? 1 : -1]; +int a2a[is_same >::type, int> + ::value? 1 : -1]; +int a2b[is_same >::type, float> + ::value? 1 : -1]; +int a2c[is_same >::type, double> + ::value? 1 : -1]; + +int main() +{ + tuple<> t0; + tuple t1(1); + tuple t2(1, 3.14159f); + tuple t3a(1, 3.14159f, "Hello, world!"); + tuple t3b(t3a); + t3b = t3a; + // t3a = t3b; DPG: triggers an error, as it should. + + tuple t3c = + make_tuple(17, 2.718281828, std::string("Fun")); + + int seventeen = 17; + double pi = 3.14159; + tuple seventeen_pi = make_tuple(ref(seventeen), ref(pi)); + tuple seventeen_pi2 = + make_tuple(ref(seventeen), cref(pi)); + tuple seventeen_pi_tied = tie(seventeen, pi); + assert(get<0>(t3a) == 1); + assert(get<1>(t3a) == 3.14159f); + assert(std::strcmp(get<2>(t3a), "Hello, world!") == 0); + + assert(t3a == t3b); + assert(!(t3a != t3b)); + assert(!(t3a < t3b)); + assert(!(t3a > t3b)); + assert(t3a <= t3b && t3b <= t3a); + assert(t3a >= t3b && t3b >= t3a); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic1.C b/gcc/testsuite/g++.dg/cpp0x/variadic1.C new file mode 100644 index 00000000000..f87d53ca386 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic1.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +class tuple; + +template +class tuple { }; + +template +class tuple1p { }; + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic10.C b/gcc/testsuite/g++.dg/cpp0x/variadic10.C new file mode 100644 index 00000000000..5f73eba8d68 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic10.C @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++0x" } +template +struct pair {}; + +template +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple > { }; + +template +struct X { + template + struct Y + { + typedef tuple...> type; // { dg-error "mismatched argument pack lengths" } + }; +}; + +X::Y::type honk; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic11.C b/gcc/testsuite/g++.dg/cpp0x/variadic11.C new file mode 100644 index 00000000000..3c27de0fb19 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic11.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template struct count; + +template<> +struct count<> { + static const int value = 0; +}; + +template +struct count { + static const int value = 1 + count::value; +}; + +int a0[count<>::value == 0? 1 : -1]; +int a1[count::value == 1? 1 : -1]; +int a2[count::value == 2? 1 : -1]; +int a3[count::value == 3? 1 : -1]; +int a4[count::value == 4? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic12.C b/gcc/testsuite/g++.dg/cpp0x/variadic12.C new file mode 100644 index 00000000000..30108c99932 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic12.C @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// A tuple type +template struct tuple { }; + +// Determine if two types are the same +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +// Append 'T' to the end of Tuple +template +struct append_to_tuple; + +template +struct append_to_tuple > { + typedef tuple type; +}; + +// Reverse a sequence of arguments (and return the result as a tuple) +template struct reverse; + +template +struct reverse { + typedef typename append_to_tuple::type>::type + type; +}; + +template<> +struct reverse<> { + typedef tuple<> type; +}; + +int a0[is_same::type, tuple<> >::value? 1 : -1]; +int a1[is_same::type, tuple >::value? 1 : -1]; +int a2[is_same::type, tuple >::value? 1 : -1]; +int a3[is_same::type, tuple >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic13.C b/gcc/testsuite/g++.dg/cpp0x/variadic13.C new file mode 100644 index 00000000000..7794e8a3dc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic13.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template struct tuple1 { }; +template struct tuple2 { }; + +template +struct same_tuple_args { + static const bool value = false; +}; + +template +struct same_tuple_args, tuple2 > { + static const bool value = true; +}; + +int same0[same_tuple_args, tuple2<> >::value? 1 : -1]; +int same1[same_tuple_args, tuple2 >::value? 1 : -1]; +int same2[same_tuple_args, tuple2 >::value? 1 : -1]; +int diff0[!same_tuple_args, tuple2 >::value? 1 : -1]; +int diff1[!same_tuple_args, tuple2 >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic14.C b/gcc/testsuite/g++.dg/cpp0x/variadic14.C new file mode 100644 index 00000000000..3c1bb0d6d23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic14.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template +struct make_function_type +{ + typedef R type(ArgTypes...); +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int a0[is_same::type, int()>::value? 1 : -1]; +int a1[is_same::type, int(float)>::value? 1 : -1]; +int a2[is_same::type, int(float)>::value? 1 : -1]; +int a3[is_same::type, int(float, double)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic15.C b/gcc/testsuite/g++.dg/cpp0x/variadic15.C new file mode 100644 index 00000000000..68786cb8229 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic15.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template +struct make_function_type +{ + typedef R type(const ArgTypes&...); +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int a0[is_same::type, int()>::value? 1 : -1]; +int a1[is_same::type, int(const float&)>::value? 1 : -1]; +int a2[is_same::type, int(const float&)>::value? 1 : -1]; +int a3[is_same::type, int(const float&, double const&)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic16.C b/gcc/testsuite/g++.dg/cpp0x/variadic16.C new file mode 100644 index 00000000000..001919d469f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic16.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template +struct make_function_type +{ + typedef R type(const ArgTypes&... args); +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int a0[is_same::type, int()>::value? 1 : -1]; +int a1[is_same::type, int(const float&)>::value? 1 : -1]; +int a2[is_same::type, int(const float&)>::value? 1 : -1]; +int a3[is_same::type, int(const float&, double const&)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic17.C b/gcc/testsuite/g++.dg/cpp0x/variadic17.C new file mode 100644 index 00000000000..986721bbec3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic17.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template +struct make_function_type +{ + typedef R type(const ArgTypes&......); +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int a0[is_same::type, int(...)>::value? 1 : -1]; +int a1[is_same::type, int(const float&...)>::value? 1 : -1]; +int a2[is_same::type, int(const float&,...)>::value? 1 : -1]; +int a3[is_same::type, int(const float&, double const&...)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic18.C b/gcc/testsuite/g++.dg/cpp0x/variadic18.C new file mode 100644 index 00000000000..147ed8e4bfc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic18.C @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +template class tuple { }; + +template class... Metafunctions> +struct apply_all +{ + typedef tuple::type...> type; +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +template +struct add_pointer { + typedef T* type; +}; + +template +struct add_pointer +{ + typedef T& type; +}; + +template +struct add_reference { + typedef T& type; +}; + +template +struct add_reference +{ + typedef T& type; +}; + +int a0[is_same::type,tuple<> >::value? 1 : -1]; +int a1[is_same::type,tuple >::value? 1 : -1]; +int a2[is_same::type,tuple >::value? 1 : -1]; +int a3[is_same::type,tuple >::value? 1 : -1]; + + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic19.C b/gcc/testsuite/g++.dg/cpp0x/variadic19.C new file mode 100644 index 00000000000..92e7a953aba --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic19.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple { + static const int value = 0; +}; + +template class... Metafunctions> +struct tuple...> { + static const int value = 1; +}; + +template struct add_pointer; +template struct add_reference; + +int a0[tuple::value == 0? 1 : -1]; +int a1[tuple, add_pointer >::value == 0? 1 : -1]; +int a2[tuple<>::value == 0? 1 : -1]; +int a3[tuple >::value == 1? 1 : -1]; +int a4[tuple, add_reference >::value == 1? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic2.C b/gcc/testsuite/g++.dg/cpp0x/variadic2.C new file mode 100644 index 00000000000..d62a54245e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic2.C @@ -0,0 +1,17 @@ +// { dg-options "-std=gnu++0x" } +template // { dg-error "default argument" } +class tuple2; + +template // { dg-error "default argument" } +class tuple3; + +template +struct two_or_more {}; // { dg-error "provided for" } + +typedef two_or_more bad; // { dg-error "2 or more" } +// { dg-error "invalid type" "" { target *-*-* } 11 } + +void f() +{ + two_or_more z = 5; // { dg-error "two_or_more" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic20.C b/gcc/testsuite/g++.dg/cpp0x/variadic20.C new file mode 100644 index 00000000000..06204c75dd5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic20.C @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +template struct add_pointer; +template struct add_reference; + +template class... Metafunctions> +struct metatuple { + static const int value = 0; +}; + +template<> +struct metatuple { + static const int value = 1; +}; + +template class Meta> +struct metatuple { // { dg-error "candidates" } + static const int value = 2; +}; + +template class... Metafunctions> +struct metatuple { // { dg-error "" } + static const int value = 3; +}; + +template class First, + template class... Metafunctions> +struct metatuple { // { dg-error "struct" } + static const int value = 4; +}; + +template class First, + template class Second, + template class... Metafunctions> +struct metatuple { // { dg-error "struct" } + static const int value = 5; +}; + +int a0[metatuple<>::value == 0? 1 : -1]; +int a1[metatuple::value == 1? 1 : -1]; +int a2a[metatuple::value == 2? 1 : -1]; // { dg-error "ambiguous" } +int a2b[metatuple::value == 2? 1 : -1]; +int a3[metatuple::value == 3? 1 : -1]; // { dg-error "ambiguous" } +int a4[metatuple::value == 4? 1 : -1]; +int a5[metatuple::value == 5? 1 : -1]; + +// { dg-error "incomplete" "" { target *-*-* } 40 } +// { dg-error "incomplete" "" { target *-*-* } 42 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic21.C b/gcc/testsuite/g++.dg/cpp0x/variadic21.C new file mode 100644 index 00000000000..b65e995b9a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic21.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template +struct array { }; + +array a0; +array a1; +array a1234; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic22.C b/gcc/testsuite/g++.dg/cpp0x/variadic22.C new file mode 100644 index 00000000000..1d26e40d981 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic22.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template +struct make_function_type +{ + typedef R type(ArgTypes... args); +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int a0[is_same::type, int()>::value? 1 : -1]; +int a1[is_same::type, int(float)>::value? 1 : -1]; +int a2[is_same::type, int(float)>::value? 1 : -1]; +int a3[is_same::type, int(float, double const)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic23.C b/gcc/testsuite/g++.dg/cpp0x/variadic23.C new file mode 100644 index 00000000000..43309a1e1f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic23.C @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +template +struct array { + static const int value = 0; +}; + +template<> +struct array { + static const int value = 1; +}; + +template +struct array { + static const int value = 2; +}; + +template +struct array { + static const int value = 3; +}; + +int a0[array::value == 0? 1 : -1]; +int a1[array::value == 1? 1 : -1]; +int a2[array::value == 2? 1 : -1]; +int a3[array::value == 3? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic24.C b/gcc/testsuite/g++.dg/cpp0x/variadic24.C new file mode 100644 index 00000000000..6ef8e8a77d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic24.C @@ -0,0 +1,6 @@ +// { dg-options "-std=gnu++0x" } +template +struct vector_c { }; + +vector_c intvec; +vector_c charvec; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic25.C b/gcc/testsuite/g++.dg/cpp0x/variadic25.C new file mode 100644 index 00000000000..6589e7f60af --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic25.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +template +struct sum; + +template<> +struct sum<> { + static const int value = 0; +}; + +template +struct sum { + static const int value = Value + sum::value; +}; + +int a0[sum<>::value == 0? 1 : -1]; +int a1[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic26.C b/gcc/testsuite/g++.dg/cpp0x/variadic26.C new file mode 100644 index 00000000000..7f9f6bc8052 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic26.C @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +template class Meta, int Initial, int... Values> +struct accumulate { + static const int value = Initial; +}; + +template class Meta, int Initial, int Value, int... Rest> +struct accumulate { + static const int value = + Meta::value>::value; +}; + +template +struct sum { + static const int value = X + Y; +}; + +template +struct prod { + static const int value = X * Y; +}; + +int a0[accumulate::value == 15? 1 : -1]; +int a1[accumulate::value == 120? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic27.C b/gcc/testsuite/g++.dg/cpp0x/variadic27.C new file mode 100644 index 00000000000..45a897ce2c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic27.C @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++0x" } +template +struct function_traits; + +template +struct function_traits { + typedef R result_type; +}; + +template +struct same_type { + static const bool value = false; +}; + +template +struct same_type { + static const bool value = true; +}; + +int a0[same_type::result_type, int>::value? 1 : -1]; +int a1[same_type::result_type, int>::value? 1 : -1]; +int a2[same_type::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic28.C b/gcc/testsuite/g++.dg/cpp0x/variadic28.C new file mode 100644 index 00000000000..167088b4945 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic28.C @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +template +struct function_traits; + +template +struct function_traits { + typedef R result_type; +}; + +template +struct same_type { + static const bool value = false; +}; + +template +struct same_type { + static const bool value = true; +}; + +int a0[same_type::result_type, int>::value? 1 : -1]; +int a1[same_type::result_type, int>::value? 1 : -1]; +int a2[same_type::result_type, int>::value? 1 : -1]; +int a3[same_type::result_type, int>::value? 1 : -1]; +int a4[same_type::result_type, int>::value? 1 : -1]; +int a5[same_type::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic29.C b/gcc/testsuite/g++.dg/cpp0x/variadic29.C new file mode 100644 index 00000000000..aaed595831d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic29.C @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +template +struct function_traits; + +template +struct function_traits { + typedef R result_type; +}; + +template +struct function_traits { + typedef R result_type; +}; + +template +struct function_traits { + typedef R result_type; +}; + +template +struct same_type { + static const bool value = false; +}; + +template +struct same_type { + static const bool value = true; +}; + +struct X {}; + +int a0[same_type::result_type, int>::value? 1 : -1]; +int a1[same_type::result_type, int>::value? 1 : -1]; +int a2[same_type::result_type, int>::value? 1 : -1]; +int a3[same_type::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic3.C b/gcc/testsuite/g++.dg/cpp0x/variadic3.C new file mode 100644 index 00000000000..42ba8ab47ea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic3.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +class tuple {}; + +void f() +{ + tuple<> x; + tuple y; + tuple z; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic30.C b/gcc/testsuite/g++.dg/cpp0x/variadic30.C new file mode 100644 index 00000000000..66cbe9f6272 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic30.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template +void eat(T...); + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic31.C b/gcc/testsuite/g++.dg/cpp0x/variadic31.C new file mode 100644 index 00000000000..eacf568978a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic31.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template +void eat(T...) { } + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic32.C b/gcc/testsuite/g++.dg/cpp0x/variadic32.C new file mode 100644 index 00000000000..c5bee55ccb7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic32.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template +void eat(const T&...) { } + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic33.C b/gcc/testsuite/g++.dg/cpp0x/variadic33.C new file mode 100644 index 00000000000..5784be887ac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic33.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +void print_all() {} + +template +void print_all(const T& t, const Rest&... rest) +{ + print_all(rest...); +} + +void f() +{ + print_all(); + print_all(1); + print_all(1, 3.14159); + print_all("Hello, World!", 17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic34.C b/gcc/testsuite/g++.dg/cpp0x/variadic34.C new file mode 100644 index 00000000000..5eee3f13c62 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic34.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template +void get_ith(const Args&... args); + +void f() +{ + get_ith<1>(1, 2, 3); + get_ith<1, int>(1, 2.0, 'x'); + get_ith<1, int, double>(1, 2.0, 'x'); + get_ith<1, int, double, char>(1, 2.0, 'x'); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic35.C b/gcc/testsuite/g++.dg/cpp0x/variadic35.C new file mode 100644 index 00000000000..cd6ba2b0a0c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic35.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template +void get_ith(const Args&... args); + +void f() +{ + get_ith<1, float>(1, 2.0, 'x'); + get_ith<1, int, double, char, int>(1, 2.0, 'x'); // { dg-error "no matching function" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic36.C b/gcc/testsuite/g++.dg/cpp0x/variadic36.C new file mode 100644 index 00000000000..370d475eb6d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic36.C @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++0x" } +template +void f(const T&, const Args&... args) +{ + f(args); // { dg-error "packs not expanded" } +} + +template +struct tuple_base { }; + +template +struct tuple : tuple_base { }; // { dg-error "packs not expanded" } + +// { dg-error "args" "" { target *-*-* } 5 } +// { dg-error "Values" "" { target *-*-* } 12 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic37.C b/gcc/testsuite/g++.dg/cpp0x/variadic37.C new file mode 100644 index 00000000000..a6e5f613fcd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic37.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple +{ + static const __SIZE_TYPE__ length = sizeof...(Values); +}; + +int a0[tuple<>::length == 0? 1 : -1]; +int a1[tuple::length == 1? 1 : -1]; +int a2[tuple::length == 2? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic38.C b/gcc/testsuite/g++.dg/cpp0x/variadic38.C new file mode 100644 index 00000000000..e4ae4a6305d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic38.C @@ -0,0 +1,6 @@ +// { dg-options "-std=gnu++0x" } +template +struct int_vec {}; + +template +struct int_vec<0, (Values+1)...> {}; // { dg-error "involves template parameter" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic39.C b/gcc/testsuite/g++.dg/cpp0x/variadic39.C new file mode 100644 index 00000000000..bd656ba8504 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic39.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple {}; + +template +struct tuple { }; // { dg-error "end" } + + +template +struct int_vec { }; + +template +struct int_vec { }; // { dg-error "end" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic4.C b/gcc/testsuite/g++.dg/cpp0x/variadic4.C new file mode 100644 index 00000000000..6c15a6de92d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic4.C @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template +class tuple {}; + +void f_none(tuple<>) {} +void f_one(tuple) {} +void f_two(tuple) {} +void f_nested(tuple, float>) { } + + +// { dg-final { scan-assembler "_Z6f_none5tupleIE" } } +// { dg-final { scan-assembler "_Z5f_one5tupleIiE" } } +// { dg-final { scan-assembler "_Z5f_two5tupleIifE" } } +// { dg-final { scan-assembler "_Z8f_nested5tupleIiS_IdcEfE" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic40.C b/gcc/testsuite/g++.dg/cpp0x/variadic40.C new file mode 100644 index 00000000000..6cc9273a897 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic40.C @@ -0,0 +1,3 @@ +// { dg-options "-std=gnu++0x" } +template +struct backward_tuple {}; // { dg-error "end" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic41.C b/gcc/testsuite/g++.dg/cpp0x/variadic41.C new file mode 100644 index 00000000000..d209766d132 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic41.C @@ -0,0 +1,3 @@ +// { dg-options "-std=gnu++0x" } +template +void f(const Args&... args, int oops); // { dg-error "end" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic42.C b/gcc/testsuite/g++.dg/cpp0x/variadic42.C new file mode 100644 index 00000000000..4c6c7673d80 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic42.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template +void f(Args...) { } + +void g() +{ + f(0, 0, 0); + f(0,0,0); +} +// { dg-final { scan-assembler "_Z1fIPiPfPdEvU10__variadicT_" } } +// { dg-final { scan-assembler "_Z1fIPiiiEvU10__variadicT_" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic43.C b/gcc/testsuite/g++.dg/cpp0x/variadic43.C new file mode 100644 index 00000000000..fce81ae0dd1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic43.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template +int f(const Args&...); + +void g() +{ + int (*fp)(const int&, const float&) = &f; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic44.C b/gcc/testsuite/g++.dg/cpp0x/variadic44.C new file mode 100644 index 00000000000..8452a96cc21 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic44.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template +int f(const Args&...); + +template void g(T) { } + +void h() +{ + g(&f); +} + +// { dg-final { scan-assembler "_Z1gIPFiRKiRKfEEvT_"} } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic45.C b/gcc/testsuite/g++.dg/cpp0x/variadic45.C new file mode 100644 index 00000000000..c5a66ab2062 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic45.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +int& f(Args...); + +template +float& f(T1, T2); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic46.C b/gcc/testsuite/g++.dg/cpp0x/variadic46.C new file mode 100644 index 00000000000..8b81a363bf1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic46.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template +int& f(Args&...); + +template +float& f(const Args&...); + +int& g(int x, float y) +{ + return f(x, y); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic47.C b/gcc/testsuite/g++.dg/cpp0x/variadic47.C new file mode 100644 index 00000000000..d80371c0eee --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic47.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template struct wrap { }; + +template +int& f(const Args&...); + +template +float& f(const wrap&...); + +int& g(int x, float y, double z) +{ + return f(x, y, z); +} + +float& h(wrap x, wrap y, wrap z) +{ + return f(x, y, z); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic48.C b/gcc/testsuite/g++.dg/cpp0x/variadic48.C new file mode 100644 index 00000000000..ab3f777f795 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic48.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +int& f(const T&, Args...); + +template +float& f(const T&); + +float& g() { + return f(17); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic49.C b/gcc/testsuite/g++.dg/cpp0x/variadic49.C new file mode 100644 index 00000000000..7e2215f2c23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic49.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +int& f(...); + +template +float& f(Args...); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic5.C b/gcc/testsuite/g++.dg/cpp0x/variadic5.C new file mode 100644 index 00000000000..d1f333566d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic5.C @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple<> { + static const int value = 1; +}; + +template<> +struct tuple { + static const int value = 2; +}; + + +template<> +struct tuple { + static const int value = 3; +}; + +template +struct tuple { + static const int value = 4; +}; + +template<> +struct tuple { + static const int value = 5; +}; + +int a0[tuple::value == 0? 1 : -1]; +int a1[tuple<>::value == 1? 1 : -1]; +int a2[tuple::value == 2? 1 : -1]; +int a3[tuple::value == 3? 1 : -1]; +int a4[tuple::value == 4? 1 : -1]; +int a5[tuple::value == 5? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic50.C b/gcc/testsuite/g++.dg/cpp0x/variadic50.C new file mode 100644 index 00000000000..a2c3b7c908f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic50.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +int& f(int, double, ...); + +template +float& f(Args...); + +float& g() { + return f(17, 3.14159, 3); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic51.C b/gcc/testsuite/g++.dg/cpp0x/variadic51.C new file mode 100644 index 00000000000..e2e2d630a7b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic51.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template +float& f(T1, T2); + +template +int& f(Args...); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic52.C b/gcc/testsuite/g++.dg/cpp0x/variadic52.C new file mode 100644 index 00000000000..12b121fe4ec --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic52.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template +struct vector_c { }; + +vector_c v1; +vector_c v2; +vector_c v3; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic53.C b/gcc/testsuite/g++.dg/cpp0x/variadic53.C new file mode 100644 index 00000000000..09a3879b420 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic53.C @@ -0,0 +1,17 @@ +// { dg-options "-std=gnu++0x" } +template +class bound_functor +{ + public: + typedef typename F::result_type result_type; + + template + typename F::result_type operator()(Args&... args); +}; + +template +template +typename F::result_type +bound_functor::operator()(Args&... args) +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic54.C b/gcc/testsuite/g++.dg/cpp0x/variadic54.C new file mode 100644 index 00000000000..db750d76511 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic54.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template +class bound_functor +{ + public: + bound_functor(); +}; + +template +bound_functor::bound_functor() +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic55.C b/gcc/testsuite/g++.dg/cpp0x/variadic55.C new file mode 100644 index 00000000000..b9c8cffb027 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic55.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template +class bound_functor +{ + public: + bound_functor(const BoundArgs&... bound_args); +}; + +template +bound_functor::bound_functor(const BoundArgs&...) +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic56.C b/gcc/testsuite/g++.dg/cpp0x/variadic56.C new file mode 100644 index 00000000000..77846e51321 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic56.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple { }; + +template +struct tuple { + int foo(); +}; + +template +struct tuple { + int bar(); +}; + +template +int tuple::foo() { return 0; } + +template +int tuple::bar() { return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic57.C b/gcc/testsuite/g++.dg/cpp0x/variadic57.C new file mode 100644 index 00000000000..9833b1bb359 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic57.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +template +struct array { + int foo(); +}; + +template +struct array { + int bar(); +}; + +template +int array::foo() { } + +template +int array::bar() { } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic58.C b/gcc/testsuite/g++.dg/cpp0x/variadic58.C new file mode 100644 index 00000000000..5da0730b5aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic58.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +#include + +template +void foo(Args...) { } + +template +void bar(Args... args) { + foo(Args()...); + foo(args = args...); + foo(reinterpret_cast(&args)...); + foo(const_cast(args)...); + foo(static_cast(&args)...); + foo(dynamic_cast(&args)...); + foo(typeid(Args)...); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic59.C b/gcc/testsuite/g++.dg/cpp0x/variadic59.C new file mode 100644 index 00000000000..f0730d33baf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic59.C @@ -0,0 +1,4 @@ +// { dg-options "-std=gnu++0x" } +template +void print(T t, VarArgs args); // { dg-error "packs not expanded" } +// { dg-error "VarArgs" "" { target *-*-* } 3 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic6.C b/gcc/testsuite/g++.dg/cpp0x/variadic6.C new file mode 100644 index 00000000000..105550bb903 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic6.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple_base {}; + +template +struct tuple : public tuple_base +{ +}; + +tuple<> zero; +tuple one; +tuple two; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic60.C b/gcc/testsuite/g++.dg/cpp0x/variadic60.C new file mode 100644 index 00000000000..29c4e29b872 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic60.C @@ -0,0 +1 @@ +template class tuple; // { dg-warning "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic61.C b/gcc/testsuite/g++.dg/cpp0x/variadic61.C new file mode 100644 index 00000000000..487f78bc07a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic61.C @@ -0,0 +1,2 @@ +// { dg-options "-pedantic" } +template class tuple; // { dg-warning "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic62.C b/gcc/testsuite/g++.dg/cpp0x/variadic62.C new file mode 100644 index 00000000000..dfa41f73915 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic62.C @@ -0,0 +1,2 @@ +// { dg-options "-pedantic-errors" } +template class tuple; // { dg-error "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic63.C b/gcc/testsuite/g++.dg/cpp0x/variadic63.C new file mode 100644 index 00000000000..359def1cd10 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic63.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++0x -pedantic" } +template class tuple; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic64.C b/gcc/testsuite/g++.dg/cpp0x/variadic64.C new file mode 100644 index 00000000000..c9212e2e959 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic64.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template + struct _Index_tuple { }; + +template > +struct _Build_index_tuple; + +template +struct _Build_index_tuple<_Num, _Index_tuple<_Indexes...> > + : _Build_index_tuple<_Num - 1, + _Index_tuple<_Indexes..., sizeof...(_Indexes)> > +{ +}; + +template +struct _Build_index_tuple<0, _Index_tuple<_Indexes...> > +{ + typedef _Index_tuple<_Indexes...> __type; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic65.C b/gcc/testsuite/g++.dg/cpp0x/variadic65.C new file mode 100644 index 00000000000..6379da83f11 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic65.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +struct unused; +template +struct tuple {}; + +template +void foo(tuple) { } // { dg-error "cannot expand" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic66.C b/gcc/testsuite/g++.dg/cpp0x/variadic66.C new file mode 100644 index 00000000000..5c31ae06fd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic66.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } + +template +Result bind(Functor, ArgTypes...) { } + +void f() +{ + bind(17, 20, 22); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic67.C b/gcc/testsuite/g++.dg/cpp0x/variadic67.C new file mode 100644 index 00000000000..e496bfc176c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic67.C @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +template struct tuple {}; + +template +struct nested +{ + typedef tuple...> type; +}; + +template +struct is_same +{ + static const bool value = false; +}; + +template +struct is_same +{ + static const bool value = true; +}; + +int a0[is_same::type, + tuple, + tuple > >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic68.C b/gcc/testsuite/g++.dg/cpp0x/variadic68.C new file mode 100644 index 00000000000..53d8f2d6d0c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic68.C @@ -0,0 +1,23 @@ +// { dg-do "run" } +// { dg-options "-std=gnu++0x" } +extern "C" void abort(); + +template +void f(T* expected_values, int n) +{ + if (sizeof...(Values) != n) + abort (); + + T values[] = { Values... }; + for (int i = 0; i < n; ++i) + if (values[i] != expected_values[i]) + abort(); +} + +int main() +{ + int test_arr1[3] = { 1, 2, 3 }; + f(test_arr1, 3); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic69.C b/gcc/testsuite/g++.dg/cpp0x/variadic69.C new file mode 100644 index 00000000000..5fe9a1950ff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic69.C @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +template +struct stored_value +{ + explicit stored_value() : value() { } + + explicit stored_value(const T& value) : value(value) { } + + stored_value(int, const T& value) : value(value) { } + + T value; +}; + +template +struct myclass : public stored_value... +{ + myclass() { } + + explicit myclass(const Values&... values) + : stored_value(values)... { } + + explicit myclass(int x, const Values&... values) + : stored_value(x, values)... { } + +}; + +void f() +{ + int i; + float f; + myclass ifp1; + myclass ifp2(&i, &f); + myclass ifp3(1, &i, &f); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic7.C b/gcc/testsuite/g++.dg/cpp0x/variadic7.C new file mode 100644 index 00000000000..3ba37bfb66e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic7.C @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple_base { + static const int value = 0; +}; + +template<> +struct tuple_base { + static const int value = 1; +}; + +template<> +struct tuple_base { + static const int value = 2; +}; + +template<> +struct tuple_base { + static const int value = 3; +}; + +template +struct int_tuple : tuple_base { }; + +template +struct tuple_int : tuple_base { }; + +int a0a[int_tuple::value == 0? 1 : -1]; +int a0b[int_tuple::value == 0? 1 : -1]; +int a1a[int_tuple<>::value == 1? 1 : -1]; +int a1b[tuple_int<>::value == 1? 1 : -1]; +int a2[int_tuple::value == 2? 1 : -1]; +int a3[tuple_int::value == 3? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic70.C b/gcc/testsuite/g++.dg/cpp0x/variadic70.C new file mode 100644 index 00000000000..0bc8e824cd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic70.C @@ -0,0 +1,22 @@ +// { dg-do "run" } +// { dg-options "-std=gnu++0x" } +template struct bomb; + +template +struct bomb { + static const T value = 0; +}; + +template +struct bomb { + static const T value = v + bomb::value; +}; + +extern "C" void abort(); + +int main() { + bomb b; + if (b.value != 10) + abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic71.C b/gcc/testsuite/g++.dg/cpp0x/variadic71.C new file mode 100644 index 00000000000..d4219dace83 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic71.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template struct list {}; + +template +struct push_front; + +template +struct push_front, Head> { + typedef list type; // { dg-error "parameter packs not expanded" } +}; + +// { dg-error "Elements" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic72.C b/gcc/testsuite/g++.dg/cpp0x/variadic72.C new file mode 100644 index 00000000000..b1a620d5386 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic72.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +struct A {}; +struct B {}; +struct C {}; + +template +struct mixed_up : public Mixins... +{ +}; + +void fA(A); +void fB(B); +void fC(C); + +void g() +{ + mixed_up m; + fA(m); + fB(m); + fC(m); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic73.C b/gcc/testsuite/g++.dg/cpp0x/variadic73.C new file mode 100644 index 00000000000..7bff85b5037 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic73.C @@ -0,0 +1,33 @@ +// { dg-do "run" } +// { dg-options "-std=gnu++0x" } +struct A {}; +struct B {}; +struct C {}; + +template void f(int idx) throw(Exceptions...) { + if (idx == 0) throw A(); + else if (idx == 1) throw B(); + else if (idx == 2) throw C(); +} + +extern "C" void abort(); + +int main() +{ + try { + f(0); + abort(); + } catch (A) { + } + try { + f(1); + abort(); + } catch (B) { + } + try { + f(2); + abort(); + } catch (C) { + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic74.C b/gcc/testsuite/g++.dg/cpp0x/variadic74.C new file mode 100644 index 00000000000..19b6b11d8e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic74.C @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +template class A +{ +public: + template class X { /* ... */ }; // { dg-error "not a valid type for a template constant parameter" } +}; + +template class B +{ +public: + template class X { + typename A::template X foo; + }; +}; + +int i; +float f; + +A::X<&i, &f> apple1; +B::X<&i, &f> banana1; + +A::X<&i> apple2; // { dg-error "wrong number of template arguments" } +// { dg-error "invalid type" "" { target *-*-* } 22 } +A::X<&i, &f, &f> apple3; // { dg-error "wrong number of template arguments" } +// { dg-error "invalid type" "" { target *-*-* } 24 } +A apple4; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic75.C b/gcc/testsuite/g++.dg/cpp0x/variadic75.C new file mode 100644 index 00000000000..f57f8b3ef47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic75.C @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } + +template struct tuple { }; + +template class Meta, typename... Values> +struct apply_all +{ + typedef tuple::type...> type; +}; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +template +struct add_reference { + typedef T& type; +}; + +template +struct add_reference { + typedef T& type; +}; + +static_assert(is_same::type, + tuple >::value, + "check apply"); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic8.C b/gcc/testsuite/g++.dg/cpp0x/variadic8.C new file mode 100644 index 00000000000..c3a1340cf26 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic8.C @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +template +struct tuple_base { + static const int value = 0; +}; + +template<> +struct tuple_base +{ + static const int value = 1; +}; + +template +struct tuple_base +{ + static const int value = 2; +}; + +template +struct tuple_of_pointers : tuple_base { }; + +int a1[tuple_of_pointers::value == 1? 1 : -1]; +int a2[tuple_of_pointers::value == 2? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic9.C b/gcc/testsuite/g++.dg/cpp0x/variadic9.C new file mode 100644 index 00000000000..c5db6af6a89 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic9.C @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +template +struct pair {}; + +template +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple > { + static const int value = 1; +}; + +template +struct tuple > { + static const int value = 2; +}; + +template +struct tuple, pair > { + static const int value = 3; +}; + + +template +struct X { + template + struct Y + { + typedef tuple...> type; + }; +}; + +int a0[X::Y::type::value == 0? 1 : -1]; +int a1[X::Y::type::value == 1? 1 : -1]; +int a2[X::Y::type::value == 2? 1 : -1]; +int a3[X::Y::type::value == 3? 1 : -1];