public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/37555 and PR c++/37556 (ICEs with invalid typedef)
@ 2008-09-27 16:35 Simon Martin
  2008-09-30 19:49 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Martin @ 2008-09-27 16:35 UTC (permalink / raw)
  To: gcc-patches

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

Hi all.


The following snippet triggers an ICE since 3.4:

=== PR c++/37555 ===
struct A {};

typedef void (A::T)();

void foo()
{
     T t;
     t;
}
=== PR c++/37555 ===


And this one with the mainline (introduced by
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138756):

=== PR c++/37556 ===
struct A
{
     void foo();
};

typedef void (A::T)();

void bar(T);

void baz()
{
     bar(&A::foo);
}
=== PR c++/37556 ===


The following patch fixes both ICEs by setting the type of declarations
for typedefs to nested-name-specifiers to error_mark_node.

I've successfully regtested this patch on x86_64-apple-darwin-9. Is it
OK for 4.3 and for the mainline?

Thanks in advance,
Simon

:ADDPATCH c++:



[-- Attachment #2: CL_37555 --]
[-- Type: text/plain, Size: 192 bytes --]

2008-09-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37555
	PR c++/37556
	* decl.c (grokdeclarator): Set the type for typedefs to a
	nested-name-specifier to error_mark_node.



[-- Attachment #3: pr37555.patch --]
[-- Type: text/plain, Size: 635 bytes --]

Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 140713)
+++ gcc/cp/decl.c	(working copy)
@@ -8679,8 +8679,10 @@ grokdeclarator (const cp_declarator *dec
 	decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
       else
 	decl = build_decl (TYPE_DECL, unqualified_id, type);
-      if (id_declarator && declarator->u.id.qualifying_scope)
+      if (id_declarator && declarator->u.id.qualifying_scope) {
 	error ("%Jtypedef name may not be a nested-name-specifier", decl);
+	TREE_TYPE (decl) = error_mark_node;
+      }
 
       if (decl_context != FIELD)
 	{



[-- Attachment #4: CL_37555_testsuite --]
[-- Type: text/plain, Size: 165 bytes --]

2008-09-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37555
	* g++.dg/parse/error32.C: New test.

	PR c++/37556
	* g++.dg/parse/error33.C: New test.



[-- Attachment #5: error32.C --]
[-- Type: text/plain, Size: 220 bytes --]

/* PR c++/37555 */
/* { dg-do "compile" } */

struct A {};

typedef void (A::T)(); /* { dg-error "typedef name may not be a nested-name-specifier" } */

void foo()
{
  T t;
  t; /* { dg-error "was not declared" } */
}



[-- Attachment #6: error33.C --]
[-- Type: text/plain, Size: 275 bytes --]

/* PR c++/37556 */
/* { dg-do "compile" } */

struct A
{
  void foo();
};

typedef void (A::T)(); /* { dg-error "typedef name may not be a nested" } */

void bar(T); /* { dg-error "too many arguments" } */

void baz()
{
  bar(&A::foo); /* { dg-error "at this point" } */
}



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

* Re: [PATCH] Fix PR c++/37555 and PR c++/37556 (ICEs with invalid  typedef)
  2008-09-27 16:35 [PATCH] Fix PR c++/37555 and PR c++/37556 (ICEs with invalid typedef) Simon Martin
@ 2008-09-30 19:49 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2008-09-30 19:49 UTC (permalink / raw)
  To: Simon Martin; +Cc: gcc-patches

Simon Martin wrote:

> :ADDPATCH c++:

> 2008-09-27  Simon Martin  <simartin@users.sourceforge.net>
> 
> 	PR c++/37555
> 	PR c++/37556
> 	* decl.c (grokdeclarator): Set the type for typedefs to a
> 	nested-name-specifier to error_mark_node.

:REVIEWMAIL: OK

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

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

end of thread, other threads:[~2008-09-30 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-27 16:35 [PATCH] Fix PR c++/37555 and PR c++/37556 (ICEs with invalid typedef) Simon Martin
2008-09-30 19:49 ` Mark Mitchell

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).