A decltype doesn't have a name.
Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
commit bab2f5e9e77bd41b91ca6eae34483eb159307519
Author: Jason Merrill <[email protected]>
Date: Thu Jun 14 17:28:08 2012 -0700
PR c++/53651
* name-lookup.c (constructor_name_p): Don't try to look at the
name of a DECLTYPE_TYPE.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0f28820..cc8439c 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype37.C b/gcc/testsuite/g++.dg/cpp0x/decltype37.C
new file mode 100644
index 0000000..c885e9a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype37.C
@@ -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;