------- Comment #3 from spark at gcc dot gnu dot org  2007-03-13 22:57 -------
This is somewhat complicated. 
The extra type cast causes
different code paths to be taken.
In particular, in finish_call_expr() in cp/semantics.c:

  if (processing_template_decl)
    {
      if (type_dependent_expression_p (fn)
          || any_type_dependent_arguments_p (args))
        {
          result = build_nt_call_list (fn, args);
          KOENIG_LOOKUP_P (result) = koenig_p;
          return result;
        }
      if (!BASELINK_P (fn)
          && TREE_CODE (fn) != PSEUDO_DTOR_EXPR
          && TREE_TYPE (fn) != unknown_type_node)
        fn = build_non_dependent_expr (fn);
      args = build_non_dependent_args (orig_args);



With the type cast, 
build_over_call() is called eventually
which checks TREE_THIS_VOLATILE() for the callee function decl
and mark the current function (i.e. caller A::g) as returns_abnormally.
The lack of the type cast triggers
any_type_dependent_arguments_p(args) above,
leading to build_nt_call_list() which doesn't do this marking
of the returns_abnormally.

Now, not being familiar with the c++ frontend,
I'm not sure where exactly we should do the checking
of TREE_THIS_VOLATILE() for the callee decl.

The following patch seems to fix the problem 
(though I can't even tell whether this is the right approach):

diff -r 15a559a8fcf0 gcc/cp/semantics.c
--- a/gcc/cp/semantics.c        Mon Mar 12 15:38:22 2007 -0700
+++ b/gcc/cp/semantics.c        Tue Mar 13 15:48:45 2007 -0700
@@ -1816,6 +1816,10 @@ finish_call_expr (tree fn, tree args, bo
          || any_type_dependent_arguments_p (args))
        {
          result = build_nt_call_list (fn, args);
+
+         if (fn && TREE_THIS_VOLATILE (fn) && cfun)
+           current_function_returns_abnormally = 1;
+
          KOENIG_LOOKUP_P (result) = koenig_p;
          return result;
        }


-- 

spark at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spark at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30988

Reply via email to