Commit b872d729 by Paolo Carlini Committed by Paolo Carlini

decl.c (xref_tag_1): Change pairs of errors to error + inform.

/cp
2016-06-02  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (xref_tag_1): Change pairs of errors to error + inform.
	(start_enum): Likewise.
	* parser.c (cp_parser_class_head): Likewise.

/testsuite
2016-06-02  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/forw_enum10.C: Adjust for dg-message vs dg-error.
	* g++.dg/cpp0x/forw_enum6.C: Likewise.
	* g++.dg/cpp0x/forw_enum8.C: Likewise.
	* g++.dg/cpp0x/override2.C: Likewise.
	* g++.dg/parse/crash5.C: Likewise.
	* g++.dg/parse/error16.C: Likewise.
	* g++.dg/parse/error27.C: Likewise.
	* g++.dg/template/qualttp15.C: Likewise.
	* g++.dg/template/redecl4.C: Likewise.
	* g++.old-deja/g++.other/crash39.C: Likewise.
	* g++.old-deja/g++.other/struct1.C: Likewise.
	* g++.old-deja/g++.pt/m9a.C: Likewise.
	* g++.old-deja/g++.pt/memclass10.C: Likewise.

From-SVN: r237046
parent e29525d3
2016-06-02 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (xref_tag_1): Change pairs of errors to error + inform.
(start_enum): Likewise.
* parser.c (cp_parser_class_head): Likewise.
2016-06-02 Jakub Jelinek <jakub@redhat.com> 2016-06-02 Jakub Jelinek <jakub@redhat.com>
PR c++/71372 PR c++/71372
......
...@@ -12793,7 +12793,7 @@ xref_tag_1 (enum tag_types tag_code, tree name, ...@@ -12793,7 +12793,7 @@ xref_tag_1 (enum tag_types tag_code, tree name,
&& CLASSTYPE_IS_TEMPLATE (t)) && CLASSTYPE_IS_TEMPLATE (t))
{ {
error ("redeclaration of %qT as a non-template", t); error ("redeclaration of %qT as a non-template", t);
error ("previous declaration %q+D", t); inform (location_of (t), "previous declaration %qD", t);
return error_mark_node; return error_mark_node;
} }
...@@ -13149,16 +13149,16 @@ start_enum (tree name, tree enumtype, tree underlying_type, ...@@ -13149,16 +13149,16 @@ start_enum (tree name, tree enumtype, tree underlying_type,
{ {
error_at (input_location, "scoped/unscoped mismatch " error_at (input_location, "scoped/unscoped mismatch "
"in enum %q#T", enumtype); "in enum %q#T", enumtype);
error_at (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)), inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
"previous definition here"); "previous definition here");
enumtype = error_mark_node; enumtype = error_mark_node;
} }
else if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) != !! underlying_type) else if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) != !! underlying_type)
{ {
error_at (input_location, "underlying type mismatch " error_at (input_location, "underlying type mismatch "
"in enum %q#T", enumtype); "in enum %q#T", enumtype);
error_at (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)), inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
"previous definition here"); "previous definition here");
enumtype = error_mark_node; enumtype = error_mark_node;
} }
else if (underlying_type && ENUM_UNDERLYING_TYPE (enumtype) else if (underlying_type && ENUM_UNDERLYING_TYPE (enumtype)
...@@ -13169,8 +13169,8 @@ start_enum (tree name, tree enumtype, tree underlying_type, ...@@ -13169,8 +13169,8 @@ start_enum (tree name, tree enumtype, tree underlying_type,
{ {
error_at (input_location, "different underlying type " error_at (input_location, "different underlying type "
"in enum %q#T", enumtype); "in enum %q#T", enumtype);
error_at (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)), inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
"previous definition here"); "previous definition here");
underlying_type = NULL_TREE; underlying_type = NULL_TREE;
} }
} }
......
...@@ -22008,8 +22008,8 @@ cp_parser_class_head (cp_parser* parser, ...@@ -22008,8 +22008,8 @@ cp_parser_class_head (cp_parser* parser,
{ {
error_at (type_start_token->location, "redefinition of %q#T", error_at (type_start_token->location, "redefinition of %q#T",
type); type);
error_at (type_start_token->location, "previous definition of %q+#T", inform (location_of (type), "previous definition of %q#T",
type); type);
type = NULL_TREE; type = NULL_TREE;
goto done; goto done;
} }
2016-06-02 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/forw_enum10.C: Adjust for dg-message vs dg-error.
* g++.dg/cpp0x/forw_enum6.C: Likewise.
* g++.dg/cpp0x/forw_enum8.C: Likewise.
* g++.dg/cpp0x/override2.C: Likewise.
* g++.dg/parse/crash5.C: Likewise.
* g++.dg/parse/error16.C: Likewise.
* g++.dg/parse/error27.C: Likewise.
* g++.dg/template/qualttp15.C: Likewise.
* g++.dg/template/redecl4.C: Likewise.
* g++.old-deja/g++.other/crash39.C: Likewise.
* g++.old-deja/g++.other/struct1.C: Likewise.
* g++.old-deja/g++.pt/m9a.C: Likewise.
* g++.old-deja/g++.pt/memclass10.C: Likewise.
2016-06-02 Jakub Jelinek <jakub@redhat.com> 2016-06-02 Jakub Jelinek <jakub@redhat.com>
PR c++/71372 PR c++/71372
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
//This error is diagnosed at instantiation time //This error is diagnosed at instantiation time
template<typename T> struct S1 template<typename T> struct S1
{ {
enum E : T; // { dg-error "previous definition" } enum E : T; // { dg-message "previous definition" }
enum E : int; // { dg-error "different underlying type" } enum E : int; // { dg-error "different underlying type" }
}; };
template struct S1<short>; // { dg-message "required from here" } template struct S1<short>; // { dg-message "required from here" }
...@@ -24,7 +24,7 @@ template struct S3<short,short>; ...@@ -24,7 +24,7 @@ template struct S3<short,short>;
template<typename T1, typename T2> struct S4 template<typename T1, typename T2> struct S4
{ {
enum E : T1; // { dg-error "previous definition" } enum E : T1; // { dg-message "previous definition" }
enum E : T2; // { dg-error "different underlying type" } enum E : T2; // { dg-error "different underlying type" }
}; };
template struct S4<short,char>; // { dg-message "required from here" } template struct S4<short,char>; // { dg-message "required from here" }
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
enum class E1 : int; // { dg-error "previous definition" } enum class E1 : int; // { dg-message "previous definition" }
enum E1 : int; // { dg-error "scoped/unscoped mismatch" } enum E1 : int; // { dg-error "scoped/unscoped mismatch" }
enum E2 : int; // { dg-error "previous definition" } enum E2 : int; // { dg-message "previous definition" }
enum class E2 : int; // { dg-error "scoped/unscoped mismatch" } enum class E2 : int; // { dg-error "scoped/unscoped mismatch" }
enum struct E3 : int; enum struct E3 : int;
enum class E3 : int; //ok enum class E3 : int; //ok
enum class E4 : int; // { dg-error "previous definition" } enum class E4 : int; // { dg-message "previous definition" }
enum class E4 : long; // { dg-error "different underlying type" } enum class E4 : long; // { dg-error "different underlying type" }
enum E5 : int; // { dg-error "previous definition" } enum E5 : int; // { dg-message "previous definition" }
enum E5 : long; // { dg-error "different underlying type" } enum E5 : long; // { dg-error "different underlying type" }
enum E6 : int; enum E6 : int;
......
...@@ -11,7 +11,7 @@ template struct S1<int>; //ok ...@@ -11,7 +11,7 @@ template struct S1<int>; //ok
//This error is diagnosed at instantiation time //This error is diagnosed at instantiation time
template<typename T> struct S2 template<typename T> struct S2
{ {
enum E : int; // { dg-error "previous definition" } enum E : int; // { dg-message "previous definition" }
enum E : T; // { dg-error "different underlying type" } enum E : T; // { dg-error "different underlying type" }
}; };
template struct S2<short>; // { dg-message "required from here" } template struct S2<short>; // { dg-message "required from here" }
...@@ -19,7 +19,7 @@ template struct S2<short>; // { dg-message "required from here" } ...@@ -19,7 +19,7 @@ template struct S2<short>; // { dg-message "required from here" }
//This error is diagnosed at compilation time //This error is diagnosed at compilation time
template<typename T> struct S3 template<typename T> struct S3
{ {
enum E : int; // { dg-error "previous definition" } enum E : int; // { dg-message "previous definition" }
enum E : short; // { dg-error "different underlying type" } enum E : short; // { dg-error "different underlying type" }
}; };
...@@ -38,7 +38,7 @@ int main() ...@@ -38,7 +38,7 @@ int main()
{ {
D3<B1> d; D3<B1> d;
D4<B2> d2; D4<B2> d2;
struct B2 final{}; // { dg-error "previous definition" } struct B2 final{}; // { dg-message "previous definition" }
B2 final; // { dg-error "has a previous declaration|previously declared here" } B2 final; // { dg-error "has a previous declaration|previously declared here" }
B2 final2 = final; B2 final2 = final;
struct B2 {}; // { dg-error "redefinition" } struct B2 {}; // { dg-error "redefinition" }
...@@ -47,7 +47,7 @@ int main() ...@@ -47,7 +47,7 @@ int main()
struct B2 final {}; // { dg-error "redefinition" } struct B2 final {}; // { dg-error "redefinition" }
struct B2 override {}; // { dg-error "cannot specify 'override' for a class" } struct B2 override {}; // { dg-error "cannot specify 'override' for a class" }
B2 override{}; // { dg-error "redeclaration" } B2 override{}; // { dg-error "redeclaration" }
struct foo final {}; // { dg-error "previous definition" } struct foo final {}; // { dg-message "previous definition" }
struct foo final {}; // { dg-error "redefinition" } struct foo final {}; // { dg-error "redefinition" }
foo final; // { dg-error "conflicting declaration" } foo final; // { dg-error "conflicting declaration" }
} }
// { dg-options "-w" } // { dg-options "-w" }
class QString { // { dg-error "previous definition" } class QString { // { dg-message "previous definition" }
QString (const QString & a); // { dg-message "QString::QString|candidate expects" } QString (const QString & a); // { dg-message "QString::QString|candidate expects" }
}; };
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct A struct A
{ {
struct B {}; // { dg-error "10:previous definition of 'struct A::B'" } struct B {}; // { dg-message "10:previous definition of 'struct A::B'" }
}; };
struct A::B{}; // { dg-error "11:redefinition of 'struct A::B'" } struct A::B{}; // { dg-error "11:redefinition of 'struct A::B'" }
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" } // { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/20152 // PR c++/20152
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:previous definition of 'struct KrSelectionMode'" } struct KrSelectionMode { virtual void init() = 0; }; // { dg-message "8:previous definition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:previous definition of 'struct KrKDESelectionMode'" } struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-message "8:previous definition of 'struct KrKDESelectionMode'" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:redefinition of 'struct KrSelectionMode'" } 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'" } struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:redefinition of 'struct KrKDESelectionMode'" }
KrKDESelectionMode krKDESelectionMode; KrKDESelectionMode krKDESelectionMode;
...@@ -12,7 +12,7 @@ template <template <class> class TT> struct X ...@@ -12,7 +12,7 @@ template <template <class> class TT> struct X
TT<int> y; TT<int> y;
}; };
template <class T> struct X<T::template B> // { dg-error "previous" } template <class T> struct X<T::template B> // { dg-message "previous" }
{ {
T z; T z;
}; };
......
// PR c++/28710 // PR c++/28710
// { dg-do compile } // { dg-do compile }
template<int> union A; // { dg-error "previous" } template<int> union A; // { dg-message "previous" }
struct A; // { dg-error "non-template" } struct A; // { dg-error "non-template" }
...@@ -10,7 +10,7 @@ struct X ...@@ -10,7 +10,7 @@ struct X
{ {
~X (); ~X ();
}; };
struct S { X a; }; // { dg-error "" } previous defn struct S { X a; }; // { dg-message "" } previous defn
struct S { X a; }; // { dg-error "" } redefinition struct S { X a; }; // { dg-error "" } redefinition
void c1(S s) void c1(S s)
......
...@@ -6,35 +6,35 @@ ...@@ -6,35 +6,35 @@
// Duplicate definitions are wrong, we should just cough // Duplicate definitions are wrong, we should just cough
// politely, but we used to die horribly. // politely, but we used to die horribly.
class Y // { dg-error "" } previous definition class Y // { dg-message "" } previous definition
{ {
}; };
class Y // { dg-error "" } redefinition class Y // { dg-error "" } redefinition
{ {
}; };
template<class T> class X // { dg-error "" } previous definition template<class T> class X // { dg-message "" } previous definition
{ {
}; };
template<class T> class X // { dg-error "" } redefinition 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-message "" } previous definition
{ {
}; };
template<class T> class X<T *> // { dg-error "" } redefinition template<class T> class X<T *> // { dg-error "" } redefinition
{ {
}; };
template<> class X<int> // { dg-error "" } previous definition template<> class X<int> // { dg-message "" } previous definition
{ {
}; };
template<> class X<int> // { dg-error "" } redefinition template<> class X<int> // { dg-error "" } redefinition
{ {
}; };
template<> class X<int *> // { dg-error "" } previous definition template<> class X<int *> // { dg-message "" } previous definition
{ {
}; };
template<> class X<int *> // { dg-error "" } redefinition template<> class X<int *> // { dg-error "" } redefinition
......
// { dg-do assemble } // { dg-do assemble }
struct A { A() { a = 1; } int a; }; // { dg-error "" } struct A { A() { a = 1; } int a; }; // { dg-message "" }
struct A { A() { a = 2; } int a; }; // { dg-error "" } struct A { A() { a = 2; } int a; }; // { dg-error "" }
A aavv; A aavv;
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct S1 struct S1
{ {
template <class T> template <class T>
struct S2 {}; // { dg-error "" } previous definition struct S2 {}; // { dg-message "" } previous definition
template <class T> template <class T>
struct S2 {}; // { dg-error "" } redefinition struct S2 {}; // { dg-error "" } redefinition
......
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