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>
* 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
to reflect reality.
(push_class_level_binding): Ajust comments to reflect reality.
......
/* Functions related to building classes and their related objects.
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)
This file is part of GNU CC.
......@@ -2316,7 +2316,7 @@ duplicate_tag_error (t)
tree 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. */
......@@ -5328,12 +5328,20 @@ tree
finish_struct (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
as necessary. */
unreverse_member_declarations (t);
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)
{
finish_struct_methods (t);
......@@ -5342,6 +5350,9 @@ finish_struct (t, attributes)
else
finish_struct_1 (t);
input_filename = saved_filename;
lineno = saved_lineno;
TYPE_BEING_DEFINED (t) = 0;
if (current_class_type)
......
......@@ -6837,7 +6837,7 @@ fixup_anonymous_aggr (t)
/* ISO C++ 9.5.3. Anonymous unions may not have function members. */
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.
......
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.
2001-01-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
......
......@@ -10,11 +10,11 @@ public:
};
class miami : public bahamian
{
{ // WARNING - // WARNING -
public:
miami ();
~miami ();
}; // WARNING - // WARNING -
};
......
......@@ -3,8 +3,8 @@
// Build don't link:
// Special g++ Options: -Wnon-virtual-dtor -Weffc++
class bermuda {
class bermuda { // WARNING - // WARNING -
public:
virtual int func1(int);
~bermuda();
}; // WARNING - // WARNING -
};
......@@ -30,6 +30,6 @@ class GnWidget : public GnObject {
virtual ~GnWidget();
};
class GnOptionGroup : public GnObject, public GnWidget {
};// ERROR - warning
class GnOptionGroup : public GnObject, public GnWidget {// ERROR - warning
};
......@@ -7,9 +7,9 @@ union Value
};
struct GlobalAddress
{
{// ERROR - candidates .*
GlobalAddress(Value *nvar){}// ERROR - .*
};// ERROR - candidates .*
};
int
main()
......
// Build don't link:
// GROUPS passed old-abort
class internal {
class internal { // ERROR - candidates are
int field;
int anotherfield;
}; // ERROR - candidates are
};
class bug {
class bug { // ERROR - several errors
internal* numbers;
bug(int size);
}; // ERROR - several errors
};
bug::bug(int size)
{ // ERROR - candidates
......
......@@ -7,12 +7,12 @@ struct B
};
class C
{
{ // ERROR - warning
int g();
};// ERROR - warning
};
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 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:
// GROUPS passed warnings
// there should be a warning about foo only defining private methods
class foo {
class foo { // ERROR - .*
int bar();
};// ERROR - .*
};
......@@ -18,8 +18,8 @@ struct0::struct0 (int, void *)
{
}
struct struct0_derived_struct_0 : public struct0 {
}; // ERROR -
struct struct0_derived_struct_0 : public struct0 { // ERROR -
};
// struct0_derived_struct_0 object; // would give g++ error if compiled
......
......@@ -13,12 +13,12 @@
struct t_0_st_0;
struct t_0_st_1 {
struct t_0_st_1 { // ERROR -
int member;
t_0_st_1 (t_0_st_0&);// ERROR -
t_0_st_1 ();
};// ERROR -
};
struct t_0_st_0 {
int member;
......@@ -80,12 +80,12 @@ void t_1_local_init ()
struct t_2_st_0;
struct t_2_st_1 {
struct t_2_st_1 { // ERROR - candidate
int member;
t_2_st_1 (t_2_st_0); // ERROR - candidate
t_2_st_1 ();
}; // ERROR - candidate
};
struct t_2_st_0 {
int member;
......
......@@ -123,10 +123,10 @@ struct B1 : A
};
struct C : A, A1
{
{ // ERROR - looser throw - A::~A()
virtual void foo() throw(int); // ERROR - looser throw - A::foo
virtual void bar() throw(int); // ERROR - looser throw - A1::bar
}; // ERROR - looser throw - A::~A()
};
struct D : A, A1
{
......
......@@ -3,9 +3,9 @@
// Build don't link:
struct Node
{
{ // ERROR -
Node* child[2];
}; // ERROR -
};
void bug(int i)
{
......
......@@ -10,10 +10,10 @@ public:
inline A(int x){printf("constructing A with %d\n", x);}
};
class B:public A{
class B:public A{ // ERROR - non-default constructor
private:
public:
}; // ERROR - non-default constructor
};
int main()
{
......
......@@ -9,10 +9,10 @@
#include <fstream.h>
class X : public ifstream {
class X : public ifstream { // ERROR - candidate
public:
X(int a, char *b) {} // ERROR - candidate
}; // ERROR - candidate
};
int main()
{
X *y = new X(10, "123");
......
......@@ -5,13 +5,13 @@
// Date: Tue, 1 Sep 92 10:38:44 EDT
class X
{
{ // ERROR - candidate
private:
int x;
public:
static const X x0;
X( int );
}; // ERROR - candidate
};
class Y
{
......
......@@ -21,9 +21,9 @@ Foo::Foo(int aa)
struct var_Foo: public Foo
{
{ // ERROR - base.*// ERROR - in class.*
var_Foo* operator-> () {return this;}
};// ERROR - base.*// ERROR - in class.*
};
int blort(Foo& f)
{
......
......@@ -20,8 +20,8 @@ class lM : public M {
class rM : public M {
};
class D : public lM, rM {
} d; // ERROR - ambiguous function
class D : public lM, rM { // ERROR - ambiguous function
} d;
int main() {
((lM*)&d)->i = 1;
......
......@@ -4,8 +4,8 @@ public:
Parent( char *s ) {}
};
class Child : public Parent {
}; // ERROR - called
class Child : public Parent { // ERROR - called
};
int main() {
Child c( "String initializer" ); // ERROR - bad
......
......@@ -25,9 +25,9 @@ class ccHandleBase : public ccObjectInfo
{};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{
{ // WARNING -
public:
virtual const ccObjectInfo& ri (int);
}; // WARNING -
};
class ccCircleHdl : public ccHandle <cc_CircleHdl> {};
......@@ -27,9 +27,9 @@ class ccHandleBase : public ccObjectInfo
{};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{
{ // WARNING -
public:
virtual const ccObjectInfo& repInvariant (int);
}; // WARNING -
};
class ccCircleHdl : public ccHandle <cc_CircleHdl> {};
......@@ -10,8 +10,8 @@ class D : private B {
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;
}; // WARNING - direct base inaccessible due to ambiguity
};
E e;
// Build don't link:
// GROUPS niklas uncaught default-construct
struct A { A (int); };
struct B : A {}; // ERROR -
struct B : A {}; // ERROR - without ctor // ERROR - candidates
void f () { B (0); }// ERROR - .*
......@@ -10,7 +10,7 @@
struct A
{
union
{
{ // ERROR - anon union cannot have member fns
void bad();
}; // ERROR - anon union cannot have member fns
};
};
......@@ -9,18 +9,18 @@ protected:
friend class D2;
};
class D : public B {
class D : public B { // ERROR - within this context
public:
using B::a;
using B::b;
}; // ERROR - within this context
};
class D2 : public B {
class D2 : public B { // ERROR - conflicting access specifications
public:
using B::a;
using B::b;
private:
using B::b;
}; // ERROR - conflicting access specifications
};
......@@ -4,51 +4,51 @@ class A {
};
class B {
class B { // WARNING - only private constructors
public:
void f();
private:
B ();
B (const B&);
}; // WARNING - only private constructors
};
class C {
class C { // WARNING - only private destructors
public:
void f();
private:
~C ();
}; // WARNING - only private destructors
};
class D {
class D { // WARNING - all member functions are private
private:
void f();
}; // WARNING - all member functions are private
};
template <class T>
class X {
class X { // WARNING - only private destructors
private:
~X ();
}; // WARNING - only private destructors
};
template class X<int>;
template class X<double>;
template <class T>
class Y {
class Y { // WARNING - only private constructors
private:
Y ();
Y (const Y&);
}; // WARNING - only private constructors
};
template <class T>
class Z {
class Z { // WARNING - all member functions are private
private:
void f();
}; // WARNING - all member functions are private
};
// Build don't link:
class A {
class A { // ERROR - synthesized copy ctor
public:
A(int); // ERROR - referenced below
A(float); // ERROR - referenced below
~A();
}; // ERROR - synthesized copy ctor
};
A::A() { // ERROR -
}
......
......@@ -4,9 +4,9 @@
int r = 0;
struct foo {
struct foo { // ERROR - candidate
foo(int x) { r = 1; } // ERROR - candidate
}; // ERROR - candidate
};
struct bar : foo {
typedef int an_int;
......
......@@ -15,10 +15,10 @@ friend class D;
unsigned counter;
};
class D {
class D { //WARNING - only private members
int ins( B*&);
}; //WARNING - only private members
};
int
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