diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1ff1c73..d442f01 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7371,10 +7371,11 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 
       if (CLASS_TYPE_P (template_type))
 	{
+	  tree tt = TYPE_MAIN_VARIANT (template_type);
 	  TREE_PRIVATE (type_decl)
-	    = TREE_PRIVATE (TYPE_STUB_DECL (template_type));
+	    = TREE_PRIVATE (TYPE_STUB_DECL (tt));
 	  TREE_PROTECTED (type_decl)
-	    = TREE_PROTECTED (TYPE_STUB_DECL (template_type));
+	    = TREE_PROTECTED (TYPE_STUB_DECL (tt));
 	  if (CLASSTYPE_VISIBILITY_SPECIFIED (template_type))
 	    {
 	      DECL_VISIBILITY_SPECIFIED (type_decl) = 1;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-25.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-25.C
new file mode 100644
index 0000000..dd4cc02
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-25.C
@@ -0,0 +1,10 @@
+// Origin: PR c++/54466
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+  struct X { };
+
+template<typename T>
+  using Y = const X<T>;
+
+using Z = Y<int>;
