Patchwork C++ PATCH for c++/47068 (ICE with decltype of destructor name)

login
register
mail settings
Submitter Jason Merrill
Date Dec. 29, 2010, 2:17 a.m.
Message ID <4D1A9A34.90204@redhat.com>
Download mbox | patch
Permalink /patch/76876/
State New
Headers show

Comments

Jason Merrill - Dec. 29, 2010, 2:17 a.m.
maybe_note_name_used_in_class assumes that its argument is, in fact, a 
name, not just an id-expression, so we shouldn't call it for non-names.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit c22af743cd576b2a1c5e22f1a005020ec1f9a77f
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 28 18:47:13 2010 -0500

    	PR c++/47068
    	* semantics.c (finish_id_expression): Don't note non-names
    	as being used in the class.

Patch

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 93493fb..aeb10fe 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2797,7 +2797,8 @@  finish_id_expression (tree id_expression,
 	 the current class so that we can check later to see if
 	 the meaning would have been different after the class
 	 was entirely defined.  */
-      if (!scope && decl != error_mark_node)
+      if (!scope && decl != error_mark_node
+	  && TREE_CODE (id_expression) == IDENTIFIER_NODE)
 	maybe_note_name_used_in_class (id_expression, decl);
 
       /* Disallow uses of local variables from containing functions, except
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype24.C b/gcc/testsuite/g++.dg/cpp0x/decltype24.C
new file mode 100644
index 0000000..16d0736
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype24.C
@@ -0,0 +1,7 @@ 
+// PR c++/47068
+// { dg-options -std=c++0x }
+
+template <class T> struct broken {
+  int member;
+  typedef decltype(~ member) gcc_crashes_here;
+};