Commit 1f0d71c5 by Nathan Sidwell Committed by Nathan Sidwell

class.c (duplicate_tag_error): Adjust diagnostic.

cp:
	* class.c (duplicate_tag_error): Adjust diagnostic.
	(finish_struct): Locally set location to start of struct.
	* decl.c (fixup_anonymous_aggr): Use cp_error_at.
testsuite:
	* g++.old-deja/g++.benjamin/15309-1.C: Expect diagnostic at
	start of structs.
	* g++.old-deja/g++.benjamin/15309-2.C: Likewise.
	* g++.old-deja/g++.brendan/crash17.C: Likewise.
	* g++.old-deja/g++.brendan/crash29.C: Likewise.
	* g++.old-deja/g++.brendan/crash48.C: Likewise.
	* g++.old-deja/g++.brendan/ns1.C: Likewise.
	* g++.old-deja/g++.brendan/warnings1.C: Likewise.
	* g++.old-deja/g++.bugs/900205_04.C: Likewise.
	* g++.old-deja/g++.bugs/900514_03.C: Likewise.
	* g++.old-deja/g++.eh/spec6.C: Likewise.
	* g++.old-deja/g++.jason/crash3.C: Likewise.
	* g++.old-deja/g++.law/ctors11.C: Likewise.
	* g++.old-deja/g++.law/ctors17.C: Likewise.
	* g++.old-deja/g++.law/ctors5.C: Likewise.
	* g++.old-deja/g++.law/ctors9.C: Likewise.
	* g++.old-deja/g++.mike/ambig1.C: Likewise.
	* g++.old-deja/g++.mike/net22.C: Likewise.
	* g++.old-deja/g++.mike/p3538a.C: Likewise.
	* g++.old-deja/g++.mike/p3538b.C: Likewise.
	* g++.old-deja/g++.mike/virt3.C: Likewise.
	* g++.old-deja/g++.niklas/t128.C: Likewise.
	* g++.old-deja/g++.other/anon4.C: Likewise.
	* g++.old-deja/g++.other/using1.C: Likewise.
	* g++.old-deja/g++.other/warn3.C: Likewise.
	* g++.old-deja/g++.pt/t37.C: Likewise.
	* g++.old-deja/g++.robertl/eb69.C: Likewise.
	* g++.old-deja/g++.robertl/eb71.C: Likewise.

From-SVN: r38798
parent 5bf15e84
2001-01-08 Nathan Sidwell <nathan@codesourcery.com> 2001-01-08 Nathan Sidwell <nathan@codesourcery.com>
* class.c (duplicate_tag_error): Adjust diagnostic.
(finish_struct): Locally set location to start of struct.
* decl.c (fixup_anonymous_aggr): Use cp_error_at.
2001-01-08 Nathan Sidwell <nathan@codesourcery.com>
* decl.c (struct binding_level): Adjust class_shadowed comments * decl.c (struct binding_level): Adjust class_shadowed comments
to reflect reality. to reflect reality.
(push_class_level_binding): Ajust comments to reflect reality. (push_class_level_binding): Ajust comments to reflect reality.
......
/* Functions related to building classes and their related objects. /* Functions related to building classes and their related objects.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -2316,7 +2316,7 @@ duplicate_tag_error (t) ...@@ -2316,7 +2316,7 @@ duplicate_tag_error (t)
tree t; tree t;
{ {
cp_error ("redefinition of `%#T'", t); cp_error ("redefinition of `%#T'", t);
cp_error_at ("previous definition here", t); cp_error_at ("previous definition of `%#T'", t);
/* Pretend we haven't defined this type. */ /* Pretend we haven't defined this type. */
...@@ -5328,12 +5328,20 @@ tree ...@@ -5328,12 +5328,20 @@ tree
finish_struct (t, attributes) finish_struct (t, attributes)
tree t, attributes; tree t, attributes;
{ {
char *saved_filename = input_filename;
int saved_lineno = lineno;
/* Now that we've got all the field declarations, reverse everything /* Now that we've got all the field declarations, reverse everything
as necessary. */ as necessary. */
unreverse_member_declarations (t); unreverse_member_declarations (t);
cplus_decl_attributes (t, attributes, NULL_TREE); cplus_decl_attributes (t, attributes, NULL_TREE);
/* Nadger the current location so that diagnostics point to the start of
the struct, not the end. */
input_filename = DECL_SOURCE_FILE (TYPE_NAME (t));
lineno = DECL_SOURCE_LINE (TYPE_NAME (t));
if (processing_template_decl) if (processing_template_decl)
{ {
finish_struct_methods (t); finish_struct_methods (t);
...@@ -5342,6 +5350,9 @@ finish_struct (t, attributes) ...@@ -5342,6 +5350,9 @@ finish_struct (t, attributes)
else else
finish_struct_1 (t); finish_struct_1 (t);
input_filename = saved_filename;
lineno = saved_lineno;
TYPE_BEING_DEFINED (t) = 0; TYPE_BEING_DEFINED (t) = 0;
if (current_class_type) if (current_class_type)
......
...@@ -6837,7 +6837,7 @@ fixup_anonymous_aggr (t) ...@@ -6837,7 +6837,7 @@ fixup_anonymous_aggr (t)
/* ISO C++ 9.5.3. Anonymous unions may not have function members. */ /* ISO C++ 9.5.3. Anonymous unions may not have function members. */
if (TYPE_METHODS (t)) if (TYPE_METHODS (t))
error ("an anonymous union cannot have function members"); cp_error_at ("an anonymous union cannot have function members", t);
} }
/* Make sure that a declaration with no declarator is well-formed, i.e. /* Make sure that a declaration with no declarator is well-formed, i.e.
......
2001-01-08 Nathan Sidwell <nathan@codesourcery.com> 2001-01-08 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.benjamin/15309-1.C: Expect diagnostic at
start of structs.
* g++.old-deja/g++.benjamin/15309-2.C: Likewise.
* g++.old-deja/g++.brendan/crash17.C: Likewise.
* g++.old-deja/g++.brendan/crash29.C: Likewise.
* g++.old-deja/g++.brendan/crash48.C: Likewise.
* g++.old-deja/g++.brendan/ns1.C: Likewise.
* g++.old-deja/g++.brendan/warnings1.C: Likewise.
* g++.old-deja/g++.bugs/900205_04.C: Likewise.
* g++.old-deja/g++.bugs/900514_03.C: Likewise.
* g++.old-deja/g++.eh/spec6.C: Likewise.
* g++.old-deja/g++.jason/crash3.C: Likewise.
* g++.old-deja/g++.law/ctors11.C: Likewise.
* g++.old-deja/g++.law/ctors17.C: Likewise.
* g++.old-deja/g++.law/ctors5.C: Likewise.
* g++.old-deja/g++.law/ctors9.C: Likewise.
* g++.old-deja/g++.mike/ambig1.C: Likewise.
* g++.old-deja/g++.mike/net22.C: Likewise.
* g++.old-deja/g++.mike/p3538a.C: Likewise.
* g++.old-deja/g++.mike/p3538b.C: Likewise.
* g++.old-deja/g++.mike/virt3.C: Likewise.
* g++.old-deja/g++.niklas/t128.C: Likewise.
* g++.old-deja/g++.other/anon4.C: Likewise.
* g++.old-deja/g++.other/using1.C: Likewise.
* g++.old-deja/g++.other/warn3.C: Likewise.
* g++.old-deja/g++.pt/t37.C: Likewise.
* g++.old-deja/g++.robertl/eb69.C: Likewise.
* g++.old-deja/g++.robertl/eb71.C: Likewise.
2001-01-08 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/lookup16.C: Remove XFAIL. * g++.old-deja/g++.other/lookup16.C: Remove XFAIL.
2001-01-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2001-01-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
......
...@@ -10,11 +10,11 @@ public: ...@@ -10,11 +10,11 @@ public:
}; };
class miami : public bahamian class miami : public bahamian
{ { // WARNING - // WARNING -
public: public:
miami (); miami ();
~miami (); ~miami ();
}; // WARNING - // WARNING - };
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// Build don't link: // Build don't link:
// Special g++ Options: -Wnon-virtual-dtor -Weffc++ // Special g++ Options: -Wnon-virtual-dtor -Weffc++
class bermuda { class bermuda { // WARNING - // WARNING -
public: public:
virtual int func1(int); virtual int func1(int);
~bermuda(); ~bermuda();
}; // WARNING - // WARNING - };
...@@ -30,6 +30,6 @@ class GnWidget : public GnObject { ...@@ -30,6 +30,6 @@ class GnWidget : public GnObject {
virtual ~GnWidget(); virtual ~GnWidget();
}; };
class GnOptionGroup : public GnObject, public GnWidget { class GnOptionGroup : public GnObject, public GnWidget {// ERROR - warning
};// ERROR - warning };
...@@ -7,9 +7,9 @@ union Value ...@@ -7,9 +7,9 @@ union Value
}; };
struct GlobalAddress struct GlobalAddress
{ {// ERROR - candidates .*
GlobalAddress(Value *nvar){}// ERROR - .* GlobalAddress(Value *nvar){}// ERROR - .*
};// ERROR - candidates .* };
int int
main() main()
......
// Build don't link: // Build don't link:
// GROUPS passed old-abort // GROUPS passed old-abort
class internal { class internal { // ERROR - candidates are
int field; int field;
int anotherfield; int anotherfield;
}; // ERROR - candidates are };
class bug { class bug { // ERROR - several errors
internal* numbers; internal* numbers;
bug(int size); bug(int size);
}; // ERROR - several errors };
bug::bug(int size) bug::bug(int size)
{ // ERROR - candidates { // ERROR - candidates
......
...@@ -7,12 +7,12 @@ struct B ...@@ -7,12 +7,12 @@ struct B
}; };
class C class C
{ { // ERROR - warning
int g(); int g();
};// ERROR - warning };
class D2 : public B class D2 : public B
{ { // ERROR - type C is not a base type for type D2
using B::f; // ok: B is a base of D using B::f; // ok: B is a base of D
using C::g; // error: C isn't a base of D2 using C::g; // error: C isn't a base of D2
}; // ERROR - type C is not a base type for type D2 };
// Build don't link: // Build don't link:
// GROUPS passed warnings // GROUPS passed warnings
// there should be a warning about foo only defining private methods // there should be a warning about foo only defining private methods
class foo { class foo { // ERROR - .*
int bar(); int bar();
};// ERROR - .* };
...@@ -18,8 +18,8 @@ struct0::struct0 (int, void *) ...@@ -18,8 +18,8 @@ struct0::struct0 (int, void *)
{ {
} }
struct struct0_derived_struct_0 : public struct0 { struct struct0_derived_struct_0 : public struct0 { // ERROR -
}; // ERROR - };
// struct0_derived_struct_0 object; // would give g++ error if compiled // struct0_derived_struct_0 object; // would give g++ error if compiled
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
struct t_0_st_0; struct t_0_st_0;
struct t_0_st_1 { struct t_0_st_1 { // ERROR -
int member; int member;
t_0_st_1 (t_0_st_0&);// ERROR - t_0_st_1 (t_0_st_0&);// ERROR -
t_0_st_1 (); t_0_st_1 ();
};// ERROR - };
struct t_0_st_0 { struct t_0_st_0 {
int member; int member;
...@@ -80,12 +80,12 @@ void t_1_local_init () ...@@ -80,12 +80,12 @@ void t_1_local_init ()
struct t_2_st_0; struct t_2_st_0;
struct t_2_st_1 { struct t_2_st_1 { // ERROR - candidate
int member; int member;
t_2_st_1 (t_2_st_0); // ERROR - candidate t_2_st_1 (t_2_st_0); // ERROR - candidate
t_2_st_1 (); t_2_st_1 ();
}; // ERROR - candidate };
struct t_2_st_0 { struct t_2_st_0 {
int member; int member;
......
...@@ -123,10 +123,10 @@ struct B1 : A ...@@ -123,10 +123,10 @@ struct B1 : A
}; };
struct C : A, A1 struct C : A, A1
{ { // ERROR - looser throw - A::~A()
virtual void foo() throw(int); // ERROR - looser throw - A::foo virtual void foo() throw(int); // ERROR - looser throw - A::foo
virtual void bar() throw(int); // ERROR - looser throw - A1::bar virtual void bar() throw(int); // ERROR - looser throw - A1::bar
}; // ERROR - looser throw - A::~A() };
struct D : A, A1 struct D : A, A1
{ {
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// Build don't link: // Build don't link:
struct Node struct Node
{ { // ERROR -
Node* child[2]; Node* child[2];
}; // ERROR - };
void bug(int i) void bug(int i)
{ {
......
...@@ -10,10 +10,10 @@ public: ...@@ -10,10 +10,10 @@ public:
inline A(int x){printf("constructing A with %d\n", x);} inline A(int x){printf("constructing A with %d\n", x);}
}; };
class B:public A{ class B:public A{ // ERROR - non-default constructor
private: private:
public: public:
}; // ERROR - non-default constructor };
int main() int main()
{ {
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include <fstream.h> #include <fstream.h>
class X : public ifstream { class X : public ifstream { // ERROR - candidate
public: public:
X(int a, char *b) {} // ERROR - candidate X(int a, char *b) {} // ERROR - candidate
}; // ERROR - candidate };
int main() int main()
{ {
X *y = new X(10, "123"); X *y = new X(10, "123");
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
// Date: Tue, 1 Sep 92 10:38:44 EDT // Date: Tue, 1 Sep 92 10:38:44 EDT
class X class X
{ { // ERROR - candidate
private: private:
int x; int x;
public: public:
static const X x0; static const X x0;
X( int ); X( int );
}; // ERROR - candidate };
class Y class Y
{ {
......
...@@ -21,9 +21,9 @@ Foo::Foo(int aa) ...@@ -21,9 +21,9 @@ Foo::Foo(int aa)
struct var_Foo: public Foo struct var_Foo: public Foo
{ { // ERROR - base.*// ERROR - in class.*
var_Foo* operator-> () {return this;} var_Foo* operator-> () {return this;}
};// ERROR - base.*// ERROR - in class.* };
int blort(Foo& f) int blort(Foo& f)
{ {
......
...@@ -20,8 +20,8 @@ class lM : public M { ...@@ -20,8 +20,8 @@ class lM : public M {
class rM : public M { class rM : public M {
}; };
class D : public lM, rM { class D : public lM, rM { // ERROR - ambiguous function
} d; // ERROR - ambiguous function } d;
int main() { int main() {
((lM*)&d)->i = 1; ((lM*)&d)->i = 1;
......
...@@ -4,8 +4,8 @@ public: ...@@ -4,8 +4,8 @@ public:
Parent( char *s ) {} Parent( char *s ) {}
}; };
class Child : public Parent { class Child : public Parent { // ERROR - called
}; // ERROR - called };
int main() { int main() {
Child c( "String initializer" ); // ERROR - bad Child c( "String initializer" ); // ERROR - bad
......
...@@ -25,9 +25,9 @@ class ccHandleBase : public ccObjectInfo ...@@ -25,9 +25,9 @@ class ccHandleBase : public ccObjectInfo
{}; {};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{ { // WARNING -
public: public:
virtual const ccObjectInfo& ri (int); virtual const ccObjectInfo& ri (int);
}; // WARNING - };
class ccCircleHdl : public ccHandle <cc_CircleHdl> {}; class ccCircleHdl : public ccHandle <cc_CircleHdl> {};
...@@ -27,9 +27,9 @@ class ccHandleBase : public ccObjectInfo ...@@ -27,9 +27,9 @@ class ccHandleBase : public ccObjectInfo
{}; {};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{ { // WARNING -
public: public:
virtual const ccObjectInfo& repInvariant (int); virtual const ccObjectInfo& repInvariant (int);
}; // WARNING - };
class ccCircleHdl : public ccHandle <cc_CircleHdl> {}; class ccCircleHdl : public ccHandle <cc_CircleHdl> {};
...@@ -10,8 +10,8 @@ class D : private B { ...@@ -10,8 +10,8 @@ class D : private B {
int Di; int Di;
}; };
class E : public virtual D, public B { class E : public virtual D, public B { // WARNING - direct base inaccessible due to ambiguity
int Ei; int Ei;
}; // WARNING - direct base inaccessible due to ambiguity };
E e; E e;
// Build don't link: // Build don't link:
// GROUPS niklas uncaught default-construct // GROUPS niklas uncaught default-construct
struct A { A (int); }; struct A { A (int); };
struct B : A {}; // ERROR - struct B : A {}; // ERROR - without ctor // ERROR - candidates
void f () { B (0); }// ERROR - .* void f () { B (0); }// ERROR - .*
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
struct A struct A
{ {
union union
{ { // ERROR - anon union cannot have member fns
void bad(); void bad();
}; // ERROR - anon union cannot have member fns };
}; };
...@@ -9,18 +9,18 @@ protected: ...@@ -9,18 +9,18 @@ protected:
friend class D2; friend class D2;
}; };
class D : public B { class D : public B { // ERROR - within this context
public: public:
using B::a; using B::a;
using B::b; using B::b;
}; // ERROR - within this context };
class D2 : public B { class D2 : public B { // ERROR - conflicting access specifications
public: public:
using B::a; using B::a;
using B::b; using B::b;
private: private:
using B::b; using B::b;
}; // ERROR - conflicting access specifications };
...@@ -4,51 +4,51 @@ class A { ...@@ -4,51 +4,51 @@ class A {
}; };
class B { class B { // WARNING - only private constructors
public: public:
void f(); void f();
private: private:
B (); B ();
B (const B&); B (const B&);
}; // WARNING - only private constructors };
class C { class C { // WARNING - only private destructors
public: public:
void f(); void f();
private: private:
~C (); ~C ();
}; // WARNING - only private destructors };
class D { class D { // WARNING - all member functions are private
private: private:
void f(); void f();
}; // WARNING - all member functions are private };
template <class T> template <class T>
class X { class X { // WARNING - only private destructors
private: private:
~X (); ~X ();
}; // WARNING - only private destructors };
template class X<int>; template class X<int>;
template class X<double>; template class X<double>;
template <class T> template <class T>
class Y { class Y { // WARNING - only private constructors
private: private:
Y (); Y ();
Y (const Y&); Y (const Y&);
}; // WARNING - only private constructors };
template <class T> template <class T>
class Z { class Z { // WARNING - all member functions are private
private: private:
void f(); void f();
}; // WARNING - all member functions are private };
// Build don't link: // Build don't link:
class A { class A { // ERROR - synthesized copy ctor
public: public:
A(int); // ERROR - referenced below A(int); // ERROR - referenced below
A(float); // ERROR - referenced below A(float); // ERROR - referenced below
~A(); ~A();
}; // ERROR - synthesized copy ctor };
A::A() { // ERROR - A::A() { // ERROR -
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
int r = 0; int r = 0;
struct foo { struct foo { // ERROR - candidate
foo(int x) { r = 1; } // ERROR - candidate foo(int x) { r = 1; } // ERROR - candidate
}; // ERROR - candidate };
struct bar : foo { struct bar : foo {
typedef int an_int; typedef int an_int;
......
...@@ -15,10 +15,10 @@ friend class D; ...@@ -15,10 +15,10 @@ friend class D;
unsigned counter; unsigned counter;
}; };
class D { class D { //WARNING - only private members
int ins( B*&); int ins( B*&);
}; //WARNING - only private members };
int int
D::ins( B*& tempN) D::ins( B*& tempN)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment