aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-01-17 18:01:43 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-01-17 18:01:43 +0000
commit742b6dc476c544389f109b03d221262a4cc55aaf (patch)
tree8a9bf793a3e4ef87b404584cbf910e7a4dead16d /gcc/cp/decl.c
parentb9e03679808ef26ba9614d352f69a347df120265 (diff)
downloadgcc-742b6dc476c544389f109b03d221262a4cc55aaf.zip
gcc-742b6dc476c544389f109b03d221262a4cc55aaf.tar.gz
gcc-742b6dc476c544389f109b03d221262a4cc55aaf.tar.bz2
decl.c (grokdeclarator): Use typespec_loc in error messages about 'auto' and trailing return type.
/cp 2019-01-17 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Use typespec_loc in error messages about 'auto' and trailing return type. /testsuite 2019-01-17 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/auto52.C: Test locations too. * g++.dg/cpp0x/trailing2.C: Likewise. * g++.dg/cpp1y/auto-fn18.C: Likewise. * g++.dg/cpp1y/auto-fn25.C: Likewise. * g++.dg/cpp1y/auto-fn52.C: Likewise. * g++.dg/cpp1y/auto-fn53.C: Likewise. * g++.dg/cpp1y/auto-fn54.C: Likewise. From-SVN: r268043
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9f96ebc..79eeac1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11287,35 +11287,37 @@ grokdeclarator (const cp_declarator *declarator,
/* OK for C++11 lambdas. */;
else if (cxx_dialect < cxx14)
{
- error ("%qs function uses "
- "%<auto%> type specifier without trailing "
- "return type", name);
- inform (input_location, "deduced return type "
- "only available with -std=c++14 or "
- "-std=gnu++14");
+ error_at (typespec_loc, "%qs function uses "
+ "%<auto%> type specifier without "
+ "trailing return type", name);
+ inform (typespec_loc,
+ "deduced return type only available "
+ "with -std=c++14 or -std=gnu++14");
}
else if (virtualp)
{
- error ("virtual function cannot "
- "have deduced return type");
+ error_at (typespec_loc, "virtual function "
+ "cannot have deduced return type");
virtualp = false;
}
}
else if (!is_auto (type) && sfk != sfk_conversion)
{
- error ("%qs function with trailing return type has"
- " %qT as its type rather than plain %<auto%>",
- name, type);
+ error_at (typespec_loc, "%qs function with trailing "
+ "return type has %qT as its type rather "
+ "than plain %<auto%>", name, type);
return error_mark_node;
}
else if (is_auto (type) && AUTO_IS_DECLTYPE (type))
{
if (funcdecl_p)
- error ("%qs function with trailing return type has "
- "%<decltype(auto)%> as its type rather than "
- "plain %<auto%>", name);
+ error_at (typespec_loc,
+ "%qs function with trailing return type "
+ "has %<decltype(auto)%> as its type "
+ "rather than plain %<auto%>", name);
else
- error ("invalid use of %<decltype(auto)%>");
+ error_at (typespec_loc,
+ "invalid use of %<decltype(auto)%>");
return error_mark_node;
}
tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node);
@@ -11359,11 +11361,13 @@ grokdeclarator (const cp_declarator *declarator,
if (cxx_dialect < cxx11)
/* Not using maybe_warn_cpp0x because this should
always be an error. */
- error ("trailing return type only available with "
- "-std=c++11 or -std=gnu++11");
+ error_at (typespec_loc,
+ "trailing return type only available "
+ "with -std=c++11 or -std=gnu++11");
else
- error ("%qs function with trailing return type not "
- "declared with %<auto%> type specifier", name);
+ error_at (typespec_loc, "%qs function with trailing "
+ "return type not declared with %<auto%> "
+ "type specifier", name);
return error_mark_node;
}
}