This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] TC1 testsuite (part 2/N)


Hello,

this is the second batch of tests for C++03 compliance. Tested with make
check-g++ on i686-pc-linux-gnu. OK for mainline?

Giovanni Bajo


testsuite/
2004-01-31  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        * g++.dg/tc1/dr101.C, g++.dg/tc1/dr135.C, g++.dg/tc1/dr142.C,
        g++.dg/tc1/dr152.C, g++.dg/tc1/dr159.C, g++.dg/tc1/dr161.C,
        g++.dg/tc1/dr166.C, g++.dg/tc1/dr176.C, g++.dg/tc1/dr188.C,
        g++.dg/tc1/dr193.C, g++.dg/tc1/dr194.C, g++.dg/tc1/dr217.C,
        g++.dg/tc1/dr48.C, g++.dg/tc1/dr56.C, g++.dg/tc1/dr68.C,
        g++.dg/tc1/dr76.C, g++.dg/tc1/dr80.C, g++.dg/tc1/dr94.C: New tests.


Index: dr101.C
===================================================================
RCS file: dr101.C
diff -N dr101.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr101.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,31 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR101: Redeclaration of extern "C" names via using-declarations
+
+ namespace Test1 {
+
+   typedef unsigned int X;
+   extern "C" void f1();
+   namespace N {
+     typedef unsigned int X;
+     extern "C" void f1();
+   }
+   using N::f1; // { dg-bogus "" "redeclaration through 'using' should not be
ambiguous" }
+   using N::X;  // { dg-bogus "" "redeclaration through 'using' should not be
ambiguous" }
+ }
+
+
+ namespace Test2 {
+
+   typedef unsigned int X;
+   extern "C" int f2();
+   namespace N {
+     typedef unsigned int X;
+     extern "C" int f2();
+   }
+   using namespace N;
+   int i = f2(); // { dg-bogus "" "redeclaration through 'using' should not be
ambiguous" }
+   X x;          // { dg-bogus "" "redeclaration through 'using' should not be
ambiguous" { xfail *-*-* } }
+
+ }
+
Index: dr135.C
===================================================================
RCS file: dr135.C
diff -N dr135.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr135.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,8 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR135: Class type in in-class member function definitions
+
+ struct S {
+   S f() { return S(); }  // { dg-bogus "" "incomplete class type is allowed
as return type" }
+   void g(S) { }          // { dg-bogus "" "incomplete class type is allowed
as parameter type" }
+ };
Index: dr142.C
===================================================================
RCS file: dr142.C
diff -N dr142.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr142.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,32 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR142: Injection-related errors in access example
+
+ class B {                 // { dg-error "inaccessible" }
+ public:
+   int mi;                 // { dg-error "inaccessible" }
+   static int si;          // { dg-error "inaccessible" }
+ };
+
+ class D: private B {
+ };
+
+ class DD: public D {
+   void f();
+ };
+
+ void DD::f() {
+   mi = 3;          // { dg-error "within this context" "" }
+   si = 3;          // { dg-error "within this context" "" }
+   ::B b;
+   b.mi = 3;
+   b.si = 3;
+   ::B::si = 3;
+   ::B* bp1 = this;        // { dg-error "inaccessible base" "" }
+   ::B* bp2 = (::B*)this;
+   bp2->mi = 3;
+
+
+   B b2;                   // { dg-error "within this context" "" }
+   B::si = 3;              // { dg-error "within this context" "" }
+ }
Index: dr152.C
===================================================================
RCS file: dr152.C
diff -N dr152.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr152.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,36 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR152: explicit copy constructors
+
+ namespace N1 {
+   struct X {
+     X();
+     explicit X(const X&);
+   };
+   void f(X);
+   int foo()
+   {
+     X x;
+     f(x);     // { dg-error "" "" }
+   }
+ }
+
+ namespace N2 {
+   template <class T>
+   struct X {
+     X();
+     explicit X(const X&);
+   };
+
+   template <class T>
+   void f(T ) {}
+
+   template <class T>
+   int foo()
+   {
+     X<T> x;
+     N2::f(x);   // { dg-error "" "" }
+   }
+
+   template int foo<float>();  // { dg-error "instantiated from here" }
+ }
Index: dr159.C
===================================================================
RCS file: dr159.C
diff -N dr159.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr159.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,12 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR159: Namespace qualification in declarators
+
+ namespace N {
+   namespace M {
+     void f();
+     void g();
+   }
+   void M::f(){}
+   void N::M::g(){}
+ }
Index: dr161.C
===================================================================
RCS file: dr161.C
diff -N dr161.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr161.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,50 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR161: Access to protected nested type
+
+ namespace N1 {
+   struct A
+   {
+   protected:
+     typedef int type;
+   };
+
+   struct B : public A
+   {
+     void test(void)
+     {
+       A::type t;
+     }
+
+     friend void ftest(void)
+     {
+       A::type t;
+     }
+   };
+ }
+
+
+ namespace N2 {
+   template <class T>
+   struct A
+   {
+   protected:
+     typedef int type;
+   };
+
+   template <class T>
+   struct B : public A<T>
+   {
+     void test(B b)
+     {
+       typename A<T>::type t;
+     }
+
+     friend void ftest(B b)
+     {
+       typename A<T>::type t;
+     }
+   };
+
+   template struct B<void>;
+ }
Index: dr166.C
===================================================================
RCS file: dr166.C
diff -N dr166.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr166.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,60 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR166: Friend declarations of template-ids
+
+ namespace N {
+   template <class T> void f(T);
+   void g();
+
+   namespace M {
+     class A {
+       friend void f<int>(int); // N::f
+       static int x;   // { dg-error "private" }
+     };
+
+     class B {
+       template <class T> friend void f(T);  // M::f
+       static int x;   // { dg-error "private" }
+     };
+
+     class C {
+       friend void g(); // M::g
+       static int x;   // { dg-error "private" }
+     };
+
+     template <class T> void f(T)  // will be instantiated as f<long>
+     {
+       M::A::x = 0;    // { dg-error "within this context" }
+       M::B::x = 0;
+     }
+     template <> void f<int>(int)
+     { M::A::x = 0; }      // { dg-error "within this context" }
+     template <> void f<double>(double )
+     {
+       M::B::x = 0;
+       M::f<long>(0);   // { dg-error "instantiated" }
+     }
+
+     void g(void)
+     { M::C::x = 0; }
+   }
+
+   template <class T> void f(T)  // will be instantiated as f<long>
+   {
+     M::A::x = 0;       // { dg-error "within this context" }
+     M::B::x = 0;       // { dg-error "within this context" }
+   }
+
+   template <> void f<int>(int )
+   {
+     N::f<long>(0);        // { dg-error "instantiated" }
+     M::A::x = 0;
+     M::B::x = 0;       // { dg-error "within this context" }
+   }
+
+   template <> void f<char>(char )
+   { M::A::x = 0; }      // { dg-error "within this context" }
+
+   void g(void)
+   { M::C::x = 0; }      // { dg-error "within this context" }
+ }
Index: dr176.C
===================================================================
RCS file: dr176.C
diff -N dr176.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr176.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,29 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR176: Name injection and templates
+
+ namespace N1 {
+   template <class T> struct Base {
+     Base* p;
+     Base<T*>* p2;
+     ::Base* p3;    // { dg-error "" "" }
+   };
+
+   template <class T> struct Derived: public Base<T> {
+     Base* p;     // { dg-bogus "" "injected class name in derived classes"
{ xfail *-*-* } }
+     Base<T*>* p2;
+     typename Derived::Base* p3;   // { dg-bogus "" "injected class name in
derived classes" { xfail *-*-* } }
+   };
+
+   template struct Derived<void>;  // { dg-bogus "instantiated from here"
"everything should be looked up at parsing time (after DR224)" { xfail
*-*-* } }
+ }
+
+
+ namespace N2 {
+   template <class T> struct Base {};
+   template <class T> struct Derived: public Base<T> {
+     typename Derived::template Base<double>* p1;  // { dg-bogus "" "" { xfail
*-*-* } }
+   }
+
+   template struct Derived<void>;
+ }
Index: dr188.C
===================================================================
RCS file: dr188.C
diff -N dr188.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr188.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,9 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR188: Comma operator and rvalue conversion
+
+ template <bool> struct StaticAssert;
+ template <> struct StaticAssert<true> {};
+
+ char arr[100];
+ StaticAssert<(sizeof(0,arr) == 100)> check;
Index: dr193.C
===================================================================
RCS file: dr193.C
diff -N dr193.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr193.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,72 ----
+ // { dg-do run }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR193: Order of destruction of local automatics of destructor
+
+ extern "C" void abort(void);
+
+ namespace N1 {
+   bool a_done = false;
+   struct A
+   {
+     ~A()
+     {
+       a_done = true;
+     }
+   };
+
+   struct B
+   {
+     ~B()
+     {
+       if (!a_done)
+         abort();
+     }
+   };
+
+   struct C {
+     B x;
+     ~C() {
+       A y;
+     };
+   };
+ }
+
+
+ namespace N2 {
+   bool a_done = false;
+
+   template <class>
+   struct A
+   {
+     ~A()
+     {
+       a_done = true;
+     }
+   };
+
+   template <class>
+   struct B
+   {
+     ~B()
+     {
+       if (!a_done)
+         abort();
+     }
+   };
+
+   template <class T>
+   struct C {
+     B<T> x;
+     ~C() {
+       A<T> y;
+     };
+   };
+ }
+
+
+ int main(void)
+ {
+   N1::C c1;
+   N2::C<void> c2;
+   return 0;
+ }
Index: dr194.C
===================================================================
RCS file: dr194.C
diff -N dr194.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr194.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,16 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR194: Identifying constructors
+
+ struct A
+ {
+   inline explicit A();
+ };
+
+ template <class>
+ struct B
+ {
+   inline explicit B();
+ };
+
+ template struct B<void>;
Index: dr217.C
===================================================================
RCS file: dr217.C
diff -N dr217.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr217.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,14 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR217: Default arguments for non-template member functions of class
+ //  templates
+
+ template <class T>
+ struct S
+ {
+   void foo (int);
+ };
+
+ template <class T>
+ void S<T>::foo (int = 0)  // { dg-error "" "default arguments for parameters
of member functions of class templates can be specified in the initial
declaration only" { xfail *-*-* } }
+ { }
Index: dr48.C
===================================================================
RCS file: dr48.C
diff -N dr48.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr48.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,13 ----
+ // { dg-do link }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR48: Definitions of unused static members
+
+ struct A {
+   static const int size = 10;
+   int array[size];
+ };
+
+ int main() {
+   A a;
+   return 0;
+ }
Index: dr56.C
===================================================================
RCS file: dr56.C
diff -N dr56.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr56.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,12 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR56: Redeclaring typedefs within classes
+
+ class X {
+   typedef int I;
+   typedef int I;  // { dg-error "" "Cannot redeclare a typedef in a class
scope" { xfail *-*-* } }
+ };
+
+ // In non-class scope, they are allowed.
+ typedef int A;
+ typedef int A;
Index: dr68.C
===================================================================
RCS file: dr68.C
diff -N dr68.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr68.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,20 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR68: Grammar does not allow "friend class A<int>;"
+
+ namespace A{
+   class B{};
+ }
+
+ namespace B{
+   class A{};
+   class C{
+     friend class ::A::B;
+   };
+ }
+
+
+ template <typename> class K;
+ class J {
+   friend class K<int>;
+ };
Index: dr76.C
===================================================================
RCS file: dr76.C
diff -N dr76.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr76.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,8 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR76: Are const volatile variables considered "constant expressions"?
+
+ volatile const int a = 5;
+
+ template <int> struct K;
+ template struct K<a>; // { dg-error "non-constant" }
Index: dr80.C
===================================================================
RCS file: dr80.C
diff -N dr80.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr80.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,53 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR80: Class members with same name as class
+
+ struct A
+ {
+   int A;
+ };
+
+ struct A2
+ {
+   static int A2;  // { dg-error "same name as" }
+ };
+
+
+ template <class>
+ struct A3
+ {
+   int A3;
+ };
+
+ template <class>
+ struct A4
+ {
+   static int A4;  // { dg-error "same name as" }
+ };
+
+
+ struct B
+ {
+   B();
+   int B;  // { dg-error "same name as" }
+ };
+
+ struct B2
+ {
+   B2();
+   static int B2;  // { dg-error "same name as" }
+ };
+
+ template <class>
+ struct B3
+ {
+   B3();
+   int B3;  // { dg-error "same name as" "this error should appear at parsing
time" { xfail *-*-* } }
+ };
+
+ template <class>
+ struct B4
+ {
+   B4();
+   static int B4;  // { dg-error "same name as" }
+ };
Index: dr94.C
===================================================================
RCS file: dr94.C
diff -N dr94.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- dr94.C 1 Feb 2004 00:36:49 -0000
***************
*** 0 ****
--- 1,9 ----
+ // { dg-do compile }
+ // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+ // DR94: Inconsistencies in the descriptions of constant expressions
+
+ struct S {
+   static const int c = 5;
+ };
+ int a[S::c];
+



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]