re PR c++/53816 (internal compiler error: tree check: expected field_decl, have ident...
authorJason Merrill <jason@redhat.com>
Tue, 3 Jul 2012 03:29:58 +0000 (23:29 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 3 Jul 2012 03:29:58 +0000 (23:29 -0400)
PR c++/53816
* class.c (resolves_to_fixed_type_p): Check uses_template_parms
(current_function_decl) instead of processing_template_decl.

From-SVN: r189187

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ref6.C [new file with mode: 0644]

index fb8a34de04c92dc88528507a42738b8f2902d51a..f00ff70f8f10da8bcf57ecc552ee2c1f12b1bc82 100644 (file)
@@ -1,5 +1,9 @@
 2012-07-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53816
+       * class.c (resolves_to_fixed_type_p): Check uses_template_parms
+       (current_function_decl) instead of processing_template_decl.
+
        PR c++/53821
        * semantics.c (maybe_add_lambda_conv_op): Don't set
        DECL_INTERFACE_KNOWN.
index 264258c1dbc1a73495686303aedbd8c51cbdff6f..e70e6747b55b40ceb42a71072f9856bdea747289 100644 (file)
@@ -6521,7 +6521,10 @@ resolves_to_fixed_type_p (tree instance, int* nonnull)
   int cdtorp = 0;
   tree fixed;
 
-  if (processing_template_decl)
+  /* processing_template_decl can be false in a template if we're in
+     fold_non_dependent_expr, but we still want to suppress this check.  */
+  if (current_function_decl
+      && uses_template_parms (current_function_decl))
     {
       /* In a template we only care about the type of the result.  */
       if (nonnull)
index dead28172925069c93c1ff15cf244fb8e2c90bca..fc712849a65a4d282470c03a8933d6e285572c43 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-02  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53816
+       * g++.dg/template/ref6.C: New.
+
 2012-07-03  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/53568
diff --git a/gcc/testsuite/g++.dg/template/ref6.C b/gcc/testsuite/g++.dg/template/ref6.C
new file mode 100644 (file)
index 0000000..2e1254a
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/53816
+
+template <typename T>
+struct S { int v () const; };
+template <typename T>
+struct V : public S<T> {};
+struct U
+{
+  V<int> v;
+  template<typename T>
+  struct W
+  {
+    W (U const &x) { V<int> const &v = x.v; v.v(); }
+  };
+};