diff options
author | Adam Butcher <adam@jessamine.co.uk> | 2015-06-24 16:11:06 +0100 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-06-24 15:11:06 +0000 |
commit | aa97bb6f1229cf69aa17ad7660c3bc63c39ab22b (patch) | |
tree | 91cdf8752a8c083aa801cf0f11735cf56a34b7a1 /gcc | |
parent | e00cdb8a6546552f699a86f8bda85e56242ddf79 (diff) | |
download | gcc-aa97bb6f1229cf69aa17ad7660c3bc63c39ab22b.zip gcc-aa97bb6f1229cf69aa17ad7660c3bc63c39ab22b.tar.gz gcc-aa97bb6f1229cf69aa17ad7660c3bc63c39ab22b.tar.bz2 |
re PR c++/65750 (misinterpret in a virtual member function with a C++11 style function signature)
/cp
2015-06-24 Adam Butcher <adam@jessamine.co.uk>
PR c++/65750
* parser.c (cp_parser_simple_type_specifier): Don't synthesize
implicit template parm if 'auto' is a placeholder for trailing
return type.
/testsuite
2015-06-24 Adam Butcher <adam@jessamine.co.uk>
PR c++/65750
* g++.dg/cpp0x/trailing11.C: New.
From-SVN: r224901
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/trailing11.C | 12 |
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4b27519..c9c3977 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-06-24 Adam Butcher <adam@jessamine.co.uk> + + PR c++/65750 + * parser.c (cp_parser_simple_type_specifier): Don't synthesize + implicit template parm if 'auto' is a placeholder for trailing + return type. + 2015-06-24 Patrick Palka <ppalka@gcc.gnu.org> Revert: diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9a1cbd8..5150abe 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14939,6 +14939,30 @@ 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); + 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/ChangeLog b/gcc/testsuite/ChangeLog index 40d8497..af6d43a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-06-24 Adam Butcher <adam@jessamine.co.uk> + + PR c++/65750 + * g++.dg/cpp0x/trailing11.C: New. + 2015-06-24 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> * gcc.target/arm/fixed_float_conversion.c: Skip for inappropriate diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing11.C b/gcc/testsuite/g++.dg/cpp0x/trailing11.C new file mode 100644 index 0000000..0c9e908 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing11.C @@ -0,0 +1,12 @@ +// PR c++/65750 +// { dg-do compile { target c++11 } } + +template<typename T> struct F { }; + +class a +{ + virtual auto f( F< void () > ) -> void; + virtual auto g( F< auto () -> void > ) -> void; +}; + +auto main() -> int { } |