Hi,

I'm having a look at this ICE during error recovery regression and I have a couple of different proposals which both pass testing. In the first case, instead of reaching (in cp_parser_cache_defarg):

  default_argument = make_node (DEFAULT_ARG);
  DEFARG_TOKENS (default_argument)
    = cp_token_cache_new (first_token, token);
  DEFARG_INSTANTIATIONS (default_argument) = NULL;

  return default_argument;

we could simply return an error_mark_node right after:

error_at (token->location, "file ends in default argument");

and certainly avoid the ICE in merge_exception_specifiers much later. Alternately, maybe it's too heavy handed, maybe fatal_errors are really appropriate in a very restrict set of cases (not sure), it would work to simply change the error_at to fatal_error, which also cuts some redundant diagnostic we produce right now after the sensible one about file ends. The idea occurred to me in particular because the error_at above does *not* result (and never did to my best knowledge) in a actual location being printed, we issue:

cc1plus: error: file ends in default argument

which smells like a fatal-type error message?!?

What do you think?

Thanks,
Paolo.

/////////////////////////
/cp
2016-04-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/68722
        * parser.c (cp_parser_cache_defarg): When file ends in default
        argument simply return error_mark_node.

/testsuite
2016-04-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/68722
        * g++.dg/parse/pr68722.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 234836)
+++ cp/parser.c (working copy)
@@ -27472,8 +27472,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns
        case CPP_EOF:
        case CPP_PRAGMA_EOL:
          error_at (token->location, "file ends in default argument");
-         done = true;
-         break;
+         return error_mark_node;
 
        case CPP_NAME:
        case CPP_SCOPE:
Index: testsuite/g++.dg/parse/pr68722.C
===================================================================
--- testsuite/g++.dg/parse/pr68722.C    (revision 0)
+++ testsuite/g++.dg/parse/pr68722.C    (working copy)
@@ -0,0 +1,9 @@
+// PR c++/68722
+
+class A {
+  &__loc   // { dg-error "" }
+} class ios_base {  // { dg-error "" }
+  A _M_ios_locale ios_base(ios_base &) template <_Traits> class basic_ios {  
// { dg-error "" }
+basic_ios basic_ios = operator=  // { dg-error "" }
+
+// { dg-prune-output "file ends in default argument" }
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 234836)
+++ cp/parser.c (working copy)
@@ -27471,7 +27471,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns
          /* If we run out of tokens, issue an error message.  */
        case CPP_EOF:
        case CPP_PRAGMA_EOL:
-         error_at (token->location, "file ends in default argument");
+         fatal_error (token->location, "file ends in default argument");
          done = true;
          break;
 
Index: testsuite/g++.dg/parse/pr68722.C
===================================================================
--- testsuite/g++.dg/parse/pr68722.C    (revision 0)
+++ testsuite/g++.dg/parse/pr68722.C    (working copy)
@@ -0,0 +1,10 @@
+// PR c++/68722
+
+class A {
+  &__loc   // { dg-error "" }
+} class ios_base {  // { dg-error "" }
+  A _M_ios_locale ios_base(ios_base &) template <_Traits> class basic_ios {  
// { dg-error "" }
+basic_ios basic_ios = operator=
+
+// { dg-prune-output "file ends in default argument" }
+// { dg-prune-output "compilation terminated" }

Reply via email to