From 49e0438549375d706a61eb78f8375ce4877e78cc Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 12 Aug 1998 14:40:39 +0000 Subject: [PATCH] pt.c (print_template_context): Don't abort when instantiating a synthesized method. * pt.c (print_template_context): Don't abort when instantiating a synthesized method. From-SVN: r21685 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 23 ++++++++++++--------- gcc/testsuite/g++.old-deja/g++.pt/crash20.C | 9 ++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/crash20.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fe7813b6d1d..cee17fd299e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 1998-08-12 Mark Mitchell + * pt.c (print_template_context): Don't abort when instantiating a + synthesized method. + * decl.c (grokdeclarator): Issue errors on namespace qualified declarators in parameter lists or in class scope. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8e0983ece5b..319941f5e5c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3699,25 +3699,28 @@ print_template_context (err) int line = lineno; char *file = input_filename; - if (err) + if (err && p) { - if (current_function_decl == p->decl) - /* Avoid redundancy with the the "In function" line. */; - else if (current_function_decl == NULL_TREE) - fprintf (stderr, "%s: In instantiation of `%s':\n", - file, decl_as_string (p->decl, 0)); + if (current_function_decl != p->decl + && current_function_decl != NULL_TREE) + /* We can get here during the processing of some synthesized + method. Then, p->decl will be the function that's causing + the synthesis. */ + ; else - my_friendly_abort (980521); - - if (p) { + if (current_function_decl == p->decl) + /* Avoid redundancy with the the "In function" line. */; + else + fprintf (stderr, "%s: In instantiation of `%s':\n", + file, decl_as_string (p->decl, 0)); + line = p->line; file = p->file; p = p->next; } } - next: for (; p; p = p->next) { fprintf (stderr, "%s:%d: instantiated from `%s'\n", file, line, diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash20.C b/gcc/testsuite/g++.old-deja/g++.pt/crash20.C new file mode 100644 index 00000000000..29b4281c76e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash20.C @@ -0,0 +1,9 @@ +// Build don't link: + +template +struct A { const T x; A() : x(0) { } A(T x) : x(x) { } }; + +template +void func () { B y; y = B(); } // ERROR - can't use default assignment + +int main (void) { func< A<> >(); } // ERROR - instantiated from here