diff options
| author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-03 21:42:22 +0000 |
|---|---|---|
| committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-12-03 21:42:22 +0000 |
| commit | ddcb49cab8b5a584dbcddd705f0431b5b1470cc2 (patch) | |
| tree | 7c2b394d09e329bf6ba41e2a2255295e593a2155 | |
| parent | 51557c5b27cdfb0e486ac66854d659f6866c9e14 (diff) | |
| download | ppe42-gcc-ddcb49cab8b5a584dbcddd705f0431b5b1470cc2.tar.gz ppe42-gcc-ddcb49cab8b5a584dbcddd705f0431b5b1470cc2.zip | |
PR c++/38256
* parser.c (cp_parser_conversion_type_id): Diagnose
'operator auto' here.
* decl.c (grokdeclarator): Not here.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142410 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/cp/decl.c | 7 | ||||
| -rw-r--r-- | gcc/cp/parser.c | 10 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/auto11.C | 12 |
5 files changed, 31 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4987ca48687..f8bf1628eb0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2008-12-03 Jason Merrill <jason@redhat.com> + PR c++/38256 + * parser.c (cp_parser_conversion_type_id): Diagnose + 'operator auto' here. + * decl.c (grokdeclarator): Not here. + PR c++/38380 * decl.c (grokdeclarator): Only set DECL_NONCONVERTING_P on explicit constructors. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 87144324272..f2e12b3c772 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8258,12 +8258,7 @@ grokdeclarator (const cp_declarator *declarator, { if (type_uses_auto (type)) { - if (sfk == sfk_conversion) - { - error ("invalid use of %<auto%> in conversion operator"); - return error_mark_node; - } - else if (!declarator->u.function.late_return_type) + if (!declarator->u.function.late_return_type) { error ("%qs function uses %<auto%> type specifier without" " late return type", name); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 275a7f3b4d3..45abd2414d5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8966,6 +8966,16 @@ cp_parser_conversion_type_id (cp_parser* parser) /*initialized=*/0, &attributes); if (attributes) cplus_decl_attributes (&type_specified, attributes, /*flags=*/0); + + /* Don't give this error when parsing tentatively. This happens to + work because we always parse this definitively once. */ + if (! cp_parser_uncommitted_to_tentative_parse_p (parser) + && type_uses_auto (type_specified)) + { + error ("invalid use of %<auto%> in conversion operator"); + return error_mark_node; + } + return type_specified; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a574ebdb16..140c6ae98f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2008-12-03 Jason Merrill <jason@redhat.com> + PR c++/38256 + * g++.dg/cpp0x/auto11.C: New test. + PR c++/38380 * g++.dg/cpp0x/initlist10.C: New test. * g++.old-deja/g++.eh/ctor1.C: Default ctor is a candidate too. diff --git a/gcc/testsuite/g++.dg/cpp0x/auto11.C b/gcc/testsuite/g++.dg/cpp0x/auto11.C new file mode 100644 index 00000000000..bd21daef0c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto11.C @@ -0,0 +1,12 @@ +// PR c++/38256 +// { dg-options "-std=c++0x" } + +template<int> struct A +{ + template<typename T> operator T(); +}; + +void foo() +{ + A<0>().operator auto(); // { dg-error "auto.*conversion" } +} |

