Commit 13ff3e16 by Marek Polacek Committed by Marek Polacek

re PR c++/67012 (decltype(auto) with trailing return type)

	PR c++/67012
	PR c++/86942
	* decl.c (grokdeclarator): Disallow functions with trailing return
        type with decltype(auto) as its type.  Also check the function if
        it's inner declarator doesn't exist

	* g++.dg/cpp0x/auto52.C: New test.
	* g++.dg/cpp1y/auto-fn52.C: New test.
	* g++.dg/cpp1y/auto-fn53.C: New test.
	* g++.dg/cpp1y/auto-fn54.C: New test.

From-SVN: r263836
parent eafa30ef
2018-08-24 Marek Polacek <polacek@redhat.com>
PR c++/67012
PR c++/86942
* decl.c (grokdeclarator): Disallow functions with trailing return
type with decltype(auto) as its type. Also check the function if
it's inner declarator doesn't exist
2018-08-21 Marek Polacek <polacek@redhat.com>
PR c++/86499
......
......@@ -11246,7 +11246,10 @@ grokdeclarator (const cp_declarator *declarator,
/* Handle a late-specified return type. */
tree late_return_type = declarator->u.function.late_return_type;
if (funcdecl_p)
if (funcdecl_p
/* This is the case e.g. for
using T = auto () -> int. */
|| inner_declarator == NULL)
{
if (tree auto_node = type_uses_auto (type))
{
......@@ -11278,6 +11281,16 @@ grokdeclarator (const cp_declarator *declarator,
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);
else
error ("invalid use of %<decltype(auto)%>");
return error_mark_node;
}
tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node);
if (!tmpl)
if (tree late_auto = type_uses_auto (late_return_type))
......
2018-08-24 Marek Polacek <polacek@redhat.com>
PR c++/67012
PR c++/86942
* g++.dg/cpp0x/auto52.C: New test.
* g++.dg/cpp1y/auto-fn52.C: New test.
* g++.dg/cpp1y/auto-fn53.C: New test.
* g++.dg/cpp1y/auto-fn54.C: New test.
2018-08-24 Richard Sandiford <richard.sandiford@arm.com>
* lib/target-supports.exp (vect_perm_supported): Only return
......
// PR c++/86942
// { dg-do compile { target c++11 } }
using T = auto() -> int;
using U = void() -> int; // { dg-error "function with trailing return type not declared with .auto." }
using W = auto(); // { dg-error "invalid use of .auto." }
// PR c++/67012
// { dg-do compile { target c++14 } }
decltype(auto) f() -> int; // { dg-error "function with trailing return type has" }
// PR c++/86942
// { dg-do compile { target c++14 } }
using T = decltype(auto) () -> int; // { dg-error "invalid use of" }
// { dg-do compile { target c++14 } }
using T = int () -> decltype(auto); // { dg-error "function with trailing return type not declared with .auto." }
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