aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-01-16 16:16:54 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-01-16 16:16:54 +0000
commit59ec4914775d554368879fd1d67b416daf9406d4 (patch)
tree1d9d4e2d4eb41935df02b412718cc62e7355e86e /gcc/cp
parent2ea2a74dceda4b4ddf7433f2c1d9ab72aa2bd0b0 (diff)
downloadgcc-59ec4914775d554368879fd1d67b416daf9406d4.zip
gcc-59ec4914775d554368879fd1d67b416daf9406d4.tar.gz
gcc-59ec4914775d554368879fd1d67b416daf9406d4.tar.bz2
decl.c (grokdeclarator): Use locations[ds_storage_class] in error messages about ill-formed uses of mutable.
/cp 2019-01-16 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Use locations[ds_storage_class] in error messages about ill-formed uses of mutable. /testsuite 2019-01-16 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/other/pr33558.C: Test location too. * g++.dg/other/pr33558-2.C: Likewise. * g++.dg/parse/crash4.C: Likewise. * g++.old-deja/g++.brendan/err-msg11.C: Likewise. * g++.old-deja/g++.mike/p7635.C: Likewise. * g++.old-deja/g++.other/decl6.C: Likewise. From-SVN: r267978
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c21
2 files changed, 19 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6adb0e4..50f00f2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-16 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grokdeclarator): Use locations[ds_storage_class] in
+ error messages about ill-formed uses of mutable.
+
2019-01-16 Marek Polacek <polacek@redhat.com>
PR c++/78244 - narrowing conversion in template not detected.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8e1d12d..9f96ebc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11902,36 +11902,43 @@ grokdeclarator (const cp_declarator *declarator,
if (storage_class == sc_mutable)
{
+ location_t sloc = declspecs->locations[ds_storage_class];
if (decl_context != FIELD || friendp)
{
- error ("non-member %qs cannot be declared %<mutable%>", name);
+ error_at (sloc, "non-member %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
else if (decl_context == TYPENAME || typedef_p)
{
- error ("non-object member %qs cannot be declared %<mutable%>", name);
+ error_at (sloc,
+ "non-object member %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
else if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
{
- error ("function %qs cannot be declared %<mutable%>", name);
+ error_at (sloc, "function %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
else if (staticp)
{
- error ("static %qs cannot be declared %<mutable%>", name);
+ error_at (sloc, "%<static%> %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
else if (type_quals & TYPE_QUAL_CONST)
{
- error ("const %qs cannot be declared %<mutable%>", name);
+ error_at (sloc, "%<const%> %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
else if (TYPE_REF_P (type))
{
- permerror (input_location, "reference %qs cannot be declared "
- "%<mutable%>", name);
+ permerror (sloc, "reference %qs cannot be declared %<mutable%>",
+ name);
storage_class = sc_none;
}
}