Commit 4753e009 by Paolo Carlini Committed by Paolo Carlini

decl.c (check_tag_decl): Use declspecs->locations as locations in error_at and warning_at calls.

/cp
2015-06-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (check_tag_decl): Use declspecs->locations as locations in
	error_at and warning_at calls.

/testsuite
2015-06-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/decl-loc1.C: New.
	* g++.dg/cpp0x/constexpr-neg1.C: Adjust.
	* g++.dg/cpp0x/constexpr-object1.C: Likewise.
	* g++.dg/init/ctor8.C: Likewise.
	* g++.dg/parse/semicolon4.C: Likewise.

From-SVN: r224097
parent 7b3a9795
2015-06-03 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (check_tag_decl): Use declspecs->locations as locations in
error_at and warning_at calls.
2015-06-03 Marek Polacek <polacek@redhat.com> 2015-06-03 Marek Polacek <polacek@redhat.com>
PR sanitizer/66190 PR sanitizer/66190
......
...@@ -4488,30 +4488,46 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, ...@@ -4488,30 +4488,46 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
else else
{ {
if (decl_spec_seq_has_spec_p (declspecs, ds_inline) if (decl_spec_seq_has_spec_p (declspecs, ds_inline))
|| decl_spec_seq_has_spec_p (declspecs, ds_virtual)) error_at (declspecs->locations[ds_inline],
error ("%qs can only be specified for functions", "%<inline%> can only be specified for functions");
decl_spec_seq_has_spec_p (declspecs, ds_inline) else if (decl_spec_seq_has_spec_p (declspecs, ds_virtual))
? "inline" : "virtual"); error_at (declspecs->locations[ds_virtual],
"%<virtual%> can only be specified for functions");
else if (saw_friend else if (saw_friend
&& (!current_class_type && (!current_class_type
|| current_scope () != current_class_type)) || current_scope () != current_class_type))
error ("%<friend%> can only be specified inside a class"); error_at (declspecs->locations[ds_friend],
"%<friend%> can only be specified inside a class");
else if (decl_spec_seq_has_spec_p (declspecs, ds_explicit)) else if (decl_spec_seq_has_spec_p (declspecs, ds_explicit))
error ("%<explicit%> can only be specified for constructors"); error_at (declspecs->locations[ds_explicit],
"%<explicit%> can only be specified for constructors");
else if (declspecs->storage_class) else if (declspecs->storage_class)
error ("a storage class can only be specified for objects " error_at (declspecs->locations[ds_storage_class],
"and functions"); "a storage class can only be specified for objects "
else if (decl_spec_seq_has_spec_p (declspecs, ds_const) "and functions");
|| decl_spec_seq_has_spec_p (declspecs, ds_volatile) else if (decl_spec_seq_has_spec_p (declspecs, ds_const))
|| decl_spec_seq_has_spec_p (declspecs, ds_restrict) error_at (declspecs->locations[ds_const],
|| decl_spec_seq_has_spec_p (declspecs, ds_thread)) "%<const%> can only be specified for objects and "
error ("qualifiers can only be specified for objects " "functions");
"and functions"); else if (decl_spec_seq_has_spec_p (declspecs, ds_volatile))
error_at (declspecs->locations[ds_volatile],
"%<volatile%> can only be specified for objects and "
"functions");
else if (decl_spec_seq_has_spec_p (declspecs, ds_restrict))
error_at (declspecs->locations[ds_restrict],
"%<__restrict%> can only be specified for objects and "
"functions");
else if (decl_spec_seq_has_spec_p (declspecs, ds_thread))
error_at (declspecs->locations[ds_thread],
"%<__thread%> can only be specified for objects "
"and functions");
else if (saw_typedef) else if (saw_typedef)
warning (0, "%<typedef%> was ignored in this declaration"); warning_at (declspecs->locations[ds_typedef], 0,
"%<typedef%> was ignored in this declaration");
else if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr)) else if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr))
error ("%<constexpr%> cannot be used for type declarations"); error_at (declspecs->locations[ds_constexpr],
"%<constexpr%> cannot be used for type declarations");
} }
if (declspecs->attributes && warn_attributes && declared_type) if (declspecs->attributes && warn_attributes && declared_type)
......
2015-06-03 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/decl-loc1.C: New.
* g++.dg/cpp0x/constexpr-neg1.C: Adjust.
* g++.dg/cpp0x/constexpr-object1.C: Likewise.
* g++.dg/init/ctor8.C: Likewise.
* g++.dg/parse/semicolon4.C: Likewise.
2015-06-03 Marek Polacek <polacek@redhat.com> 2015-06-03 Marek Polacek <polacek@redhat.com>
PR sanitizer/66190 PR sanitizer/66190
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
constexpr int square(int x); // { dg-message "never defined" } constexpr int square(int x); // { dg-message "never defined" }
// error: pixel is a type // error: pixel is a type
constexpr struct pixel { constexpr struct pixel { // { dg-error "constexpr" }
int x; int x;
int y; int y;
// OK: declaration // OK: declaration
constexpr pixel(int); constexpr pixel(int);
}; // { dg-error "constexpr" } };
constexpr pixel::pixel(int a) constexpr pixel::pixel(int a)
// OK: definition // OK: definition
: x(square(a)), y(square(a)) // { dg-error "square" } : x(square(a)), y(square(a)) // { dg-error "square" }
......
...@@ -22,8 +22,8 @@ const constexpr A1 a3 = A1(); ...@@ -22,8 +22,8 @@ const constexpr A1 a3 = A1();
volatile constexpr A1 a4 = A1(); // { dg-bogus "both .volatile. and .constexpr. cannot" } volatile constexpr A1 a4 = A1(); // { dg-bogus "both .volatile. and .constexpr. cannot" }
// error: on type declaration // error: on type declaration
constexpr struct pixel constexpr struct pixel // { dg-error "cannot be used for type declarations" }
{ {
int x; int x;
int y; int y;
}; // { dg-error "cannot be used for type declarations" } };
// { dg-do compile { target c++11 } }
inline struct A; // { dg-error "1:'inline'" }
virtual struct B; // { dg-error "1:'virtual'" }
friend struct C; // { dg-error "1:'friend'" }
explicit struct D; // { dg-error "1:'explicit'" }
mutable struct E; // { dg-error "1:a storage class" }
const struct F; // { dg-error "1:'const'" }
volatile struct G; // { dg-error "1:'volatile'" }
__restrict struct H; // { dg-error "1:'__restrict'" }
__thread struct I; // { dg-error "1:'__thread'" }
typedef struct J; // { dg-warning "1:'typedef'" }
constexpr struct K; // { dg-error "1:'constexpr'" }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
typedef struct S { // { dg-error "reference" "" { target c++11 } } typedef struct S { // { dg-error "reference" "" { target c++11 } }
int &r; int &r;
}; // { dg-warning "'typedef' was ignored" } }; // { dg-warning "1:'typedef' was ignored" "" { target *-*-* } 3 }
S f () { S f () {
......
...@@ -22,7 +22,7 @@ struct OK3 ...@@ -22,7 +22,7 @@ struct OK3
struct E1 struct E1
{ {
int i; int i;
} const; // { dg-error "qualifiers can only be specified for objects and functions" } } const; // { dg-error "'const' can only be specified for objects and functions" }
void foo ( void foo (
struct E2 struct E2
......
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