class.c (duplicate_tag_error): Adjust diagnostic.
authorNathan Sidwell <nathan@codesourcery.com>
Mon, 8 Jan 2001 11:45:22 +0000 (11:45 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 8 Jan 2001 11:45:22 +0000 (11:45 +0000)
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

31 files changed:
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.benjamin/15309-1.C
gcc/testsuite/g++.old-deja/g++.benjamin/15309-2.C
gcc/testsuite/g++.old-deja/g++.brendan/crash17.C
gcc/testsuite/g++.old-deja/g++.brendan/crash29.C
gcc/testsuite/g++.old-deja/g++.brendan/crash48.C
gcc/testsuite/g++.old-deja/g++.brendan/ns1.C
gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C
gcc/testsuite/g++.old-deja/g++.bugs/900205_04.C
gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C
gcc/testsuite/g++.old-deja/g++.eh/spec6.C
gcc/testsuite/g++.old-deja/g++.jason/crash3.C
gcc/testsuite/g++.old-deja/g++.law/ctors11.C
gcc/testsuite/g++.old-deja/g++.law/ctors17.C
gcc/testsuite/g++.old-deja/g++.law/ctors5.C
gcc/testsuite/g++.old-deja/g++.law/ctors9.C
gcc/testsuite/g++.old-deja/g++.mike/ambig1.C
gcc/testsuite/g++.old-deja/g++.mike/net22.C
gcc/testsuite/g++.old-deja/g++.mike/p3538a.C
gcc/testsuite/g++.old-deja/g++.mike/p3538b.C
gcc/testsuite/g++.old-deja/g++.mike/virt3.C
gcc/testsuite/g++.old-deja/g++.niklas/t128.C
gcc/testsuite/g++.old-deja/g++.other/anon4.C
gcc/testsuite/g++.old-deja/g++.other/using1.C
gcc/testsuite/g++.old-deja/g++.other/warn3.C
gcc/testsuite/g++.old-deja/g++.pt/t37.C
gcc/testsuite/g++.old-deja/g++.robertl/eb69.C
gcc/testsuite/g++.old-deja/g++.robertl/eb71.C

index 1a6c0748b02663b058b36e20d8d673710553703d..91d53afc9d620eabbbc7ba3b0fd726c4c0337bce 100644 (file)
@@ -1,3 +1,9 @@
+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
index 65281a64f347ea4c263f224dd9e9a872a886908a..08027ef91d744a93e141b0e11b4b54404db5799d 100644 (file)
@@ -1,6 +1,6 @@
 /* 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)
index e15e77c479b95266752eac98ac32aa22445a846a..58fa5cda3e22366e430d56935e78c31312d75c3a 100644 (file)
@@ -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.
index 0a02df628afa5cbd580230ed07b8d4c5d9dd809f..4be78f2b329615babe4f0dbe4f9c7a136f9ddc22 100644 (file)
@@ -1,3 +1,34 @@
+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.
index ec83fb46ae4a762a687fbaf405d20b03825e3a96..ac3a5ec09716cb4d74b800eb7ecdc51e17d9515d 100644 (file)
@@ -10,11 +10,11 @@ public:
 };
 
 class miami : public bahamian
-{
+{ // WARNING - // WARNING -
 public:
    miami ();
    ~miami ();
-}; // WARNING - // WARNING -        
+};
 
 
 
index 1b483c869b99672ce3e922d31a5414bd6d67ff77..5a8155a36439fbc9b6123a81c2faa16e5d2471d3 100644 (file)
@@ -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 -
+};
index 7072eab2c8895980acba3b066b63d51dad0e86d4..70da8d50ada92165c451095353f89331bf9699d8 100644 (file)
@@ -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
+};
 
index 72bbdc77849c693cae4adc906e3ed380cc14d25d..b6af6a4d9113c816363396f86496d64648795f56 100644 (file)
@@ -7,9 +7,9 @@ union Value
 };
 
 struct GlobalAddress
-{
+{// ERROR -  candidates .*
        GlobalAddress(Value *nvar){}// ERROR - .*
-};// ERROR -  candidates .*
+};
 
 int
 main()
index 6dc9da09d0a0341b5cb4363beec1bf6aa11e92ac..86523d82d9c79bf954f753666b5100d7d6060311 100644 (file)
@@ -1,14 +1,14 @@
 // 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
index d20a9d939294cb6fe952bb0fedd0f6a360d420ec..312c93ae618443dababa20e96246b1a642c7d30d 100644 (file)
@@ -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
+};
index 02963623a22fde007d52aec137ca125d7ec3b093..962e718d01c9a98e031229884ea895e6a33fb328 100644 (file)
@@ -1,6 +1,6 @@
 // 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 - .*
+};
index f763480d45fc145231562f8b036a9dc266caf530..976951815cf6a7355b910fae48523dc054da9288 100644 (file)
@@ -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
 
index 54123f2bb1938b39e61266ac181e081e5527d5ac..7c4089a1bbf8953dc5a729897453c43740b680e0 100644 (file)
 
 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;
index 6ecaec0b116773117d1b49aed0fde5821ea0d4ec..1bde4cb92b85ee526260c65575fc5312adc9d5cb 100644 (file)
@@ -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
 {
index c3709c555360662d2014f3a47456e005b8d29bf7..bf63291abefc4ea9a887e93be197fa96fd92c018 100644 (file)
@@ -3,9 +3,9 @@
 // Build don't link:
 
 struct Node
-{
+{                              // ERROR - 
   Node* child[2];
-};                             // ERROR - 
+};
 
 void bug(int i)
 {
index 231d08ede6e548bbd44af0ea94f11f7235c895b3..195a8234560a652ac0af0615d29001aef9583e0d 100644 (file)
@@ -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()
 {
index eab071c1248b0046ff7b856cc6002d97404d8ba1..1f5f0b00c6ce4d299833b801bc6deef2f1885f59 100644 (file)
@@ -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");
index 3fc58041192acadaa46e6e721178236ebf91e379..faba9ba98b5e2991fdb3534b40d0c75fafc3ed35 100644 (file)
@@ -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
 {
index d926e64a075206f15fecab55bfc345da0fa579f7..4a7d24c6664d568dc280ebc23b6bb60cd1ff6a05 100644 (file)
@@ -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)
 {
index 4552791ad5ebfc0c40d7dd5a4b5ecb9403d7dd70..97200e2a8e79e405a2b63b4057600eb1e63b3c6e 100644 (file)
@@ -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;
index f18d0563f9f48e04e623e0404670f5b3664c688f..ff37d872a7824b833139632865123bf2250e95b2 100644 (file)
@@ -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
index ea1a6cc53a722f175990852c488d3de22a21232a..6335c9631be48a3736e014bb4419daa79acc1287 100644 (file)
@@ -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> {};
index 4dcd60b3d10cd7b0f8abb37e3d20a2756d1c1148..b9bead04594061b1e372e0bb80273b4c4f616787 100644 (file)
@@ -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> {};
index 3795b89cca692b0f8f9e7010458797511483dac2..3d482feb99245996c5540a2c22fafed1fe53e331 100644 (file)
@@ -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;
index 7ada1dc685e6bfc8fbca75404d8cca64535be30a..9865b8ca8e3731c00fe4cc8dfa6f356949a7b9bf 100644 (file)
@@ -1,5 +1,5 @@
 // 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 - .*
index cace54456c8490d8d9a82df3829d28830c78f89a..c6d97e14ce5206575b16e8504b527047ad11ade7 100644 (file)
@@ -10,7 +10,7 @@
 struct A
 {
   union
-  {
+  {  // ERROR - anon union cannot have member fns
     void bad();
-  };  // ERROR - anon union cannot have member fns
+  };
 };
index d22d512f64b8c35f8b68fac19a99d11fd73331a1..a431a957a3927d5810eabf460f0b6462a35b41ce 100644 (file)
@@ -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
+};
  
index 4827c5645f2acf498ad480c56c1f76b5dae0d670..64296306102a391c84f81aff8837f84f3ffda10a 100644 (file)
@@ -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
+};
index 434dadd8228486731eac8f196c92f338b39d9eac..cb957ecdd2bc91dcf30b42b3f78f85ac3d222707 100644 (file)
@@ -1,11 +1,11 @@
 // 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 - 
 }
index 4dfa523f98e5e582b2394e2659ada5f9632839fd..2daa5fe3e45be8367c27c0d0a369536d33fb99c6 100644 (file)
@@ -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;
index 1417c4ab891b529519e96924de262002af3210d7..a9ed56457d1f56c7d62c16c67aa20d1cba98790f 100644 (file)
@@ -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)