Hi,

one more / RFC, for the ICE on invalid part of these issues with '->'.

The below tries to catch the problem very early, in cp_parser_postfix_dot_deref_expression and apparently works fine, passes the testsuite, etc. Is it too early? Is the check tight enough?

Thanks,
Paolo.

//////////////////////
Index: testsuite/g++.dg/template/crash109.C
===================================================================
--- testsuite/g++.dg/template/crash109.C        (revision 0)
+++ testsuite/g++.dg/template/crash109.C        (revision 0)
@@ -0,0 +1,10 @@
+// PR c++/50864
+
+namespace impl
+{
+  template <class T> T create();
+}
+
+template <class T, class U, __SIZE_TYPE__
+         = sizeof(impl::create<T>() -> impl::create<U>())>  // { dg-error "not 
a class member" } 
+struct foo;
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 180532)
+++ cp/parser.c (working copy)
@@ -5673,6 +5673,15 @@ cp_parser_postfix_dot_deref_expression (cp_parser
        {
          if (name != error_mark_node && !BASELINK_P (name) && parser->scope)
            {
+             if (TREE_CODE (parser->scope) == NAMESPACE_DECL
+                 && TREE_CODE (postfix_expression) == ARROW_EXPR)
+               {
+                 error_at (token->location, "%<%D::%D%> is not a class member",
+                           parser->scope, name);
+                 parser->context->object_type = NULL_TREE;
+                 return error_mark_node;
+               }
+
              name = build_qualified_name (/*type=*/NULL_TREE,
                                           parser->scope,
                                           name,

Reply via email to