From 45f22fa2551c0002d82ff11384921418dc67711c Mon Sep 17 00:00:00 2001 From: Brendan Kehoe Date: Mon, 6 Oct 1997 20:08:46 -0400 Subject: [PATCH] add missing tests, put in various test adjustments from devo From-SVN: r15850 --- .../g++.old-deja/g++.benjamin/p12475.C | 2 +- .../g++.old-deja/g++.law/missed-error2.C | 4 +- .../g++.old-deja/g++.law/visibility1.C | 68 +++++++++++++++++++ .../g++.old-deja/g++.law/visibility2.C | 68 +++++++++++++++++++ 4 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.law/visibility1.C create mode 100644 gcc/testsuite/g++.old-deja/g++.law/visibility2.C diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C index fecbd576b799..ee1e39f02032 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C @@ -1,5 +1,5 @@ // Build don't link: // prms-id: 12475 -enum huh { start =-2147483648, next }; +enum huh { start =-2147483648, next }; // WARNING - diff --git a/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C index c8768055d933..4589bb112354 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C +++ b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C @@ -17,7 +17,9 @@ main() { foo(4, -37, 14.39, 14.38); } -static void foo(int i, int j, double x, double y) { // ERROR - extern +// 971006 we no longer give an error for this since we emit a hard error +// about the declaration above +static void foo(int i, int j, double x, double y) { cout << "Max(int): " << max(i,j) << " Max(double): " << max(x,y) << '\n'; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility1.C b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C new file mode 100644 index 000000000000..0314c0741c26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C @@ -0,0 +1,68 @@ +// Build don't link: +// GROUPS passed visibility +#include + + + +class base { +//========== + + void base_priv(char * n) + { cout << "base_priv called from: " << n << "\n"; }; + +protected: + + void base_prot(char * n) + { cout << "base_prot called from: " << n << "\n"; }; + +public: + + void base_publ(char * n) + { cout << "base_publ called from: " << n << "\n"; }; + + void test(char * n) { base_publ(n); base_prot(n); base_priv(n); } + +}; // class base + + + +class derived : private base { // Make this public, +//============================ // and we don't get an error + +friend void derived_friend(); + +public : + + void test(char * n) { base_publ(n); base_prot(n);} + +}; // class derived + + + +void +derived_friend() +//-------------- +{ + derived pd; + + pd.base_publ("friend of derived class"); // Compiler error here + pd.base_prot("friend of derived class"); +} + + + +main(int argc, char *argv[]) +//========================== +{ + base b; + b.base_publ("base class object"); + b.test("member of base class object"); + cout << "\n"; + + derived pd; + pd.test("member of derived class object"); + derived_friend(); + cout << "\n"; + +} /* main */ + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility2.C b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C new file mode 100644 index 000000000000..8ac5cb9e71c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C @@ -0,0 +1,68 @@ +// Build don't link: +// GROUPS passed visibility +#include + + + +class base { +//========== + + void base_priv(char * n) + { cout << "base_priv called from: " << n << "\n"; }; + +protected: + + void base_prot(char * n) + { cout << "base_prot called from: " << n << "\n"; }; + +public: + + void base_publ(char * n) + { cout << "base_publ called from: " << n << "\n"; }; + + void test(char * n) { base_publ(n); base_prot(n); base_priv(n); } + +}; // class base + + + +class derived : public base { // Make this public, +//============================ // and we don't get an error + +friend void derived_friend(); + +public : + + void test(char * n) { base_publ(n); base_prot(n);} + +}; // class derived + + + +void +derived_friend() +//-------------- +{ + derived pd; + + pd.base_publ("friend of derived class"); // Compiler error here + pd.base_prot("friend of derived class"); +} + + + +main(int argc, char *argv[]) +//========================== +{ + base b; + b.base_publ("base class object"); + b.test("member of base class object"); + cout << "\n"; + + derived pd; + pd.test("member of derived class object"); + derived_friend(); + cout << "\n"; + +} /* main */ +