public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "spark at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/30988] [4.1/4.2/4.3 Regression] Incorrect "no return statement" warning with __attribute__ ((noreturn)) and __FUNCTION__
Date: Tue, 13 Mar 2007 22:57:00 -0000	[thread overview]
Message-ID: <20070313225726.15861.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30988-12477@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2007-03-13 22:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-27 22:19 [Bug c++/30988] New: " irving at cs dot stanford dot edu
2007-02-28  0:26 ` [Bug c++/30988] " pinskia at gcc dot gnu dot org
2007-03-03 21:50 ` [Bug c++/30988] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-03-05  4:11 ` mmitchel at gcc dot gnu dot org
2007-03-13 22:57 ` spark at gcc dot gnu dot org [this message]
2007-11-17 12:34 ` jakub at gcc dot gnu dot org
2007-11-17 12:36 ` jakub at gcc dot gnu dot org
2007-11-18 22:21 ` [Bug c++/30988] [4.1/4.2 " jakub at gcc dot gnu dot org
2007-11-18 22:21 ` [Bug c++/30988] [4.1/4.2/4.3 " jakub at gcc dot gnu dot org
2008-07-04 22:00 ` [Bug c++/30988] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 21:40 ` jsm28 at gcc dot gnu dot org
2009-03-30 21:43 ` irving at naml dot us

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070313225726.15861.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).