diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/parser.c | 38 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr84610.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr84642.C | 3 |
5 files changed, 59 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aa8ba26..233b57e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2018-03-21 Alexandre Oliva <aoliva@redhat.com> + + PR c++/84610 + PR c++/84642 + * parser.c (abort_fully_implicit_template_p): New. + (cp_parser_skip_to_end_of_statement): Use it. + (cp_parser_skip_to_end_of_block_or_statement): Likewise. + (finish_fully_implicit_template_p): Clear + implicit_template_parms and implicit_template_scope. + 2018-03-21 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84972 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 4e3e1dc..6dcfae1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2264,6 +2264,8 @@ static tree synthesize_implicit_template_parm (cp_parser *, tree); static tree finish_fully_implicit_template (cp_parser *, tree); +static void abort_fully_implicit_template + (cp_parser *); /* Classes [gram.class] */ @@ -3585,7 +3587,7 @@ cp_parser_skip_to_end_of_statement (cp_parser* parser) /* Unwind generic function template scope if necessary. */ if (parser->fully_implicit_function_template_p) - finish_fully_implicit_template (parser, /*member_decl_opt=*/0); + abort_fully_implicit_template (parser); while (true) { @@ -3675,7 +3677,7 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser) /* Unwind generic function template scope if necessary. */ if (parser->fully_implicit_function_template_p) - finish_fully_implicit_template (parser, /*member_decl_opt=*/0); + abort_fully_implicit_template (parser); while (nesting_depth >= 0) { @@ -39273,11 +39275,43 @@ finish_fully_implicit_template (cp_parser *parser, tree member_decl_opt) end_template_decl (); parser->fully_implicit_function_template_p = false; + parser->implicit_template_parms = 0; + parser->implicit_template_scope = 0; --parser->num_template_parameter_lists; return member_decl_opt; } +/* Like finish_fully_implicit_template, but to be used in error + recovery, rearranging scopes so that we restore the state we had + before synthesize_implicit_template_parm inserted the implement + template parms scope. */ + +static void +abort_fully_implicit_template (cp_parser *parser) +{ + cp_binding_level *return_to_scope = current_binding_level; + + if (parser->implicit_template_scope + && return_to_scope != parser->implicit_template_scope) + { + cp_binding_level *child = return_to_scope; + for (cp_binding_level *scope = child->level_chain; + scope != parser->implicit_template_scope; + scope = child->level_chain) + child = scope; + child->level_chain = parser->implicit_template_scope->level_chain; + parser->implicit_template_scope->level_chain = return_to_scope; + current_binding_level = parser->implicit_template_scope; + } + else + return_to_scope = return_to_scope->level_chain; + + finish_fully_implicit_template (parser, NULL); + + gcc_assert (current_binding_level == return_to_scope); +} + /* Helper function for diagnostics that have complained about things being used with 'extern "C"' linkage. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 93dc7a2..45705c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-03-21 Alexandre Oliva <aoliva@redhat.com> + + PR c++/84610 + PR c++/84642 + * g++.dg/cpp0x/pr84610.C: New. + * g++.dg/cpp0x/pr84642.C: New. + 2018-03-21 Jakub Jelinek <jakub@redhat.com> PR c/84999 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84610.C b/gcc/testsuite/g++.dg/cpp0x/pr84610.C new file mode 100644 index 0000000..cc70748 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr84610.C @@ -0,0 +1,3 @@ +// { dg-do compile { target c++11 } } + +a (int &__attribute__ ((aligned(auto x)) y)); // { dg-error "parameter declaration|before|expected constructor" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84642.C b/gcc/testsuite/g++.dg/cpp0x/pr84642.C new file mode 100644 index 0000000..5c6895e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr84642.C @@ -0,0 +1,3 @@ +// { dg-do compile { target c++11 } } + +a(int(const &&__attribute__((b(auto;))))) // { dg-error "parameter declaration|with no type|before|expected constructor" } |