public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/24985] caret diagnostics
Date: Sat, 07 Apr 2012 12:55:00 -0000	[thread overview]
Message-ID: <bug-24985-4-794KdUAqTC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-24985-4@http.gcc.gnu.org/bugzilla/>

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu.org

--- Comment #26 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-07 12:53:34 UTC ---
A sneak-peek into the future ;-)

manuel@gcc12:~/test2/186200M/build/gcc$ ./cc1 -ftrack-macro-expansion
~/macro-clang.c 
 foo
/home/manuel/macro-clang.c: In function ‘foo’:
/home/manuel/macro-clang.c:2:94: error: invalid operands to binary < (have
‘struct mystruct’ and ‘float’)
 #define MYMAX(A,B)    __extension__ ({ __typeof__(A) __a = (A); __typeof__(B)
__b = (B); __a < __b ? __b : __a; })
                                                                               
              ^
/home/manuel/macro-clang.c:2:94: note: in expansion of macro 'MYMAX'
 #define MYMAX(A,B)    __extension__ ({ __typeof__(A) __a = (A); __typeof__(B)
__b = (B); __a < __b ? __b : __a; })
                                                                               
              ^
/home/manuel/macro-clang.c:8:11: note: expanded from here
 float x = MYMAX(p, f);
           ^

This is not possible with the patch just posted, but I will send this follow up
after the initial part is committed. Of course, it needs some fine-tuning to
avoid repetitions, but this is a problem with the locations given by the macro
expansion unwinder, which, in my opinion, doesn't give the best location for
each message and already produces repetitions. See:

/home/manuel/macro-caret.c: In function ‘g’:
/home/manuel/macro-caret.c:5:14: error: invalid operands to binary << (have
‘double’ and ‘int’)
   OPERATE (A,<<,B)
              ^
/home/manuel/macro-caret.c:2:9: note: in expansion of macro 'OPERATE'
   OPRD1 OPRT OPRD2;
         ^
/home/manuel/macro-caret.c:5:3: note: expanded from here
   OPERATE (A,<<,B)
   ^
/home/manuel/macro-caret.c:5:14: note: in expansion of macro 'SHIFTL'
   OPERATE (A,<<,B)
              ^
/home/manuel/macro-caret.c:8:3: note: expanded from here
   SHIFTL (A,1)
   ^
/home/manuel/macro-caret.c:8:3: note: in expansion of macro 'MULT'
   SHIFTL (A,1)
   ^
/home/manuel/macro-caret.c:13:3: note: expanded from here
   MULT (1.0);// 1.0 << 1; <-- so this is an error.
   ^


Another possibility could be to print the preprocessed string when saying "in
expansion". However, I am not sure how hard it will be to obtain the
preprocessed string (or to re-create it at runtime). Help and pointers on how
to achieve that are welcome.

Dodji, are you planning to propose to enable -ftrack-macro-expansion by default
in GCC 4.8?


  parent reply	other threads:[~2012-04-07 12:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-24985-4@http.gcc.gnu.org/bugzilla/>
2012-03-21 12:06 ` manu at gcc dot gnu.org
2012-04-04 15:28 ` manu at gcc dot gnu.org
2012-04-04 15:32 ` manu at gcc dot gnu.org
2012-04-04 15:50 ` paolo.carlini at oracle dot com
2012-04-04 18:49 ` jason at gcc dot gnu.org
2012-04-04 18:53 ` manu at gcc dot gnu.org
2012-04-04 19:20 ` jason at gcc dot gnu.org
2012-04-05 12:14 ` manu at gcc dot gnu.org
2012-04-05 17:02 ` jason at gcc dot gnu.org
2012-04-05 22:06 ` manu at gcc dot gnu.org
2012-04-05 22:10 ` manu at gcc dot gnu.org
2012-04-07 12:55 ` manu at gcc dot gnu.org [this message]
2012-04-09 16:07 ` dodji at seketeli dot org
2012-04-09 16:20 ` dodji at seketeli dot org
2012-04-11  9:28 ` manu at gcc dot gnu.org
2012-04-11  9:53 ` manu at gcc dot gnu.org
2012-04-12 21:45 ` jason at gcc dot gnu.org
2012-04-12 21:59 ` manu at gcc dot gnu.org
2012-04-13  2:26 ` paolo.carlini at oracle dot com
2012-04-13  9:57 ` rguenth at gcc dot gnu.org
2012-04-13 10:59 ` manu at gcc dot gnu.org
2012-04-13 11:35 ` rguenth at gcc dot gnu.org
2012-04-13 11:52 ` redi at gcc dot gnu.org
2012-04-13 11:54 ` redi at gcc dot gnu.org
2012-04-13 11:56 ` manu at gcc dot gnu.org
2012-04-13 11:59 ` manu at gcc dot gnu.org
2012-04-13 12:09 ` rguenth at gcc dot gnu.org
2012-04-13 12:09 ` redi at gcc dot gnu.org
2012-04-13 12:16 ` manu at gcc dot gnu.org
2012-04-13 12:19 ` manu at gcc dot gnu.org
2012-04-13 12:24 ` redi at gcc dot gnu.org
2012-04-13 12:32 ` manu at gcc dot gnu.org
2012-04-13 19:06 ` jason at gcc dot gnu.org
2012-04-13 19:41 ` manu at gcc dot gnu.org
2012-04-13 22:59 ` manu at gcc dot gnu.org
2012-04-14 10:54 ` manu at gcc dot gnu.org
2012-04-22 16:36 ` manu at gcc dot gnu.org
2012-05-04  0:33 ` manu at gcc dot gnu.org
2012-05-13 22:38 ` manu at gcc dot gnu.org
2005-11-22  4:01 [Bug c++/24985] New: Line info in diagnostics is very unfriendly igodard at pacbell dot net
2008-07-22  9:50 ` [Bug c++/24985] caret diagnostics manu at gcc dot gnu dot org
2009-07-02 23:50 ` manu at gcc dot gnu dot org
2009-07-02 23:55 ` paolo dot carlini at oracle dot com
2009-07-03  0:26 ` manu at gcc dot gnu dot org
2009-07-03  0:38 ` paolo dot carlini at oracle dot com
2009-07-03 11:04 ` dave at treblig dot org
2009-10-07 16:57 ` bkoz at gcc dot gnu dot org
2009-10-07 17:07 ` manu at gcc dot gnu dot org
2009-10-07 18:32 ` jason at gcc dot gnu dot org
2009-10-07 21:26 ` manu at gcc dot gnu dot org
2009-10-15 17:34 ` bkoz at gcc dot gnu dot org
2009-10-15 18:51 ` manu at gcc dot gnu dot org

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=bug-24985-4-794KdUAqTC@http.gcc.gnu.org/bugzilla/ \
    --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).