This warning should not warn for
auto f1 () -> auto;
because that cannot be confused with initializing a variable.
PR c++/118718
gcc/cp/ChangeLog:
* parser.cc (warn_about_ambiguous_parse): Don't warn when a trailing
return type is present.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wvexing-parse10.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(const_cast<cp_declarator *>(declarator))))
return;
+ /* Don't warn for auto f () -> auto. */
+ if (declarator->u.function.late_return_type)
+ return;
+
/* Don't warn when the whole declarator (not just the declarator-id!)
was parenthesized. That is, don't warn for int(n()) but do warn
for int(f)(). */
--- /dev/null
+// PR c++/118718
+// { dg-do compile { target c++14 } }
+
+void
+fn ()
+{
+ auto f1 () -> auto;
+ auto f2 (); // { dg-warning "empty parentheses" }
+}