OSDN Git Service

2010-04-28 Manuel López-Ibáñez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Apr 2010 08:34:01 +0000 (08:34 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Apr 2010 08:34:01 +0000 (08:34 +0000)
PR c++/9335
cp/
        * error.c (print_instantiation_partial_context_line): Handle
recursive instantiation.
        (print_instantiation_partial_context): Likewise.

testsuite/
        * g++.dg/template/recurse2.C: Update
        * g++.dg/template/recurse.C: Update.
        * g++.dg/template/pr23510.C: Update.
        * lib/prune.exp: Filter out 'recursively instantiated'.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158823 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr23510.C
gcc/testsuite/g++.dg/template/recurse.C
gcc/testsuite/g++.dg/template/recurse2.C
gcc/testsuite/lib/prune.exp

index 6d09c80..03bf79b 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-28  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/9335
+        * error.c (print_instantiation_partial_context_line): Handle
+       recursive instantiation.
+        (print_instantiation_partial_context): Likewise.
+
 2010-04-27  Jason Merrill  <jason@redhat.com>
 
        * init.c (perform_member_init): Check CLASS_TYPE_P.
index b03c83f..4ac70f7 100644 (file)
@@ -2733,31 +2733,45 @@ print_instantiation_full_context (diagnostic_context *context)
 
 static void
 print_instantiation_partial_context_line (diagnostic_context *context,
-                                         const struct tinst_level *t, location_t loc)
+                                         const struct tinst_level *t,
+                                         location_t loc, bool recursive_p)
 {
   expanded_location xloc;
   xloc = expand_location (loc);
 
-  if (t != NULL) {
-    const char *str;
-    str = decl_as_string_translate (t->decl,
-                                   TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
-    if (flag_show_column)
-      pp_verbatim (context->printer,
-                  _("%s:%d:%d:   instantiated from %qs\n"),
-                  xloc.file, xloc.line, xloc.column, str);
-    else
-      pp_verbatim (context->printer,
-                  _("%s:%d:   instantiated from %qs\n"),
-                  xloc.file, xloc.line, str);
-  } else {
-    if (flag_show_column)
-      pp_verbatim (context->printer, _("%s:%d:%d:   instantiated from here"),
-                  xloc.file, xloc.line, xloc.column);
-    else
-      pp_verbatim (context->printer, _("%s:%d:   instantiated from here"),
-                  xloc.file, xloc.line);
-  }
+  if (t != NULL) 
+    {
+      const char *str;
+      str = decl_as_string_translate (t->decl,
+                                     TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
+      if (flag_show_column)
+       pp_verbatim (context->printer,
+                    recursive_p
+                    ? _("%s:%d:%d:   recursively instantiated from %qs\n")
+                    : _("%s:%d:%d:   instantiated from %qs\n"),
+                    xloc.file, xloc.line, xloc.column, str);
+      else
+       pp_verbatim (context->printer,
+                    recursive_p
+                    ? _("%s:%d:   recursively instantiated from %qs\n")
+                    : _("%s:%d:   recursively instantiated from %qs\n"),
+                    xloc.file, xloc.line, str);
+    }
+  else
+    {
+      if (flag_show_column)
+       pp_verbatim (context->printer, 
+                    recursive_p
+                    ? _("%s:%d:%d:   recursively instantiated from here")
+                    : _("%s:%d:%d:   instantiated from here"),
+                    xloc.file, xloc.line, xloc.column);
+      else
+       pp_verbatim (context->printer,
+                    recursive_p
+                    ? _("%s:%d:   recursively instantiated from here")
+                    : _("%s:%d:   instantiated from here"),
+                    xloc.file, xloc.line);
+    }
 }
 
 /* Same as print_instantiation_full_context but less verbose.  */
@@ -2769,9 +2783,14 @@ print_instantiation_partial_context (diagnostic_context *context,
   struct tinst_level *t;
   int n_total = 0;
   int n;
+  location_t prev_loc = loc;
 
   for (t = t0; t != NULL; t = t->next)
-    n_total++;
+    if (prev_loc != t->locus)
+      {
+       prev_loc = t->locus;
+       n_total++;
+      }
 
   t = t0;
 
@@ -2781,11 +2800,13 @@ print_instantiation_partial_context (diagnostic_context *context,
       for (n = 0; n < 5; n++)
        {
          gcc_assert (t != NULL);
-         print_instantiation_partial_context_line (context, t, loc);
+         if (loc != t->locus)
+           print_instantiation_partial_context_line (context, t, loc,
+                                                     /*recursive_p=*/false);
          loc = t->locus;
          t = t->next;
        }
-      if (skip > 1) 
+      if (t != NULL && skip > 1)
        {
          expanded_location xloc;
          xloc = expand_location (loc);
@@ -2799,18 +2820,26 @@ print_instantiation_partial_context (diagnostic_context *context,
                         xloc.file, xloc.line, skip);
          
          do {
-             loc = t->locus;
-             t = t->next;
-         } while (--skip > 0);
+           loc = t->locus;
+           t = t->next;
+         } while (t != NULL && --skip > 0);
        }
     }
   
-  for (; t != NULL; t = t->next)
+  while (t != NULL)
     {
-      print_instantiation_partial_context_line (context, t, loc);
+      while (t->next != NULL && t->locus == t->next->locus)
+       {
+         loc = t->locus;
+         t = t->next;
+       }
+      print_instantiation_partial_context_line (context, t, loc,
+                                               t->locus == loc);
       loc = t->locus;
+      t = t->next;
     }
-  print_instantiation_partial_context_line (context, NULL, loc);
+  print_instantiation_partial_context_line (context, NULL, loc,
+                                           /*recursive_p=*/false);
   pp_base_newline (context->printer);
 }
 
index ac3d6e6..bb6b97c 100644 (file)
@@ -1,3 +1,11 @@
+2010-04-28  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/9335
+        * g++.dg/template/recurse2.C: Update
+        * g++.dg/template/recurse.C: Update.
+        * g++.dg/template/pr23510.C: Update.
+        * lib/prune.exp: Filter out 'recursively instantiated'.
+
 2010-04-27  Fabien Chêne  <fabien.chene@gmail.com>
 
        PR c++/29043
index a0806e2..b9e9889 100644 (file)
@@ -4,7 +4,7 @@ template<unsigned int nFactor>
 struct Factorial
 {
   enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" } 
-  // { dg-message "skipping 5 instantiation contexts" "" { target *-*-* } 6 } 
+  // { dg-message "recursively instantiated" "" { target *-*-* } 6 } 
   // { dg-error "incomplete type" "" { target *-*-* } 6 } 
 } 
 
index 17fe186..448c347 100644 (file)
@@ -8,8 +8,7 @@ template <int I> struct F
       F<I+1> f;                        // { dg-error "incomplete type" "incomplete" }
                                // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
                                 // { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
-      return f()*I;             // { dg-message "instantiated" "recurse" }
-      // { dg-message "skipping 40 instantiation contexts" "" { target *-*-* } 11 }
+      return f()*I;             // { dg-message "recursively instantiated" "recurse" }
     }
 };
 
index cf085e0..b9767df 100644 (file)
@@ -3,5 +3,6 @@
 
 template <int N> struct X {
     static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" }
+  // { dg-message "recursively instantiated" "" { target *-*-* } 5 }
 };
 template struct X<1000>;
index 160f651..769169d 100644 (file)
@@ -22,7 +22,7 @@ proc prune_gcc_output { text } {
 
     regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|program|subroutine|block-data)\[^\n\]*" $text "" text
     regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text
-    regsub -all "(^|\n)\[^\n\]*:   instantiated from \[^\n\]*" $text "" text
+    regsub -all "(^|\n)\[^\n\]*:   (recursively )?instantiated from \[^\n\]*" $text "" text
     regsub -all "(^|\n)\[^\n\]*:   . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text
     regsub -all "(^|\n)    inlined from \[^\n\]*" $text "" text
     regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text