re PR c++/35097 (ICE with attribute and template specialization)
authorJason Merrill <jason@redhat.com>
Tue, 12 Feb 2008 06:34:59 +0000 (01:34 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 12 Feb 2008 06:34:59 +0000 (01:34 -0500)
        PR c++/35097
        * pt.c (tsubst): Don't look up a template typedef in an explicit
        specialization.

From-SVN: r132253

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/ext/attrib31.C [new file with mode: 0644]

index 1e26a16..c11dcd5 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-11  Jason Merrill  <jason@redhat.com>
+
+       PR c++/35097
+       * pt.c (tsubst): Don't look up a template typedef in an explicit
+       specialization.
+
 2008-02-11  Douglas Gregor  <doug.gregor@gmail.com>
 
        PR c++/35113
index 2a8296e..a1e6521 100644 (file)
@@ -8826,14 +8826,16 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       tree decl = TYPE_NAME (t);
       
       if (DECL_CLASS_SCOPE_P (decl)
-         && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)))
+         && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))
+         && uses_template_parms (DECL_CONTEXT (decl)))
        {
          tree tmpl = most_general_template (DECL_TI_TEMPLATE (decl));
          tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);
          r = retrieve_specialization (tmpl, gen_args, false);
        }
       else if (DECL_FUNCTION_SCOPE_P (decl)
-              && DECL_TEMPLATE_INFO (DECL_CONTEXT (decl)))
+              && DECL_TEMPLATE_INFO (DECL_CONTEXT (decl))
+              && uses_template_parms (DECL_TI_ARGS (DECL_CONTEXT (decl))))
        r = retrieve_local_specialization (decl);
       else
        /* The typedef is from a non-template context.  */
diff --git a/gcc/testsuite/g++.dg/ext/attrib31.C b/gcc/testsuite/g++.dg/ext/attrib31.C
new file mode 100644 (file)
index 0000000..c614ed4
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/35097
+
+template<int> struct A;
+
+template<> struct A<0>
+{
+  typedef int X __attribute((aligned(4)));
+};
+
+template<typename T> void foo(const A<0>::X&, T);
+
+void bar()
+{
+  foo(A<0>::X(), 0);
+}