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