aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2015-06-03 17:08:39 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2015-06-03 17:08:39 +0000
commit4753e009664aa5d4cdf0ce86a03224f5bc1f9d7b (patch)
treec70bd393f3d77030375d7cc62d8dc9913e9116a8 /gcc/cp
parent7b3a9795438b33a0137b47f422a9542c5e2d7ccc (diff)
downloadgcc-4753e009664aa5d4cdf0ce86a03224f5bc1f9d7b.zip
gcc-4753e009664aa5d4cdf0ce86a03224f5bc1f9d7b.tar.gz
gcc-4753e009664aa5d4cdf0ce86a03224f5bc1f9d7b.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c50
2 files changed, 38 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4ab191..2c61d55 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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>
PR sanitizer/66190
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6140ab6..9d20b94 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4488,30 +4488,46 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
else
{
- if (decl_spec_seq_has_spec_p (declspecs, ds_inline)
- || decl_spec_seq_has_spec_p (declspecs, ds_virtual))
- error ("%qs can only be specified for functions",
- decl_spec_seq_has_spec_p (declspecs, ds_inline)
- ? "inline" : "virtual");
+ if (decl_spec_seq_has_spec_p (declspecs, ds_inline))
+ error_at (declspecs->locations[ds_inline],
+ "%<inline%> can only be specified for functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_virtual))
+ error_at (declspecs->locations[ds_virtual],
+ "%<virtual%> can only be specified for functions");
else if (saw_friend
&& (!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))
- 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)
- error ("a storage class can only be specified for objects "
- "and functions");
- else if (decl_spec_seq_has_spec_p (declspecs, ds_const)
- || decl_spec_seq_has_spec_p (declspecs, ds_volatile)
- || decl_spec_seq_has_spec_p (declspecs, ds_restrict)
- || decl_spec_seq_has_spec_p (declspecs, ds_thread))
- error ("qualifiers can only be specified for objects "
- "and functions");
+ error_at (declspecs->locations[ds_storage_class],
+ "a storage class can only be specified for objects "
+ "and functions");
+ else if (decl_spec_seq_has_spec_p (declspecs, ds_const))
+ error_at (declspecs->locations[ds_const],
+ "%<const%> can only be specified for objects 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)
- 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))
- 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)