public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix warning in tree-diagnostic.h.
@ 2015-11-02 13:27 Dominik Vogt
  2015-11-02 16:57 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2015-11-02 13:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ulrich Weigand, andreas

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

The attached patch fixes the annoying warnings generated by
diagnostic_set_last_function.

Can this be committed?

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 81 bytes --]

gcc/ChangeLog

	* tree-diagnostic.h (diagnostic_set_last_function): Fix warning.

[-- Attachment #3: 0001-Fix-warning-in-tree-diagnostic.h.patch --]
[-- Type: text/x-diff, Size: 1186 bytes --]

From b09e69bd66f157a2aaf0167b7419f47e9953950a Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Mon, 2 Nov 2015 13:58:53 +0100
Subject: [PATCH] Fix warning in tree-diagnostic.h.

---
 gcc/tree-diagnostic.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h
index c1cc1c5..60c6f1c 100644
--- a/gcc/tree-diagnostic.h
+++ b/gcc/tree-diagnostic.h
@@ -43,10 +43,13 @@ along with GCC; see the file COPYING3.  If not see
 /* Remember the current function as being the last one in which we report
    a diagnostic.  */
 #define diagnostic_set_last_function(DC, DI)		\
-  diagnostic_context_auxiliary_data (DC)		\
-    = (((DI) && diagnostic_abstract_origin (DI))	\
-       ? diagnostic_abstract_origin (DI)		\
-       : current_function_decl)
+  do {							\
+    __typeof__ (DI) __x = (DI);				\
+    diagnostic_context_auxiliary_data (DC)		\
+      = (((__x) && diagnostic_abstract_origin (__x))	\
+	 ? diagnostic_abstract_origin (__x)		\
+	 : current_function_decl);			\
+  } while (0)
 
 void diagnostic_report_current_function (diagnostic_context *,
 					 diagnostic_info *);
-- 
2.3.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix warning in tree-diagnostic.h.
  2015-11-02 13:27 [PATCH] Fix warning in tree-diagnostic.h Dominik Vogt
@ 2015-11-02 16:57 ` Jeff Law
  2015-11-03  9:57   ` Dominik Vogt
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2015-11-02 16:57 UTC (permalink / raw)
  To: gcc-patches, Ulrich Weigand, andreas

On 11/02/2015 06:26 AM, Dominik Vogt wrote:
> The attached patch fixes the annoying warnings generated by
> diagnostic_set_last_function.
>
> Can this be committed?
Can you point out what warning you're fixing?  Inline or pointer to a 
build log would be fine.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix warning in tree-diagnostic.h.
  2015-11-02 16:57 ` Jeff Law
@ 2015-11-03  9:57   ` Dominik Vogt
  2015-11-06 22:16     ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2015-11-03  9:57 UTC (permalink / raw)
  To: gcc-patches

On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote:
> On 11/02/2015 06:26 AM, Dominik Vogt wrote:
> >The attached patch fixes the annoying warnings generated by
> >diagnostic_set_last_function.
> Can you point out what warning you're fixing?

Sure.  toplec.c calls diagnostic_set_last_function with a NULL
pointer as the second argument, and cp/typeck.c complains about
it.  Ah, it seems the *current* version of Gcc does not generate
the warning, but the old one (4.8.5) I used to compile does.  So,
it may or may not be worth to apply the patch.

-- snip --
unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long \
-Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libc\
pp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace -o trans-mem.o -MT \
trans-mem.o -MMD -MP -MF ./.deps/trans-mem.TPo ../../gcc/trans-mem.c
In file included from ../../gcc/toplev.c:42:0:
../../gcc/toplev.c: In function â\200\230void announce_function(tree)â\200\231:
../../gcc/diagnostic.h:202:50: warning: invalid access to non-static data member â\200\230diagnostic_info::x_dataâ\200\231 of NULL object \
[-Winvalid-offsetof]
#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
^
../../gcc/tree-diagnostic.h:28:11: note: in expansion of macro â\200\230diagnostic_info_auxiliary_dataâ\200\231
((tree) diagnostic_info_auxiliary_data (DI))
^
../../gcc/tree-diagnostic.h:47:17: note: in expansion of macro â\200\230diagnostic_abstract_originâ\200\231
= (((DI) && diagnostic_abstract_origin (DI)) \
^
../../gcc/toplev.c:233:7: note: in expansion of macro â\200\230diagnostic_set_last_functionâ\200\231
diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
^
../../gcc/diagnostic.h:202:50: warning: (perhaps the â\200\230offsetofâ\200\231 macro was used incorrectly) [-Winvalid-offsetof]
#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
^
../../gcc/tree-diagnostic.h:28:11: note: in expansion of macro â\200\230diagnostic_info_auxiliary_dataâ\200\231
((tree) diagnostic_info_auxiliary_data (DI))
^
../../gcc/tree-diagnostic.h:47:17: note: in expansion of macro â\200\230diagnostic_abstract_originâ\200\231
= (((DI) && diagnostic_abstract_origin (DI)) \
^
../../gcc/toplev.c:233:7: note: in expansion of macro â\200\230diagnostic_set_last_functionâ\200\231
diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
^
../../gcc/diagnostic.h:202:50: warning: invalid access to non-static data member â\200\230diagnostic_info::x_dataâ\200\231 of NULL object \
[-Winvalid-offsetof]
#define diagnostic_info_auxiliary_data(DI) (DI)->x_data 
-- snip --

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix warning in tree-diagnostic.h.
  2015-11-03  9:57   ` Dominik Vogt
@ 2015-11-06 22:16     ` Jeff Law
  2015-11-17  9:02       ` Dominik Vogt
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2015-11-06 22:16 UTC (permalink / raw)
  To: gcc-patches

On 11/03/2015 02:57 AM, Dominik Vogt wrote:
> On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote:
>> On 11/02/2015 06:26 AM, Dominik Vogt wrote:
>>> The attached patch fixes the annoying warnings generated by
>>> diagnostic_set_last_function.
>> Can you point out what warning you're fixing?
>
> Sure.  toplec.c calls diagnostic_set_last_function with a NULL
> pointer as the second argument, and cp/typeck.c complains about
> it.  Ah, it seems the *current* version of Gcc does not generate
> the warning, but the old one (4.8.5) I used to compile does.  So,
> it may or may not be worth to apply the patch.
It looks like that was changed explicitly in 2014 (see the history of 
g++.dg/abi/offsetof.C).  I'm not a C++ expert, but it appears this kind 
of use is considered OK these days.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix warning in tree-diagnostic.h.
  2015-11-06 22:16     ` Jeff Law
@ 2015-11-17  9:02       ` Dominik Vogt
  0 siblings, 0 replies; 5+ messages in thread
From: Dominik Vogt @ 2015-11-17  9:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jeff Law

On Fri, Nov 06, 2015 at 03:16:37PM -0700, Jeff Law wrote:
> On 11/03/2015 02:57 AM, Dominik Vogt wrote:
> >On Mon, Nov 02, 2015 at 09:57:22AM -0700, Jeff Law wrote:
> >>On 11/02/2015 06:26 AM, Dominik Vogt wrote:
> >>>The attached patch fixes the annoying warnings generated by
> >>>diagnostic_set_last_function.
> >>Can you point out what warning you're fixing?
> >
> >Sure.  toplec.c calls diagnostic_set_last_function with a NULL
> >pointer as the second argument, and cp/typeck.c complains about
> >it.  Ah, it seems the *current* version of Gcc does not generate
> >the warning, but the old one (4.8.5) I used to compile does.  So,
> >it may or may not be worth to apply the patch.
> It looks like that was changed explicitly in 2014 (see the history
> of g++.dg/abi/offsetof.C).  I'm not a C++ expert, but it appears
> this kind of use is considered OK these days.

All right, if this is the case it's not worth "fixing".  I'll keep
ignoring gcc-4.8's message.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-17  9:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 13:27 [PATCH] Fix warning in tree-diagnostic.h Dominik Vogt
2015-11-02 16:57 ` Jeff Law
2015-11-03  9:57   ` Dominik Vogt
2015-11-06 22:16     ` Jeff Law
2015-11-17  9:02       ` Dominik Vogt

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