parser.c (cp_parser_class_specifier): Set class location to that of IDENTIFIER_NODE instead of '{' when possible.

* parser.c (cp_parser_class_specifier): Set class location to that
	of IDENTIFIER_NODE instead of '{' when possible.
	* semantics.c (begin_class_definition): Do not overide locations
	with less precise ones.

From-SVN: r158030
This commit is contained in:
Jason Merrill 2010-04-06 17:13:07 -04:00
parent 9310a3e269
commit d4a2b48623
47 changed files with 151 additions and 102 deletions

View File

@ -1,3 +1,11 @@
2010-04-06 Taras Glek <taras@mozilla.com>
Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_class_specifier): Set class location to that
of IDENTIFIER_NODE instead of '{' when possible.
* semantics.c (begin_class_definition): Do not overide locations
with less precise ones.
2010-04-06 Jason Merrill <jason@redhat.com>
PR c++/43648

View File

@ -16395,6 +16395,9 @@ cp_parser_class_head (cp_parser* parser,
end_specialization ();
--parser->num_template_parameter_lists;
}
if (type)
DECL_SOURCE_LOCATION (TYPE_NAME (type)) = type_start_token->location;
*attributes_p = attributes;
return type;
}

View File

@ -2409,9 +2409,6 @@ begin_class_definition (tree t, tree attributes)
pushtag (make_anon_name (), t, /*tag_scope=*/ts_current);
}
/* Update the location of the decl. */
DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location;
if (TYPE_BEING_DEFINED (t))
{
t = make_class_type (TREE_CODE (t));

View File

@ -1,3 +1,45 @@
2010-04-06 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/pr31437.C: Adjust error location.
* g++.dg/ext/attrib18.C: Likewise.
* g++.dg/ext/bitfield2.C: Likewise.
* g++.dg/ext/bitfield4.C: Likewise.
* g++.dg/ext/visibility/warn2.C: Likewise.
* g++.dg/ext/visibility/warn3.C: Likewise.
* g++.dg/gomp/pr26690-1.C: Likewise.
* g++.dg/inherit/covariant7.C: Likewise.
* g++.dg/init/synth2.C: Likewise.
* g++.dg/lookup/using7.C: Likewise.
* g++.dg/other/crash-4.C: Likewise.
* g++.dg/other/error13.C: Likewise.
* g++.dg/other/error20.C: Likewise.
* g++.dg/parse/crash31.C: Likewise.
* g++.dg/parse/error16.C: Likewise.
* g++.dg/parse/error19.C: Likewise.
* g++.dg/parse/error27.C: Likewise.
* g++.dg/parse/error28.C: Likewise.
* g++.dg/parse/fused-params1.C: Likewise.
* g++.dg/template/error2.C: Likewise.
* g++.dg/template/local6.C: Likewise.
* g++.dg/template/qualttp15.C: Likewise.
* g++.dg/warn/Wnvdtor-2.C: Likewise.
* g++.dg/warn/anonymous-namespace-3.C: Likewise.
* g++.old-deja/g++.benjamin/15309-1.C: Likewise.
* g++.old-deja/g++.brendan/crash29.C: Likewise.
* g++.old-deja/g++.eh/spec6.C: Likewise.
* g++.old-deja/g++.jason/crash3.C: Likewise.
* g++.old-deja/g++.jason/destruct2.C: Likewise.
* g++.old-deja/g++.law/ctors5.C: Likewise.
* g++.old-deja/g++.law/ctors9.C: Likewise.
* g++.old-deja/g++.mike/p3538a.C: Likewise.
* g++.old-deja/g++.mike/p3538b.C: Likewise.
* g++.old-deja/g++.other/struct1.C: Likewise.
* g++.old-deja/g++.other/volatile1.C: Likewise.
* g++.old-deja/g++.pt/crash36.C: Likewise.
* g++.old-deja/g++.pt/derived3.C: Likewise.
* g++.old-deja/g++.robertl/eb109.C: Likewise.
* g++.old-deja/g++.robertl/eb4.C: Likewise.
2010-04-06 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/43519

View File

@ -1,6 +1,6 @@
// { dg-options "-std=gnu++0x" }
template <typename... T> struct A
{ // { dg-error "candidates|A" }
template <typename... T> struct A // { dg-error "candidates|A" }
{
A(T* p) { // { dg-error "parameter packs|T" }
(A<T...>*)(p);
}

View File

@ -2,8 +2,8 @@
// Test that we warn when an attribute preceding the class-key is ignored.
// { dg-do compile }
__attribute__ ((packed)) struct A
{ // { dg-warning "attribute" }
__attribute__ ((packed)) struct A // { dg-warning "attribute" }
{
char c;
int x;
void f();

View File

@ -3,8 +3,8 @@
/* { dg-options "" } */
/* { dg-options "-mno-ms-bitfields" { target i?86-*-netware } } */
struct t
{ /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */
struct t /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */
{
char a:4;
char b:8;
char c:4;

View File

@ -2,8 +2,8 @@
/* { dg-options "" } */
/* { dg-options "-mno-ms-bitfields" { target i?86-*-netware } } */
struct t
{ /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */
struct t /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */
{
char a:4;
char b:8 __attribute__ ((packed));
char c:4;

View File

@ -8,8 +8,8 @@ namespace N __attribute ((__visibility__ ("hidden")))
struct A { };
}
struct B
{ // { dg-warning "visibility" }
struct B // { dg-warning "visibility" }
{
N::A a;
};

View File

@ -14,8 +14,8 @@ void A::f() { }
// This gets a warning because B objects might rely
// on hidden symbols from A.
struct B
{ // { dg-warning "visibility" }
struct B // { dg-warning "visibility" }
{
A a;
};

View File

@ -1,8 +1,8 @@
// PR c++/26690
// { dg-do compile }
struct A
{ // { dg-message "A::A\\(const A&\\)" }
struct A // { dg-message "A::A\\(const A&\\)" }
{
A (int); // { dg-message "candidates" }
};

View File

@ -27,7 +27,7 @@ struct c4 : virtual c3, virtual c0, virtual c1
int m;
};
struct c6 : c0, c3, c4
{ // { dg-warning "direct base" "" }
struct c6 : c0, c3, c4 // { dg-warning "direct base" "" }
{
virtual c1 &f2() volatile;
};

View File

@ -5,8 +5,8 @@ struct G {
G(G&); // { dg-message "" "candidate" }
};
class A
{ // { dg-error "no match" }
class A // { dg-error "no match" }
{
const G g;
};

View File

@ -3,8 +3,8 @@ template <typename T, bool=T::X> struct A
int i;
};
template <typename T> struct B : A<T>
{ // { dg-error "incomplete" }
template <typename T> struct B : A<T> // { dg-error "incomplete" }
{
using A<T>::i; // { dg-error "incomplete" "incomplete" }
// { dg-error "using" "using" { target *-*-* } 8 }
};

View File

@ -14,8 +14,8 @@ struct a
int m;
a(const a&);
};
struct b
{ // { dg-error "cannot bind packed field" "" { target { ! default_packed } } }
struct b // { dg-error "cannot bind packed field" "" { target { ! default_packed } } }
{
char c;
a aa __attribute__((packed)); // { dg-warning "attribute ignored" "" { target default_packed } }
};

View File

@ -1,7 +1,7 @@
//PR c++/28258
struct A
{ // { dg-message "note" }
struct A // { dg-message "note" }
{
A(void x); // { dg-error "invalid use|incomplete type|candidates" }
};

View File

@ -1,8 +1,8 @@
// PR c++/34275
// { dg-do compile }
struct A
{ // { dg-message "candidate is" }
struct A // { dg-message "candidate is" }
{
virtual A foo ();
};

View File

@ -1,5 +1,5 @@
struct A
{ // { dg-error "forward declaration" }
struct A // { dg-error "forward declaration" }
{
A : A; // { dg-error "expected|incomplete" }
A : B; // { dg-error "not declared|incomplete" }
A : A(); // { dg-error "undefined type|incomplete" }

View File

@ -3,7 +3,7 @@
struct A
{
struct B {}; // { dg-error "12:previous definition of 'struct A::B'" }
struct B {}; // { dg-error "10:previous definition of 'struct A::B'" }
};
struct A::B{}; // { dg-error "11:redefinition of 'struct A::B'" }

View File

@ -1,8 +1,8 @@
// { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " }
// PR C++/17867
struct A
{ // { dg-message "1:candidate is:" }
struct A // { dg-message "8:candidate is:" }
{
A(int);
};

View File

@ -1,8 +1,8 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/20152
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "24:previous definition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "52:previous definition of 'struct KrKDESelectionMode'" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:previous definition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:previous definition of 'struct KrKDESelectionMode'" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:redefinition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:redefinition of 'struct KrKDESelectionMode'" }
KrKDESelectionMode krKDESelectionMode;

View File

@ -2,7 +2,7 @@
// PR c++/21908
struct virt { virt () {} virt (int i) {} };
struct der : public virtual virt { // { dg-message "34:der::der" }
struct der : public virtual virt { // { dg-message "8:der::der" }
der (int i) : virt(i) {} // { dg-message "3:candidates are: der" }
};
struct top : public der {

View File

@ -2,8 +2,8 @@
// Origin: Alexander Zvyagin <Alexander.Zviagine@cern.ch>
// { dg-do compile }
template <int N,typename T> struct A
{ // { dg-error "" }
template <int N,typename T> struct A // { dg-error "" }
{
typedef T X;
template <int M> void foo (const A<M,X>&);
};

View File

@ -15,8 +15,8 @@ template<class T> struct X
template<class T >
struct Derived
{
class Nested : public X<T>
{ // { dg-message "instantiated" "" }
class Nested : public X<T> // { dg-message "instantiated" "" }
{
};
Nested m; // { dg-message "instantiated" "" }

View File

@ -1,5 +1,5 @@
template <class T> struct PCVector2
{ // { dg-message "candidate is" }
template <class T> struct PCVector2 // { dg-message "candidate is" }
{
template <class T2> PCVector2(const PCVector2<T> &cv) ;
PCVector2<T> operator- (const PCVector2<T> &ov) const

View File

@ -12,8 +12,8 @@ template <template <class> class TT> struct X
TT<int> y;
};
template <class T> struct X<T::template B>
{ // { dg-error "previous" }
template <class T> struct X<T::template B> // { dg-error "previous" }
{
T z;
};

View File

@ -6,37 +6,37 @@
// destructor, in which case it would be possible but unsafe to delete
// an instance of a derived class through a pointer to the base class.
struct A
{ // { dg-bogus "non-virtual destructor" }
struct A // { dg-bogus "non-virtual destructor" }
{
protected:
~A();
public:
virtual void f() = 0;
};
struct B
{ // { dg-bogus "non-virtual destructor" }
struct B // { dg-bogus "non-virtual destructor" }
{
private:
~B();
public:
virtual void f() = 0;
};
struct C
{ // { dg-warning "non-virtual destructor" }
struct C // { dg-warning "non-virtual destructor" }
{
virtual void f() = 0;
};
struct D
{ // { dg-warning "non-virtual destructor" }
struct D // { dg-warning "non-virtual destructor" }
{
~D();
virtual void f() = 0;
};
struct E;
struct F
{ // { dg-warning "non-virtual destructor" }
struct F // { dg-warning "non-virtual destructor" }
{
protected:
friend class E;
~F();
@ -44,8 +44,8 @@ public:
virtual void f() = 0;
};
struct G
{ // { dg-warning "non-virtual destructor" }
struct G // { dg-warning "non-virtual destructor" }
{
private:
friend class E;
~G();

View File

@ -7,7 +7,7 @@
struct B { std::auto_ptr<A> p; };
#line 10 "foo.C"
struct C
{ // { dg-warning "uses the anonymous namespace" }
struct C // { dg-warning "uses the anonymous namespace" }
{
std::auto_ptr<A> p;
};

View File

@ -9,8 +9,8 @@ public:
~bahamian ();
};
class miami : public bahamian
{ // { dg-warning "" } // WARNING -
class miami : public bahamian // { dg-warning "" } // WARNING -
{
public:
miami ();
~miami ();

View File

@ -6,8 +6,8 @@ union Value
Value(){}
};
struct GlobalAddress
{// { dg-message "note" }
struct GlobalAddress // { dg-message "note" }
{
GlobalAddress(Value *nvar){} // { dg-message "candidates" }
};

View File

@ -122,8 +122,8 @@ struct B1 : A
{
};
struct C : A, A1
{ // { dg-error "" } looser throw - A::~A()
struct C : A, A1 // { dg-error "" } looser throw - A::~A()
{
virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo
virtual void bar() throw(int); // { dg-error "" } looser throw - A1::bar
};

View File

@ -2,8 +2,8 @@
// Bug: g++ tries to generate initialization semantics for a Node from an int,
// and fails.
struct Node
{ // { dg-message "note" }
struct Node // { dg-message "note" }
{
Node* child[2];
};

View File

@ -10,8 +10,8 @@ struct X
struct Y : public X
{};
struct Z : public Y, public X
{}; // { dg-warning "" }
struct Z : public Y, public X // { dg-warning "" }
{};
void foo ()
{

View File

@ -5,8 +5,8 @@
// Subject: bug in handling static const object of the enclosing class
// Date: Tue, 1 Sep 92 10:38:44 EDT
class X
{ // { dg-message "1:X::X\\(const X&\\)" } implicit constructor
class X // { dg-message "7:X::X\\(const X&\\)" } implicit constructor
{
private:
int x;
public:

View File

@ -20,8 +20,8 @@ Foo::Foo(int aa)
{ }
struct var_Foo: public Foo
{ // { dg-message "note" } base.*// ERROR - in class.*
struct var_Foo: public Foo // { dg-message "note" } base.*// ERROR - in class.*
{
var_Foo* operator-> () {return this;}
};

View File

@ -24,8 +24,8 @@ const ccObjectInfo& ccHandle<T>::repInvariant (int)
class ccHandleBase : public ccObjectInfo
{};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{ // { dg-warning "" }
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo // { dg-warning "" }
{
public:
virtual const ccObjectInfo& ri (int);
};

View File

@ -26,8 +26,8 @@ const ccObjectInfo& ccHandle<T>::repInvariant (int)
class ccHandleBase : public ccObjectInfo
{};
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo
{ // { dg-warning "" }
class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo // { dg-warning "" }
{
public:
virtual const ccObjectInfo& repInvariant (int);
};

View File

@ -6,36 +6,36 @@
// Duplicate definitions are wrong, we should just cough
// politely, but we used to die horribly.
class Y
{ // { dg-error "" } previous definition
class Y // { dg-error "" } previous definition
{
};
class Y // { dg-error "" } redefinition
{
};
template<class T> class X
{ // { dg-error "" } previous definition
template<class T> class X // { dg-error "" } previous definition
{
};
template<class T> class X // { dg-error "" } redefinition
{
};
template<class T> class X<T *>
{ // { dg-error "" } previous definition
template<class T> class X<T *> // { dg-error "" } previous definition
{
};
template<class T> class X<T *> // { dg-error "" } redefinition
{
};
template<> class X<int>
{ // { dg-error "" } previous definition
template<> class X<int> // { dg-error "" } previous definition
{
};
template<> class X<int> // { dg-error "" } redefinition
{
};
template<> class X<int *>
{ // { dg-error "" } previous definition
template<> class X<int *> // { dg-error "" } previous definition
{
};
template<> class X<int *> // { dg-error "" } redefinition
{

View File

@ -2,9 +2,8 @@
// Test that failed lvalue-to-rvalue conversion of vf doesn't crash the
// compiler.
class f_class
{ }; // { dg-message "candidates" "candidates" }
// { dg-message "note" "note" { target *-*-* } 6 }
class f_class // { dg-message "note" "candidates" }
{ };
volatile f_class
ret_v_f_class()

View File

@ -13,8 +13,8 @@ struct iterator {
template <class Iterator>
struct reverse_iterator : public
iterator<typename iterator_traits<Iterator>::iterator_category> { // { dg-message "instantiated" } no type iterator_category
struct reverse_iterator : public // { dg-message "instantiated" } no type iterator_category
iterator<typename iterator_traits<Iterator>::iterator_category> {
protected:
Iterator current;

View File

@ -5,8 +5,8 @@
template<class T>
class X {
class Y : public T
{ // { dg-error "base type .* fails to be" }
class Y : public T // { dg-error "base type .* fails to be" }
{
};
Y y; // { dg-message "instantiated" }
};

View File

@ -19,8 +19,8 @@ inline istream& operator>>(istream& is, Empty& ) { return is;}
template<class VertexType, class EdgeType>
class Graph
{ // { dg-message "note" } candidates
class Graph // { dg-message "note" } candidates
{
public:
// public type interface
typedef std::map<int, EdgeType > Successor;

View File

@ -16,8 +16,8 @@ public:
int i;
};
class some_derived : public some_base
{ // { dg-message "note" }
class some_derived : public some_base // { dg-message "note" }
{
public:
class derived_func_args;
void func(derived_func_args &);

View File

@ -33,6 +33,6 @@ int main()
}
// { dg-error "deleted function" "" { target *-*-* } 72 }
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "first required here" "" { target *-*-* } 30 }
// { dg-excess-errors "copy constructor" }

View File

@ -32,7 +32,7 @@ void test02()
test_base io1;
test_base io2 = io1;
}
// { dg-error "within this context" "" { target *-*-* } 27 }
// { dg-error "within this context" "" { target *-*-* } 26 }
// { dg-error "synthesized" "" { target *-*-* } 33 }
// { dg-error "is private" "" { target *-*-* } 785 }
// { dg-error "copy constructor" "" { target *-*-* } 0 }

View File

@ -36,4 +36,4 @@ int main()
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
// { dg-error "declaration of" "" { target *-*-* } 62 }
// { dg-error "declaration of" "" { target *-*-* } 61 }

View File

@ -36,4 +36,4 @@ int main()
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
// { dg-error "declaration of" "" { target *-*-* } 105 }
// { dg-error "declaration of" "" { target *-*-* } 104 }