OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-src/gcc-4.2.2/gcc/testsuite/g++.old-deja/g++.benjamin
    from Rev 149 to Rev 154
    Reverse comparison

Rev 149 → Rev 154

/15799.C
0,0 → 1,29
// { dg-do assemble }
// 981203 bkoz
// g++/15799 test1
 
/*
15799.cpp: In function `void foo()':
15799.cpp:21: call of overloaded `sanjose({anonymous enum})' is ambiguous
15799.cpp:13: candidates are: sanjose::sanjose(const sanjose &) <near match>
15799.cpp:14: sanjose::sanjose(unsigned int)
*/
 
typedef char int_8;
typedef unsigned long uint_32;
 
class sanjose {
public:
sanjose();
sanjose(const sanjose&); // { dg-error "" } candidate
sanjose(int_8 value); // { dg-error "" } // ERROR -
sanjose(uint_32 value); // { dg-error "" } // ERROR -
};
 
enum { first, last};
 
void foo(void) {
sanjose obj(first); // { dg-error "" } // ERROR -
}
 
 
15799.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: typeid01.C =================================================================== --- typeid01.C (nonexistent) +++ typeid01.C (revision 154) @@ -0,0 +1,72 @@ +// { dg-do run } +// 980617 bkoz +// typeid for local types +// typeid bool vs int and enum vs int + +#include +#ifdef DEBUG_ASSERT +#include +#endif + +// 4: local class in non-main function + +void test1 (void) { + bool class_p = false; + class X2 { + private: + unsigned int counter; + public: + X2 (unsigned int i = 35): counter(i) {} + ~X2(){} + unsigned int ret_counter() {return counter;} + }; + X2 obj_1; + class_p = typeid(X2) == typeid(obj_1); +} + +int main () +{ + // 1: simple +#if 1 + bool enum_p = false; + enum E { A, B, C }; + enum_p = typeid(A) == typeid(E); +#ifdef DEBUG_ASSERT + assert (enum_p); +#endif +#endif + + // 2: complex +#if 0 + bool enum2_p = false; + bool int_p = false; + bool bool_p = false; + enum E2 { A2, B2}; + enum2_p = typeid(A2) == typeid(E2); + int_p = typeid(int) == typeid(E2); + bool_p = typeid(bool) == typeid(E2); +#ifdef DEBUG_ASSERT + assert (enum2_p); + assert (!int_p); + assert (!bool_p); +#endif +#endif + + // 3: local class + bool class_p = false; + class X { + private: + unsigned int counter; + public: + X (unsigned int i = 35): counter(i) {} + ~X(){} + unsigned int ret_counter() {return counter;} + }; + X obj_1; + class_p = typeid(X) == typeid(obj_1); + + // 4: local class in function + test1(); + + return 0; +}
typeid01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: p12475.C =================================================================== --- p12475.C (nonexistent) +++ p12475.C (revision 154) @@ -0,0 +1,14 @@ +// { dg-do assemble } +// prms-id: 12475 + +#include + +#if LONG_MAX == 2147483647 +#define TEST 2147483648 +#elif LONG_MAX == 9223372036854775807 +#define TEST 9223372036854775808 +#else +#error "Unsupported test -- add new constants." +#endif + +enum huh { start =-TEST, next }; // { dg-warning "" }
p12475.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: scope01.C =================================================================== --- scope01.C (nonexistent) +++ scope01.C (revision 154) @@ -0,0 +1,71 @@ +// { dg-do assemble } +// 980604 bkoz +// 3.4.5 Class member access p 4 +// nested and non-nested calls, no dtors + +struct L { + int ii; + void foo(int a) {++a;} + struct Linner { + int ii_inner; + void foo_inner(int b) {++b;} + }; +}; +class A : public L {}; +class B : public L {}; +class C : public A, public B {}; + + +void foo() { + // straight call + C x; + x.A::ii = 5; + x.A::foo(x.A::ii); + + // 5.1 Primary expressions + // p 8 + // a nested name specifier that names a class, + // optionally followed by the keyword template and then followd by + // the name of a member of either that class or one of its base + // classes is a qualified-id. (3.4.3.1 describes their lookup.) + + // 5.2.5 Class memember access + + // p 3 if E1 has the type 'pointer to class X' then + // E1->E2 == (*(E1)).E32 + // E1 == object-expression + // E2 == id-expression + // thus everything gets converted to the "." notation + + // p 2 + // the id-expression shall name a member of the class + // (object-expression) or of one of its base classes. + + // p4 if E2 is a nested type (of the object-expression), tye + // expression E1.E2 is ill formed. + + // try 1 nested call - ERROR +#if 0 + C x2; + x2.A::L::Linner::ii_inner = 6; //ERROR violates p2, does not name member of C + x2.A::L::Linner::foo_inner(x2.A::L::Linner::ii_inner); +#endif + + //try2: scoped method call -edg +acc +g++ +#if 1 + C::A::Linner x2; + x2.A::Linner::ii_inner = 6; + x2.A::Linner::foo_inner(x2.A::Linner::ii_inner); +#endif + + //try 3: non-scoped method call -edg +acc +g++ +#if 0 + C::A::L::Linner x3; + x3.ii_inner = 6; + x3.foo_inner(x3.ii_inner); +#endif +} + + + +
scope01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15800-1.C =================================================================== --- 15800-1.C (nonexistent) +++ 15800-1.C (revision 154) @@ -0,0 +1,17 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/15800 - test + +struct panama { + panama(); + panama(panama &); + panama& operator=(panama&); // { dg-error "" } // ERROR - +}; + +extern panama dig(); + +void foo() { + panama obj; + obj = dig(); // { dg-error "" } // ERROR - +} +
15800-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: scope02.C =================================================================== --- scope02.C (nonexistent) +++ scope02.C (revision 154) @@ -0,0 +1,208 @@ +// { dg-do assemble } +//980529 bkoz +//3.4.5 Class member access via pointer and non-pointer +// non-nested dtor calls + +int counter = 0; + +struct X { + int rank; + X(int init = 64) : rank(init) { } + ~X() { ++counter; } + typedef X classtype; +}; +typedef X globaltype; + +#if 0 +template +struct X_tem { + T rank; + X_tem(T init = T(64) ) : rank(init) { } + ~X_tem() { ++counter; } + typedef X_tem classtype_tem; +}; +typedef X_tem globaltype_tem; +#endif + + + + +int main(void) +{ + // 3.4.5 Class member access + // p 2 + // if the id-expression in a class member access is an + // unqualified-id, and the type of the object expression is of class + // type C (or pointer to class type C), the unqualified-id is looked + // up in the scope of class C. If the type of the object-expression + // is of pointer to scalar type, the unqualified-id is looked up in + // the context of the complete postfix-expression. + + // p 3 + // if the unqualitified id is ~type-name, and the type of the object + // expression is of a class type C (or pointer to class type C), the + // type-name is looked up in the context of the entire + // postfix-expression and in the scope of class C. The type-name + // shall refer to a class-name. If type-name is found in both + // contexts, the name shall refer to the same class type. If the + // type of the object expression is of scalar type, the type-name is + // looked up in the complete postfix-expression. + + typedef X localtype; + + // + // 1 non-templatized, pointer, unqualified + // + X x01 ; + X *px = &x01; + px->~X(); + + X x02 (66); + px = &x02; + px->~localtype(); + + X x03 (68); + px = &x03; + px->~classtype(); //-g++ //p3: unqual-id lookup in object and postfix-expr + + X x04 (70); + px = &x04; + px->~globaltype(); + + + // p 1 + // . . . the id-expression is first looked up in the class of the + // object-expression. If the identifier is not found, itis then + // looked up in the context of the entier postfix-expression and + // shall name a class or function template. If the lookup in the + // class of the object-expression finds a template, the name is also + // looked up in teh context of the entier postfix-expression and + // 1 if the name is not found, use the name from the object-expr + // 2 if the name found in postfix-expr != class template, use object-expr + // 3 if name found is class template, name must match object-expr or error + + // p 4 + + // if the id-expr in a class member acess is a qualified-id, the + // id-expression is looked up in both the context of the entire + // postfix-expr and in the scope of the class of the object-expr. If + // the name is found in both contexts, the id-expr shall refer to + // the same entity. + + + // + // 2 non-templatized, pointer, qualified + // + X x05 ; + px = &x05; + px->X::~X(); + + X x06 (66); + px = &x06; + px->X::~localtype(); + + X x07 (68); + px = &x07; + px->X::~classtype(); // -edg + + X x08 (70); + px = &x08; + px->X::~globaltype(); + + X x09 (66); + px = &x09; + px->localtype::~localtype(); + + X x10 (68); + px = &x10; + px->classtype::~classtype(); + + X x11 (70); + px = &x11; + px->globaltype::~globaltype(); + + X x12 (66); + px = &x12; + px->classtype::~localtype(); + + X x13 (68); + px = &x13; + px->globaltype::~localtype(); + + X x14 (70); + px = &x14; + px->localtype::~globaltype(); + + X x15 (70); + px = &x15; + px->classtype::~globaltype(); + + X x16 (70); + px = &x16; + px->localtype::~classtype(); //-edg + + X x17 (70); + px = &x17; + px->globaltype::~classtype(); //-edg + +#if 0 + // + // non-templatized, non-pointer + // + X xo5 ; + xo5.~X(); //unqualified + + localtype xo6 (66); + xo6.~localtype(); + + X xo7 (68); + xo7.~classtype(); + + X xo8 (70); + xo8.~globaltype(); + + + // + // templatized, pointer + // + X_tem xto1 ; + X_tem *pxt = &xto1; + pxt->~X_tem(); //unqualified + + typedef X_tem localtype_tem; + localtype_tem xto2 (66); + pxt = &xto2; + pxt->~localtype_tem(); + + //paragraph 2: unqualitifed id looked up in scope of post-fix expr if object + X_tem xto3 (68); + pxt = &xto3; + pxt->~classtype_tem(); + + X_tem xto4 (70); + pxt = &xto4; + pxt->~globaltype_tem(); + + // + // templatized, non-pointer + // + X_tem xto5 ; + xto5.~X_tem(); //unqualified + + localtype_tem xto6 (66); + xto6.~localtype_tem(); + + X_tem xto7 (68); + xto7.~classtype_tem(); + + X_tem xto8 (70); + xto8.~globaltype_tem(); +#endif + return 0; +} + + + + + +
scope02.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15800-2.C =================================================================== --- 15800-2.C (nonexistent) +++ 15800-2.C (revision 154) @@ -0,0 +1,18 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/15800 + test + +struct panama { + panama(); + panama(panama &); + panama& operator=(panama&); + panama& getref() { return *this; } +}; + +extern panama dig(); + +void foo() { + panama obj; + obj = dig().getref(); +} +
15800-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 13523.C =================================================================== --- 13523.C (nonexistent) +++ 13523.C (revision 154) @@ -0,0 +1,12 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13523 + +template class latin_america; + +class peru +{ + friend class latin_america; // Particular template class friend works + template friend class latin_america; // This does not work. +}; +
13523.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15309-1.C =================================================================== --- 15309-1.C (nonexistent) +++ 15309-1.C (revision 154) @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Wnon-virtual-dtor -Weffc++" } +// 981203 bkoz +// g++/15309 + +class bahamian { +public: + bahamian (); + ~bahamian (); +}; + +class miami : public bahamian +{ // { dg-warning "" } // WARNING - +public: + miami (); + ~miami (); +}; + + + +
15309-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15309-2.C =================================================================== --- 15309-2.C (nonexistent) +++ 15309-2.C (revision 154) @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wnon-virtual-dtor -Weffc++" } +// 981203 bkoz +// g++/15309 + +class bermuda { // { dg-warning "" } // WARNING - +public: + virtual int func1(int); + ~bermuda(); +};
15309-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15822.C =================================================================== --- 15822.C (nonexistent) +++ 15822.C (revision 154) @@ -0,0 +1,28 @@ +// { dg-do run } +// 981203 bkoz +// g++/15822 + +#include + +static unsigned int gcount; + +struct playahermosa { + playahermosa() { ++gcount; } + playahermosa(const playahermosa &) { ++gcount; } + ~playahermosa() { --gcount; } +}; + +struct playacoco { + playacoco(const playahermosa& = playahermosa()) { } //create a temporary +}; + +void foo(playacoco *) { } + +int main() +{ + playacoco bar[2]; + foo(bar); + assert (gcount == 0); + + return 0; +}
15822.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 14139.C =================================================================== --- 14139.C (nonexistent) +++ 14139.C (revision 154) @@ -0,0 +1,22 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/14309 +// test for global functions, mf's, and templatized mf's. + +static int fooe_1(void) { return 5; } +static int fooe_2(int x = fooe_1()) { return x; } + +struct antigua { + static int& foo_1(); + static int foo_2(int& x = antigua::foo_1()); + static int foo_3(int x = fooe_2()); +}; + +template + struct jamacia { + static int& foo_1(); + static int foo_2(int& x = antigua::foo_1()); + static int foo_3(int x = fooe_2()); + }; + +template class jamacia;
14139.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 17922.C =================================================================== --- 17922.C (nonexistent) +++ 17922.C (revision 154) @@ -0,0 +1,19 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/17922 + +class base { }; + +struct derived : public base { + derived (const derived&); + derived (const base&); +}; + +class tahiti { +public: + static void mf (derived); +}; + +void foo (const derived aaa) { + tahiti::mf(aaa); +}
17922.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 16077.C =================================================================== --- 16077.C (nonexistent) +++ 16077.C (revision 154) @@ -0,0 +1,29 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/16077 +// { dg-options "-Wconversion" } + +class nicaragua; +struct colombia { + colombia(); + colombia(const colombia &); + colombia(const nicaragua &); + colombia &operator= (const colombia&); +}; + +struct nicaragua { +public: + nicaragua(); + nicaragua(const nicaragua&); + operator colombia(); +}; + +void peace(const colombia&); + +void foo(nicaragua& b) { + peace(b); // { dg-warning "" } // WARNING - +} + + + +
16077.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 13908.C =================================================================== --- 13908.C (nonexistent) +++ 13908.C (revision 154) @@ -0,0 +1,21 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13908 + +class chile +{ +public: +protected: +private: +}; + +typedef void (chile::* pmf) (); + +void* foo; + +void bar (chile* pobj, pmf pmethod) +{ + //-edg: expected member name + //-g++: taking address of bound pointer-to-member expression + foo = (void*) &(pobj->*pmethod); // { dg-error "invalid use" } +}
13908.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: bool01.C =================================================================== --- bool01.C (nonexistent) +++ bool01.C (revision 154) @@ -0,0 +1,80 @@ +// { dg-do run } +//980323 bkoz +//test for bools with inclusive ors + +#include +#include + +void bar ( bool x ) {} +void bars ( short x ) {} + +/* 980326 bkoz this is not initialized and so can have indeterminate value. */ +#if 0 +int orb(){ + bool y; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 or 0 +} +#endif + +int orbtrue(){ + bool y = true; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int orbfalse(){ + bool y = false; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int orbfalse2(){ + bool y = 0; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int ors(){ + short y = 1; + bars ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + + +#if INT_MAX > 32767 +int orus(){ + unsigned short y = 1; + bars ( y ); + int blob = ( 65539 | int (y) ); + return blob; //expect 65539, will be 3 if done in us type +} +#endif + +int main() { + int tmp; +#if 0 + tmp = orb(); + assert (tmp == 27 || tmp == 0); +#endif + tmp = orbtrue(); + assert (tmp ==27); + tmp = orbfalse(); + assert (tmp ==27); + tmp = orbfalse2(); + assert (tmp ==27); + tmp = ors(); + assert (tmp ==27); +#if INT_MAX > 32767 + tmp = orus(); + assert (tmp == 65539); +#endif + + return 0; +} +
bool01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: bool02.C =================================================================== --- bool02.C (nonexistent) +++ bool02.C (revision 154) @@ -0,0 +1,64 @@ +// { dg-do run } +//980324 bkoz +//test for bool and bitwise ands + +#include + + +void bar ( bool x ) {} +void bars ( short x ) {} + +#if 0 +int andb(){ + bool y; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 or 0 +} +#endif + +int andbtrue(){ + bool y = true; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 +} + +int andbfalse(){ + bool y = false; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 0 +} + +int andbfalse2(){ + bool y = 0; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 0 +} + +int ands(){ + short y = 1; + bars ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 +} + + +int main() { + int tmp; +#if 0 + tmp = andb(); + assert (tmp == 1 || tmp == 0); +#endif + tmp = andbtrue(); + assert (tmp == 1); + tmp = andbfalse(); + assert (tmp == 0); + tmp = andbfalse2(); + assert (tmp == 0); + tmp = ands(); + assert (tmp == 1); + return 0; +}
bool02.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: p13417.C =================================================================== --- p13417.C (nonexistent) +++ p13417.C (revision 154) @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +// prms-id: 13417 + +class Foo { +public: + explicit Foo (int){} +}; +Foo f(10); +Foo blat() return f(4){} // { dg-error "" } named return value +
p13417.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: typedef01.C =================================================================== --- typedef01.C (nonexistent) +++ typedef01.C (revision 154) @@ -0,0 +1,46 @@ +// { dg-do assemble } +//980205 bkoz + +//7.1.3 the typedef specifier + + +//p1 +typedef int MILES, *KLICKSP; +MILES distance; +extern KLICKSP metricp; + +//p2--can redefine to same type +typedef struct s { /* ... */ } s; +typedef int I; +typedef int I; +typedef I I; + +//p3--cannot redefine to a different type in a given scope +class complex2 { /* ... */ };// { dg-error "" } .* +typedef int complex2;// { dg-error "" } .* +typedef int complex3;// { dg-error "" } .* +class complex3 { /* ... */ };// { dg-error "" } .* + + +//p4 +/* +4 A typedef-name that names a class is a class-name (_class.name_). If + a typedef-name is used + 1) following the class-key in an elaborated-type-specifier + 2) or in the class-head of a class declaration + 3) or is used as the identifier in the declarator for a + constructor or destructor declaration + the program is ill-formed. [Example: +*/ +struct S { + S(); + ~S(); +}; + +typedef struct S T; // { dg-error "previous declaration" } + +S a = T(); // OK +struct T * p; // { dg-error "" } using typedef after struct + +//case01 +typedef bool short;// { dg-error "" } .*
typedef01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: typedef03.C =================================================================== --- typedef03.C (nonexistent) +++ typedef03.C (revision 154) @@ -0,0 +1,44 @@ +// { dg-do assemble } +//980526 bkoz +// reduced testcase for 980511 brendan qt bug + + +class QTextStream +{ +public: + QTextStream(); + virtual ~QTextStream(); + + enum { + skipws = 0x0001, + left = 0x0002, + right = 0x0004, + internal = 0x0008, + bin = 0x0010, + oct = 0x0020, + dec = 0x0040, + hex = 0x0080, + showbase = 0x0100, + showpoint = 0x0200, + uppercase = 0x0400, + showpos = 0x0800, + scientific= 0x1000, + fixed = 0x2000 + }; + + static const int basefield; + static const int adjustfield; +}; + +typedef QTextStream QTS; +const int QTS::basefield = (QTS::bin | QTS::dec | QTS::hex) ; +const int QTS::adjustfield = QTS::left | QTS::right | QTS::internal; +#if 0 +#define QTS QTextStream +const int QTS::basefield = (QTS::bin | QTS::dec | QTS::hex) ; +const int QTS::adjustfield = QTS::left | QTS::right | QTS::internal; +#endif + + + +
typedef03.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: warn01.C =================================================================== --- warn01.C (nonexistent) +++ warn01.C (revision 154) @@ -0,0 +1,98 @@ +// { dg-do assemble } +// { dg-options "-Wall -Weffc++" } + +//1 g++/12952 un-named variables in a catch block +//Wall or Wunused should not give warnings here +template +void f (void) { + try + { + } + + catch( int) + { + } +} + +// +//2 g++/12923 __attribute__((__unused__)) not working for objects +//Weffc++ or Wunused should not report the object as an error +class C { + public: + C(); +}; + +void f (void){ + C x __attribute__ ((__unused__)); + int y __attribute__ ((__unused__)); +} + +// +//3 g++/12982 lock should not give error here, as above +void setLock (); +void clearLock (); + +template +class test { +public: + class lock + { + public: + lock () { setLock(); } + ~lock () { clearLock(); } + }; + + static void f (void) + { + lock local __attribute__ ((__unused__)); + } + +}; + + +// +//4 g++/12988 neither Mutex nor AutoMutex varibles should give warnings here +//compile with -Weffc++ or -Wunused depending on post or pre 97r1 +class Mutex { +private: + long counter; +public: + virtual long retcntr() {return counter;}; + Mutex(int i = 0): counter(i) {}; + virtual ~Mutex() {}; +} __attribute__ ((__unused__)); + +class AutoMutex: public Mutex{ +private: + long counter2; +public: + long retcntr() {return counter2;}; + AutoMutex(int i = 0): counter2(i) {}; + virtual ~AutoMutex() {}; +} __attribute__ ((__unused__)); + + +template +int foofunc(T x){ + Mutex sm(2); + AutoMutex m(&sm); + return 0; +} + + +//5 sanity check to make sure other attributes cannot be used +class Mutex2 { +private: + long counter; +public: + virtual long retcntr() {return counter;}; + Mutex2(int i = 0): counter(i) {}; + virtual ~Mutex2() {}; +} __attribute__ ((warn)); // { dg-warning "" } + + + + + + +
warn01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: friend01.C =================================================================== --- friend01.C (nonexistent) +++ friend01.C (revision 154) @@ -0,0 +1,31 @@ +// { dg-do assemble } +//980610 bkoz +// example 1: buggy + +class foo { +public: + class bar; + int func(bar *); + class bar { + int st; + public: + bar(){st=12;} + ~bar(){} + friend int foo::func(bar *); + }; + foo(){} + ~foo(){} +}; + + +int foo::func(bar *obj) { + obj->st++; + return (obj->st); +} + +void test02() { + foo obj_f; + foo::bar obj_b; + + obj_f.func( &obj_b); +}
friend01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: friend02.C =================================================================== --- friend02.C (nonexistent) +++ friend02.C (revision 154) @@ -0,0 +1,31 @@ +// { dg-do assemble } +//980610 bkoz +// example 2: ok + +class bar; +class foo { +public: + int func(bar *); + foo(){} + ~foo(){} +}; + +class bar { + int st; +public: + bar(){st=12;} + ~bar(){} + friend int foo::func(bar *); +}; + +int foo::func(bar *obj) { + obj->st++; + return (obj->st); +} + +void test02() { + foo obj_f; + bar obj_b; + + obj_f.func( &obj_b); +}
friend02.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: warn02.C =================================================================== --- warn02.C (nonexistent) +++ warn02.C (revision 154) @@ -0,0 +1,54 @@ +// { dg-do assemble } +// { dg-options "-Wredundant-decls" } +// 980413 bkoz +// from g++/15307, tests for -Wredundant-decls +// for friend functions and functions + + +extern int foo(const char *); + +class A +{ + friend int foo(const char *); + int a; +}; + +class B +{ + friend int foo(const char *); + int foo2() {return b;} + int b; +}; + +class C +{ + friend int foo(const char *); + friend int foo(const char *); // { dg-warning "" } + int foo2() {return b;} + int b; +}; + +class D +{ +public: + int foo2() {return b;} // { dg-error "with" } + int foo2() {return b;} // { dg-error "overloaded" } + int b; +}; + +class E +{ +public: + int foo2(); // { dg-error "with" } + int foo2(); // { dg-error "overloaded" } + int b; +}; + +extern int foo3(const char *); // { dg-warning "" } +extern int foo3(const char *); // { dg-warning "" } + + + + + +
warn02.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: warn03.C =================================================================== --- warn03.C (nonexistent) +++ warn03.C (revision 154) @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wredundant-decls" } +// 980420 bkoz +// from g++/15307, tests for -Wredundant-decls for decls + +//shouldn't crash +extern unsigned char *foo5[]; +extern unsigned char *foo5[]; + +
warn03.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: warn04.C =================================================================== --- warn04.C (nonexistent) +++ warn04.C (revision 154) @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-Wno-non-template-friend" } +// 980903 bkoz +// make sure this option works + + +template class task { + friend void next_time(); //shouldn't give a warning +};
warn04.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15071.C =================================================================== --- 15071.C (nonexistent) +++ 15071.C (revision 154) @@ -0,0 +1,12 @@ +// { dg-do run } +// 981203 bkoz +// g++/15071 +// gcc invocation fails to link in libstdc++ + +#include + +int main() { + std::cout << "hi" << std::endl; + + return 0; +}
15071.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15054.C =================================================================== --- 15054.C (nonexistent) +++ 15054.C (revision 154) @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wno-pointer-arith" } +// 981203 bkoz +// g++/15054 +// note that -pedantic also turns on this warning + +void cuba(void) { + void* p; + p++; +}
15054.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 18208.C =================================================================== --- 18208.C (nonexistent) +++ 18208.C (revision 154) @@ -0,0 +1,25 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/18208 + +typedef unsigned int uint_32; + +class puertorico { +public: + void *f (); +private: + uint_32 member; +}; + +void foo( ) +{ + uint_32 ui; + puertorico obj; + + // Bug using static_cast<> + ui = static_cast(obj); // { dg-error "" } // ERROR - + + // Bug when missing the pair of braces + ui = (uint_32) obj.f; // { dg-error "" } // ERROR - +} +
18208.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 14664-1.C =================================================================== --- 14664-1.C (nonexistent) +++ 14664-1.C (revision 154) @@ -0,0 +1,15 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/14664 - test + +char foo[26]; + +void bar() +{ + //-g++: incompatible types in assignment of 'const char[]' to 'char[]' + //-edg: expression must be a modifiable lvalue + foo = "0123456789012345678901234"; // { dg-error "" } // ERROR - +} + + +
14664-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 14664-2.C =================================================================== --- 14664-2.C (nonexistent) +++ 14664-2.C (revision 154) @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-fpermissive -w" } +// 981203 bkoz +// g++/14664 + test + +char foo[26]; + +void bar() +{ + foo = "0123456789012345678901234"; // { dg-error "array" } +} + + +
14664-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 17930.C =================================================================== --- 17930.C (nonexistent) +++ 17930.C (revision 154) @@ -0,0 +1,6 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/17930 + +char const one[] = "test"; +char const two[] = one; // { dg-error "" } // ERROR -
17930.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15756-1.C =================================================================== --- 15756-1.C (nonexistent) +++ 15756-1.C (revision 154) @@ -0,0 +1,36 @@ +// { dg-do assemble } +// { dg-options "-Wsign-promo" } +// 981203 bkoz +// g++/15756 test1 + +enum e_value { first = 0, next = 30 }; + +struct sanjuan { + sanjuan(int value); + sanjuan(unsigned value); + friend sanjuan operator&(const sanjuan& x, const sanjuan& y); + friend int operator!=(const sanjuan& x, const sanjuan& y); +}; + +extern void mod_enum(e_value*); +extern int a; + +void foo(void) { + e_value mod = first; + mod_enum(&mod); + if (mod != next) + ++a; +} + + + + + + + + + + + + +
15756-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 13478.C =================================================================== --- 13478.C (nonexistent) +++ 13478.C (revision 154) @@ -0,0 +1,36 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13478 + +class A {}; +class AData {}; + +typedef void (A::* hand) (void); + +struct hand_table { + const int data1; + const hand data2; +}; + +class Agent : public A { +public: + enum { first = 1, last }; +protected: + static const hand_table table_1[]; + static const AData table_2; +private: + void foo (void); +}; + +const hand_table Agent::table_1[] = +{ + {0, &Agent::table_2}, + {first, &Agent::foo}, + {last, &(hand)Agent::foo} // { dg-error "" } no match +}; // { dg-error "" } cannot convert + + + + + +
13478.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tem01.C =================================================================== --- tem01.C (nonexistent) +++ tem01.C (revision 154) @@ -0,0 +1,136 @@ +// { dg-do assemble } +// prms-id: 13911 + +template +class ref_counter { +public: + ref_counter() : p_refcnt(new unsigned int(N)) {} + ref_counter(const ref_counter& x) : p_refcnt(x.p_refcnt) { + ++*p_refcnt; + } + ref_counter& operator=(const ref_counter& rhs) { + ++*rhs.p_refcnt; + decrement(); + p_refcnt = rhs.p_refcnt; + return *this; + } + ~ref_counter() {decrement();} + + bool unique() const {return *p_refcnt == N;} + +private: + unsigned int* p_refcnt; + void decrement() { + if (unique()) delete p_refcnt; + else --*p_refcnt; + } +}; + +template +class ref_pointer { +public: + + ref_pointer() : the_p(0) {} + ref_pointer(T* just_newed) : the_p(just_newed) {} + virtual ~ref_pointer() {if (unique()) delete the_p;} +protected: + ref_pointer(T* the_p_arg, ref_counter& ref_count_arg) + : the_p(the_p_arg), ref_count(ref_count_arg) {} + +public: + + ref_pointer& operator=(const ref_pointer&); + ref_pointer& operator=(T*); + operator const T*() const {return the_p;} + T* operator()() {return the_p;} + T* operator()() const {return the_p;} + T& operator*() const {return *the_p;} + friend bool operator==(const ref_pointer& lhs, + const ref_pointer& rhs) { + return lhs.the_p == rhs.the_p; + } + friend bool operator!=(const ref_pointer& lhs, + const ref_pointer& rhs) { + return lhs.the_p != rhs.the_p; + } + + + bool unique() const {return ref_count.unique();} + bool isNull() const {return the_p==0;} + +protected: + ref_counter& refCount() {return ref_count;} + +private: + + ref_counter ref_count; + T* the_p; +}; + +template +ref_pointer& ref_pointer::operator=(const ref_pointer& rhs) { + if (the_p != rhs.the_p) { + if (unique()) delete the_p; + the_p = rhs.the_p; + ref_count = rhs.ref_count; + } + return *this; +} + + +template +ref_pointer& ref_pointer::operator=(T* just_newed) { + if (unique()) delete the_p; + the_p = just_newed; + ref_count = ref_counter(); + return *this; +} + + + +template +class CountedObjPtr : public ref_pointer { +public: + CountedObjPtr() {} + CountedObjPtr(T* just_newed) : ref_pointer(just_newed) {} + CountedObjPtr(T* the_p_arg, ref_counter<1>& ref_count_arg) + : ref_pointer(the_p_arg, ref_count_arg) {} + CountedObjPtr& operator=(T* rhs) { + ref_pointer::operator=(rhs); + return *this; + } + CountedObjPtr& operator=(const CountedObjPtr& rhs) { + ref_pointer::operator=(rhs); + return *this; + } + T* operator->() const {return (*this)();} + +}; + + + + + +//instantiating type + +class TSObservable; + +class TSObserver { +public: + + enum TSType { NormalTS, UpYldCrvTS, DownYldCrvTS, ZeroVolTS }; + + virtual ~TSObserver() {} + + virtual void update(TSObservable* theChangedObservable) = 0; + virtual TSType key() const { return myKey; } + virtual TSType& key() { return myKey; } +protected: + TSObserver(TSType myKeyArg) : myKey(myKeyArg) {} + TSType myKey; +}; + + + +//now try to instantiate +template class CountedObjPtr;
tem01.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 15756-2.C =================================================================== --- 15756-2.C (nonexistent) +++ 15756-2.C (revision 154) @@ -0,0 +1,50 @@ +// { dg-do assemble } +// { dg-options "-Wsign-promo" } +// 981203 bkoz +// g++/15756 test2 +// this test may only be valid for 32bit targets at present + +#include + +enum e_i { + vali +} +enum_int; + +enum e_ui { +#if INT_MAX == 32767 + valui = 0xF234 +#else + valui = 0xF2345678 +#endif +} +enum_uint; + +int i; +unsigned int ui; + +struct caracas { + caracas(int); + caracas(unsigned int); + void foo(); +}; + +int main () +{ + caracas obj_ei ( enum_int ); // { dg-warning "" } + caracas obj_eui ( enum_uint ); // { dg-warning "" } + caracas obj_i ( i ); + caracas obj_ui ( ui ); + + obj_ei.foo(); + obj_eui.foo(); + obj_i.foo(); + obj_ui.foo(); +} + + + + + + +
15756-2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tem02.C =================================================================== --- tem02.C (nonexistent) +++ tem02.C (revision 154) @@ -0,0 +1,54 @@ +// { dg-do assemble } +//980519 bad error from nathan +//$ egcs -fhonor-std -nostdinc -c redef.C +//redef.C:56: redefinition of default argument for `class _Traits' + +template struct char_traits; +template struct char_traits { }; +template<> struct char_traits; +template<> struct char_traits { }; + +template > class istreambuf_iterator; + + +template + class istreambuf_iterator +{ + public: + typedef _Traits traits_type; + class _Proxy; + public: + inline istreambuf_iterator() throw(); + inline istreambuf_iterator(const _Proxy& __p) throw(); +}; + + +template + class istreambuf_iterator<_CharT,_Traits>::_Proxy +{ + public: + _CharT operator*(); + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: no warnings + friend class istreambuf_iterator; // XXX OK? + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: no warnings + //friend class istreambuf_iterator<_CharT,_Traits>; + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: declaration of "_CharT" and "_Traits" hides template parameter + //template friend class istreambuf_iterator; + + //ok -g++ + //ok -edg + //friend class istreambuf_iterator<_CharT>; + +}; + + + +//explicit instantiation of a nested class +template class istreambuf_iterator >::_Proxy; +
tem02.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: 16567.C =================================================================== --- 16567.C (nonexistent) +++ 16567.C (revision 154) @@ -0,0 +1,44 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/16567 + +typedef bool Bool; +typedef unsigned char Uint8; +typedef unsigned short Uint16; +typedef unsigned int Uint32; + +enum e_ms { third = 3, fourth = 4 }; + +struct bitmask { + Uint8* anon1; + Uint32 anon2; + Uint8 anon3; + Uint8 here: 2; + Uint8 anon4: 2; + Uint8 anon5: 4; +}; + +struct control { + Uint8 foo_1(); +}; + +inline Uint8 foo_2(bitmask* p) { + return p->here; +} + +inline Uint8 control::foo_1() { + return foo_2((bitmask*) this); +} + +void foo(void) { + control obj; + control *fp = &obj; + e_ms result; + + result = (e_ms) fp->foo_1; // { dg-error "" } // ERROR - +} + + + + +
16567.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tem03.C =================================================================== --- tem03.C (nonexistent) +++ tem03.C (revision 154) @@ -0,0 +1,209 @@ +// { dg-do assemble } +// 980808-980824 bkoz +// template parameter redeclaration bugs + +// 14.1 Template parameters +// p 13 +// The scope of a template-parameter extens from its point of +// declartion until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +// 14.6.1 Locally declared names +// p 4 +// A template-parameter shall not be redeclared within its scope +// (including nested scopes). A template-parameter shall not have the +// sname name as the template name. + + +// 01 +// declared friend template +template // { dg-error "" } .* +class Xone { +protected: + T4* next; + T4* prev; + T4 value; +public: + Xone(): next(0), prev(0), value(1999){} + Xone(T4 init): value(init) {} + + // these are ok: + // can also do template-decl and then can ditch the foward-declaration + // template friend bool isequal (Xone& lhs, Xone& rhs); + // this is not ok: + template friend bool isequal (Xone& lhs, Xone& rhs);// { dg-error "" } .* +}; + + +// 02 +// nested template class +template // { dg-error "" } .* +class Xtwo { +protected: + T6* next; + T6* prev; + T6 value; +public: + Xtwo(): next(0), prev(0), value(1999){} + Xtwo(T6 init): value(init) {} + + template class nested {// { dg-error "" } .* + T6 value; + public: + nested(): value( T6(0)) {} + }; +}; + + +// 03 +// member templates +template // { dg-error "" } .* +class Xthree { +protected: + T8* next; + T8* prev; + T8 value; +public: + Xthree(): next(0), prev(0), value(1999){} + Xthree(T8 init): value(init) {} + + template T8 comp_ge(T8 test) {// { dg-error "" } .* + T8 local_value; + if (local_value > value) + return local_value; + else + return value; + } +}; + + +// 04 +// local names (14.6.1 p 4) +template struct Xfour {// { dg-error "" } .* + int T10; // { dg-error "" } .* + void f(){ + char T10; + } +}; + + +// 05 +// using different tempate-parms for out-of-line defs +template struct Xfive { + void f(); +}; + +template void Xfive::f() {// { dg-error "" } .* + int T13; // { dg-error "" } .* + int T12; //should be ok +} + + +// 06 +// multiple names at the same level +template class Xsix { // { dg-error "" } .* +private: +public: + void f(); +}; + + +// 07 +// multiple names, one in template parameter one in class-name +template class T12; // { dg-error "" } .* + + +// 08 +// with multiple template params, and second (third) one is redeclared +template class Xseven { // { dg-error "" } .* +private: + char T161; // { dg-error "" } .* +public: + template + friend bool fooy(U u); + + template + friend bool foo(T161 u) + { + Xseven obj; // { dg-error "" } .* + return (obj.inst == u.inst); // { dg-error "" } .* + } + +}; + + +// 09 +// check for correct scoping of member templates +template +struct S1 +{ + template + void f(U u) + { + S1 s2u(u); + s2u.g(); + } + + template //ok + void f2(U u) + { + S1 s2u(u); + s2u.g(); + } + +}; + + +// 10 +// check for non-type parameters, should still be able to redeclare? +// local names (14.6.1 p 4) +template class Xten {// { dg-error "" } .* + float i; // { dg-error "" } .* +}; + + +// 11 +// declared friend template, non-type parameters +template // { dg-error "" } .* +class Xeleven { +public: + template friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs); // { dg-error "" } .* +}; + + + +// 12 +// nested template class, non-type parameters +template // { dg-error "" } .* +class Xtwelve { +public: + template class nested {// { dg-error "" } . + long value; + public: + nested(): value(0) {} + }; +}; + + +// 13 +// member templates, non-type parameters +template // { dg-error "" } .* +struct Xthirteen { + template long comp_ge(long test) {// { dg-error "" } . + long local_value; + if (local_value > value) // { dg-error "" } .* + return local_value; + else + return value; + } +}; + + + + + + + + +
tem03.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tem04.C =================================================================== --- tem04.C (nonexistent) +++ tem04.C (revision 154) @@ -0,0 +1,182 @@ +// { dg-do assemble } +// 980827 bkoz +// template parameter redeclaration bugs, part two: +// template template params and expanded template non-type parms + +// 14.1 Template parameters +// p 13 +// The scope of a template-parameter extens from its point of +// declartion until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +// 14.6.1 Locally declared names +// p 4 +// A template-parameter shall not be redeclared within its scope +// (including nested scopes). A template-parameter shall not have the +// same name as the template name. + +// 14 +// declared friend template (v3, template type parameters) +template // { dg-error "" } .* +class Xfourteen { +protected: + T4 value; +public: + Xfourteen(T4 init): value(init) {} + template