re PR c++/53651 ([C++11] seg fault when specifying using decltype(...)::method)
authorJason Merrill <jason@redhat.com>
Wed, 20 Jun 2012 01:17:59 +0000 (21:17 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 20 Jun 2012 01:17:59 +0000 (21:17 -0400)
PR c++/53651
* name-lookup.c (constructor_name_p): Don't try to look at the
name of a DECLTYPE_TYPE.

From-SVN: r188807

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype37.C [new file with mode: 0644]

index b45077525cc5981b41f9b918e6ae4cbb6be500cf..562f945be4350edf04650da389708b329c896050 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53651
+       * name-lookup.c (constructor_name_p): Don't try to look at the
+       name of a DECLTYPE_TYPE.
+
 2012-06-18  Lawrence Crowl  <crowl@google.com>
 
        * decl2.c (cp_write_global_declarations): Rename use of TV_PHASE_CGRAPH
index 0f2882044c7297433edef7643554ba3f72255246..cc8439c9ccd6f8ec906e3772d12baf81927e8588 100644 (file)
@@ -1966,6 +1966,11 @@ constructor_name_p (tree name, tree type)
   if (TREE_CODE (name) != IDENTIFIER_NODE)
     return false;
 
+  /* These don't have names.  */
+  if (TREE_CODE (type) == DECLTYPE_TYPE
+      || TREE_CODE (type) == TYPEOF_TYPE)
+    return false;
+
   ctor_name = constructor_name_full (type);
   if (name == ctor_name)
     return true;
index 86d6ab148ad966d4656c10ce6bf70c51cb4c72b8..07071a933c4e5eceb0f1038ed6349bd4f8c3ceb0 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53651
+       * g++.dg/cpp0x/decltype37.C: New.
+
 2012-06-19  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * gcc.dg/stack-usage-1.c: Use sh*-*-* instead of sh-*-*.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype37.C b/gcc/testsuite/g++.dg/cpp0x/decltype37.C
new file mode 100644 (file)
index 0000000..c885e9a
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/53651
+// { dg-do compile { target c++11 } }
+
+template<typename> struct wrap { void bar(); };
+
+template<typename T> auto foo(T* t) -> wrap<T>* { return 0; }
+
+template<typename T>
+struct holder : decltype(*foo((T*)0)) // { dg-error "class type" }
+{
+    using decltype(*foo((T*)0))::bar; // { dg-error "is not a base" }
+};
+
+holder<int> h;