public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch / RFC] PR 50864
@ 2011-10-26 20:31 Paolo Carlini
  2011-10-26 20:47 ` Jason Merrill
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Carlini @ 2011-10-26 20:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

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.

//////////////////////

[-- Attachment #2: patch_50864_draft --]
[-- Type: text/plain, Size: 1164 bytes --]

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,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-07 21:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-26 20:31 [C++ Patch / RFC] PR 50864 Paolo Carlini
2011-10-26 20:47 ` Jason Merrill
2011-10-26 21:05   ` Paolo Carlini
2011-10-26 21:16     ` Paolo Carlini
2011-10-26 22:15       ` Paolo Carlini
2011-11-07 21:52       ` Jason Merrill
2011-11-07 22:06         ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).