From ef8f74d66da4c6034217dfe1147bb24e0193ef80 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Sat, 6 Sep 2003 20:43:15 -0700 Subject: [PATCH] re PR c++/11507 (parser fails to recognize namespace) 2003-09-06 Andrew Pinski PR c++/11507 * g++.dg/lookup/scoped7.C: New test. PR c++/9574 * g++.dg/other/static1.C: New test. PR c++/11490 * g++.dg/warn/template-1.C: New test. PR c++/11432 * g++.dg/template/crash10.C: New test. PR c++/2478 * g++.dg/overload/VLA.C: New test. PR c++/10804 * g++.dg/template/call1.C: New test. From-SVN: r71156 --- gcc/testsuite/g++.dg/lookup/scoped7.C | 20 ++++++++++++++++++ gcc/testsuite/g++.dg/other/static1.C | 17 ++++++++++++++++ gcc/testsuite/g++.dg/overload/VLA.C | 16 +++++++++++++++ gcc/testsuite/g++.dg/template/call1.C | 17 ++++++++++++++++ gcc/testsuite/g++.dg/template/crash10.C | 27 +++++++++++++++++++++++++ gcc/testsuite/g++.dg/warn/template-1.C | 15 ++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 gcc/testsuite/g++.dg/lookup/scoped7.C create mode 100644 gcc/testsuite/g++.dg/other/static1.C create mode 100644 gcc/testsuite/g++.dg/overload/VLA.C create mode 100644 gcc/testsuite/g++.dg/template/call1.C create mode 100644 gcc/testsuite/g++.dg/template/crash10.C create mode 100644 gcc/testsuite/g++.dg/warn/template-1.C diff --git a/gcc/testsuite/g++.dg/lookup/scoped7.C b/gcc/testsuite/g++.dg/lookup/scoped7.C new file mode 100644 index 00000000000..a9d70d06e3b --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/scoped7.C @@ -0,0 +1,20 @@ +//PR c++/11507 +// Origin: kai-gcc-bugs@khms.westfalen.de and bangerth@dealii.org +//The new parser used to fail on this. + +// { dg-do compile } + +namespace NS +{ + void foo(bool arg1); +} + +namespace M { + namespace K { + bool Bc(bool x); + } + + void bar() { + NS::foo (K::Bc(true)); // GCC could not find K or Bc. + } +} diff --git a/gcc/testsuite/g++.dg/other/static1.C b/gcc/testsuite/g++.dg/other/static1.C new file mode 100644 index 00000000000..09e17d4b5ba --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static1.C @@ -0,0 +1,17 @@ +// PR c++/9574 +// Origin: fche@redhat.com and bangerth@dealii.org +// The new parser ICE on this test and then it could +// not find z in bar::bar(). + +// { dg-do compile } + +struct X { + void operator[](const int& __k); +}; +struct foo { + static X x; +}; +struct bar { + int z; + bar () { foo::x[z]; }; +}; diff --git a/gcc/testsuite/g++.dg/overload/VLA.C b/gcc/testsuite/g++.dg/overload/VLA.C new file mode 100644 index 00000000000..850e19a0054 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/VLA.C @@ -0,0 +1,16 @@ +//Origin: kengole@us.ibm.com + +//PR c++/2478 +// G++ was rejecting this as it could not convert `int (*)[]' to `int (*)[0]'. +// Using the C99 VLA style arrays in a struct. + +// { dg-do compile } + +struct { + int (*p)[]; +} B; + +void foo() { + int (*p)[]; + B.p=p; // { dg-bogus "cannot convert" } +} diff --git a/gcc/testsuite/g++.dg/template/call1.C b/gcc/testsuite/g++.dg/template/call1.C new file mode 100644 index 00000000000..3b6e367af22 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/call1.C @@ -0,0 +1,17 @@ +//Origin: harinath@cs.umn.edu +//PR c++/10804 +// G++ was not emiting the function foo. + +// { dg-do run } + + +template +struct A +{ + A() { const void (*a)() = foo; } + static const void foo() {} +}; +int main(int argc, char *argv[]) +{ + A a; +} diff --git a/gcc/testsuite/g++.dg/template/crash10.C b/gcc/testsuite/g++.dg/template/crash10.C new file mode 100644 index 00000000000..17011f1d400 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash10.C @@ -0,0 +1,27 @@ +//Origin: benko@sztaki.hu +//PR c++/11432 +// The mainline ICE on this one between 2003-01-16 and 2003-07-29. + + // { dg-do run } + + extern "C" void abort(); + + +template +struct a +{ + static int const value = A - 1; +}; + + +template +struct b +{ + static int foo() + { + return a::value; + } + + + static int const L = a::value; +}; diff --git a/gcc/testsuite/g++.dg/warn/template-1.C b/gcc/testsuite/g++.dg/warn/template-1.C new file mode 100644 index 00000000000..04ea5ae323b --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/template-1.C @@ -0,0 +1,15 @@ +//Origin: bangerth@dealii.org +//PR c++/11490 +//Since N is know at instantiation time, there +// should be no warning about comparision between +// unsinged and signed interegers. + +// { dg-do compile } +// { dg-options "-W" } + +template bool f() { + unsigned int i=0; + return i!=N; // { dg-bogus "signed and unsigned" } +} + +template bool f<2> (); -- 2.30.2