+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
end_specialization ();
--parser->num_template_parameter_lists;
}
+
+ if (type)
+ DECL_SOURCE_LOCATION (TYPE_NAME (type)) = type_start_token->location;
*attributes_p = attributes;
return type;
}
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));
+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
// { 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);
}
// 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();
/* { 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;
/* { 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;
struct A { };
}
-struct B
-{ // { dg-warning "visibility" }
+struct B // { dg-warning "visibility" }
+{
N::A a;
};
// 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;
};
// 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" }
};
int m;
};
-struct c6 : c0, c3, c4
-{ // { dg-warning "direct base" "" }
+struct c6 : c0, c3, c4 // { dg-warning "direct base" "" }
+{
virtual c1 &f2() volatile;
};
G(G&); // { dg-message "" "candidate" }
};
-class A
-{ // { dg-error "no match" }
+class A // { dg-error "no match" }
+{
const G g;
};
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 }
};
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 } }
};
//PR c++/28258
-struct A
-{ // { dg-message "note" }
+struct A // { dg-message "note" }
+{
A(void x); // { dg-error "invalid use|incomplete type|candidates" }
};
// PR c++/34275
// { dg-do compile }
-struct A
-{ // { dg-message "candidate is" }
+struct A // { dg-message "candidate is" }
+{
virtual A foo ();
};
-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" }
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'" }
// { 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);
};
// { 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;
// 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 {
// 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>&);
};
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" "" }
-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
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;
};
// 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();
virtual void f() = 0;
};
-struct G
-{ // { dg-warning "non-virtual destructor" }
+struct G // { dg-warning "non-virtual destructor" }
+{
private:
friend class E;
~G();
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;
};
~bahamian ();
};
-class miami : public bahamian
-{ // { dg-warning "" } // WARNING -
+class miami : public bahamian // { dg-warning "" } // WARNING -
+{
public:
miami ();
~miami ();
Value(){}
};
-struct GlobalAddress
-{// { dg-message "note" }
+struct GlobalAddress // { dg-message "note" }
+{
GlobalAddress(Value *nvar){} // { dg-message "candidates" }
};
{
};
-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
};
// 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];
};
struct Y : public X
{};
-struct Z : public Y, public X
-{}; // { dg-warning "" }
+struct Z : public Y, public X // { dg-warning "" }
+{};
void foo ()
{
// 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:
{ }
-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;}
};
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);
};
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);
};
// 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
{
// 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()
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;
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" }
};
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;
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 &);
}
// { 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" }
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 }
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
-// { dg-error "declaration of" "" { target *-*-* } 62 }
+// { dg-error "declaration of" "" { target *-*-* } 61 }
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
-// { dg-error "declaration of" "" { target *-*-* } 105 }
+// { dg-error "declaration of" "" { target *-*-* } 104 }