re PR c++/10471 (SegFault in build_cxx_call)
authorMark Mitchell <mark@codesourcery.com>
Thu, 24 Apr 2003 05:54:46 +0000 (05:54 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 24 Apr 2003 05:54:46 +0000 (05:54 +0000)
PR c++/10471
* call.c (build_cxx_call): Robustify.

PR c++/10471
* g++.dg/template/defarg2.C: New test.

From-SVN: r66032

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

index 13d2c54..37955be 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10471
+       * call.c (build_cxx_call): Robustify.
+
 2003-04-23  Neil Booth  <neil@daikokuya.co.uk>
 
        * Make-lang.in (lex.o): Remove mbchar.h.
index f7253d5..200aae7 100644 (file)
@@ -4737,7 +4737,9 @@ build_cxx_call(tree fn, tree args, tree converted_args)
 
   /* If this call might throw an exception, note that fact.  */
   fndecl = get_callee_fndecl (fn);
-  if ((!fndecl || !TREE_NOTHROW (fndecl)) && at_function_scope_p ())
+  if ((!fndecl || !TREE_NOTHROW (fndecl)) 
+      && at_function_scope_p ()
+      && cfun)
     cp_function_chain->can_throw = 1;
 
   /* Some built-in function calls will be evaluated at compile-time in
index 5a90c05..3195c2f 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10471
+       * g++.dg/template/defarg2.C: New test.
+
 2003-04-23  Neil Booth  <neil@daikokuya.co.uk>
 
        * gcc.dg/cpp/include2.c: Update.
diff --git a/gcc/testsuite/g++.dg/template/defarg2.C b/gcc/testsuite/g++.dg/template/defarg2.C
new file mode 100644 (file)
index 0000000..3670389
--- /dev/null
@@ -0,0 +1,10 @@
+struct X {
+    X ();
+};
+
+template <int> struct O {
+    struct I {
+        I (const X & = X());
+    };
+};
+template struct O<2>;