* [PATCH] PR c++/65750
@ 2015-04-14 21:01 Adam Butcher
2015-04-14 21:27 ` Adam Butcher
0 siblings, 1 reply; 5+ messages in thread
From: Adam Butcher @ 2015-04-14 21:01 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Adam Butcher
* cp/parser.c (cp_parser_simple_type_specifier): Don't synthesize
implicit template parm if 'auto' is a placeholder for trailing return
type.
---
gcc/cp/parser.c | 23 +++++++++++++++++++++++
gcc/testsuite/g++.dg/cpp1y/pr65750.C | 12 ++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr65750.C
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4611be9..511ec85 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14949,6 +14949,29 @@ cp_parser_simple_type_specifier (cp_parser* parser,
maybe_warn_cpp0x (CPP0X_AUTO);
if (parser->auto_is_implicit_function_template_parm_p)
{
+ /* The 'auto' might be the placeholder return type for a function decl
+ with trailing return type. */
+ bool have_trailing_return_fn_decl = false;
+ if (cp_lexer_peek_nth_token (parser->lexer, 2)->type
+ == CPP_OPEN_PAREN)
+ {
+ cp_parser_parse_tentatively (parser);
+ cp_lexer_consume_token (parser->lexer);
+ if (cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering*/false,
+ /*or_comma*/false,
+ /*consume_paren*/true))
+ have_trailing_return_fn_decl
+ = cp_lexer_next_token_is (parser->lexer, CPP_DEREF);
+ cp_parser_abort_tentative_parse (parser);
+ }
+
+ if (have_trailing_return_fn_decl)
+ {
+ type = make_auto ();
+ break;
+ }
+
if (cxx_dialect >= cxx14)
type = synthesize_implicit_template_parm (parser);
else
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr65750.C b/gcc/testsuite/g++.dg/cpp1y/pr65750.C
new file mode 100644
index 0000000..798d13b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr65750.C
@@ -0,0 +1,12 @@
+// PR c++/65750
+// { dg-do compile { target c++14 } }
+
+template <typename T> struct F { };
+
+class a
+{
+ virtual auto f( F< void () > ) -> void;
+ virtual auto g( F< auto () -> void > ) -> void;
+};
+
+auto main() -> int { }
--
2.3.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PR c++/65750
2015-04-14 21:01 [PATCH] PR c++/65750 Adam Butcher
@ 2015-04-14 21:27 ` Adam Butcher
2015-04-14 21:34 ` Jason Merrill
0 siblings, 1 reply; 5+ messages in thread
From: Adam Butcher @ 2015-04-14 21:27 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On 2015-04-10 15:57, Adam Butcher wrote:
> + cp_lexer_consume_token (parser->lexer);
Actually there should be two of these as the 'auto' isn't consumed yet.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PR c++/65750
2015-04-14 21:27 ` Adam Butcher
@ 2015-04-14 21:34 ` Jason Merrill
2015-06-24 10:58 ` Paolo Carlini
0 siblings, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2015-04-14 21:34 UTC (permalink / raw)
To: Adam Butcher; +Cc: gcc-patches
On 04/14/2015 05:27 PM, Adam Butcher wrote:
> On 2015-04-10 15:57, Adam Butcher wrote:
>> + cp_lexer_consume_token (parser->lexer);
>
> Actually there should be two of these as the 'auto' isn't consumed yet.
OK.
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PR c++/65750
2015-04-14 21:34 ` Jason Merrill
@ 2015-06-24 10:58 ` Paolo Carlini
2015-06-26 22:36 ` Jason Merrill
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Carlini @ 2015-06-24 10:58 UTC (permalink / raw)
To: Jason Merrill, Adam Butcher; +Cc: gcc-patches
Hi,
On 04/14/2015 11:34 PM, Jason Merrill wrote:
> On 04/14/2015 05:27 PM, Adam Butcher wrote:
>> On 2015-04-10 15:57, Adam Butcher wrote:
>>> + cp_lexer_consume_token (parser->lexer);
>>
>> Actually there should be two of these as the 'auto' isn't consumed yet.
> OK.
I'm finishing retesting the amended patch and, if everything goes well,
I will apply it to trunk, as approved by Jason (only additional minor
tweak: testcase in cpp0x instead of cpp1y).
What about gcc-5-branch? It's a regression.
Thanks,
Paolo.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PR c++/65750
2015-06-24 10:58 ` Paolo Carlini
@ 2015-06-26 22:36 ` Jason Merrill
0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2015-06-26 22:36 UTC (permalink / raw)
To: Paolo Carlini, Adam Butcher; +Cc: gcc-patches, Patrick Palka
On 06/24/2015 06:55 AM, Paolo Carlini wrote:
> I'm finishing retesting the amended patch and, if everything goes well,
> I will apply it to trunk, as approved by Jason (only additional minor
> tweak: testcase in cpp0x instead of cpp1y).
>
> What about gcc-5-branch? It's a regression.
I think this is safe enough for the branch.
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-26 22:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14 21:01 [PATCH] PR c++/65750 Adam Butcher
2015-04-14 21:27 ` Adam Butcher
2015-04-14 21:34 ` Jason Merrill
2015-06-24 10:58 ` Paolo Carlini
2015-06-26 22:36 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).