* [PATCH]: Cast in c-pretty-print.c causes warning
@ 2009-08-31 20:34 Kai Tietz
2009-09-02 19:03 ` Gabriel Dos Reis
0 siblings, 1 reply; 16+ messages in thread
From: Kai Tietz @ 2009-08-31 20:34 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
Hi,
In general it is bad to use size_t to cast point to scalar, but here
in c-pretty-print.c is looks ok, as the scalar is truncated to an
unsigned int type here and just the lowest 16-bit are in fact used.
So here the patch for it
ChangeLog
2009-08-31 Kai Tietz <kai.tietz@onevision.com>
* c-pretty-print.c (pp_c_tree_decl_identifier): Use size_t instead of
'unsigned long' to cast a pointer to scalar.
Tested for i686-pc-mingw32 and x86_64-pc-mingw32. Ok for apply?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: cprettyprint.diff --]
[-- Type: application/octet-stream, Size: 478 bytes --]
Index: gcc/gcc/c-pretty-print.c
===================================================================
--- gcc.orig/gcc/c-pretty-print.c 2009-05-16 11:49:04.000000000 +0200
+++ gcc/gcc/c-pretty-print.c 2009-08-31 20:08:35.766267700 +0200
@@ -2235,7 +2235,7 @@
else
{
static char xname[8];
- sprintf (xname, "<U%4x>", ((unsigned)((unsigned long)(t) & 0xffff)));
+ sprintf (xname, "<U%4x>", ((unsigned)((size_t)(t) & 0xffff)));
name = xname;
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-08-31 20:34 [PATCH]: Cast in c-pretty-print.c causes warning Kai Tietz
@ 2009-09-02 19:03 ` Gabriel Dos Reis
2009-09-02 19:50 ` Kai Tietz
0 siblings, 1 reply; 16+ messages in thread
From: Gabriel Dos Reis @ 2009-09-02 19:03 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
> Hi,
>
> In general it is bad to use size_t to cast point to scalar, but here
> in c-pretty-print.c is looks ok, as the scalar is truncated to an
> unsigned int type here and just the lowest 16-bit are in fact used.
> So here the patch for it
I'm not sure the 'size_t' trick makes the code clearer. In fact, I believe
we want uintptr_t -- but, in the form that OK with C90 compilers.
-- Gaby
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 19:03 ` Gabriel Dos Reis
@ 2009-09-02 19:50 ` Kai Tietz
2009-09-02 21:01 ` Richard Henderson
2009-09-02 21:18 ` Gabriel Dos Reis
0 siblings, 2 replies; 16+ messages in thread
From: Kai Tietz @ 2009-09-02 19:50 UTC (permalink / raw)
To: gdr; +Cc: GCC Patches
2009/9/2 Gabriel Dos Reis <dosreis@gmail.com>:
> On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>> Hi,
>>
>> In general it is bad to use size_t to cast point to scalar, but here
>> in c-pretty-print.c is looks ok, as the scalar is truncated to an
>> unsigned int type here and just the lowest 16-bit are in fact used.
>> So here the patch for it
>
> I'm not sure the 'size_t' trick makes the code clearer. In fact, I believe
> we want uintptr_t -- but, in the form that OK with C90 compilers.
>
> -- Gaby
>
Right, by this reason we use in w64 not the gnu stdint.h header. We
define uintptr_t/intptr_t/size_t etc with __extension__ to avoid those
warnings.
I can introduce here an new type __extension__ typedef __SIZE_TYPE__
c90_size_t;, if you prefer.
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 19:50 ` Kai Tietz
@ 2009-09-02 21:01 ` Richard Henderson
2009-09-02 21:06 ` Kai Tietz
2009-09-02 21:18 ` Gabriel Dos Reis
1 sibling, 1 reply; 16+ messages in thread
From: Richard Henderson @ 2009-09-02 21:01 UTC (permalink / raw)
To: Kai Tietz; +Cc: gdr, GCC Patches
On 09/02/2009 12:50 PM, Kai Tietz wrote:
> 2009/9/2 Gabriel Dos Reis<dosreis@gmail.com>:
>> On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>>> Hi,
>>>
>>> In general it is bad to use size_t to cast point to scalar, but here
>>> in c-pretty-print.c is looks ok, as the scalar is truncated to an
>>> unsigned int type here and just the lowest 16-bit are in fact used.
>>> So here the patch for it
>>
>> I'm not sure the 'size_t' trick makes the code clearer. In fact, I believe
>> we want uintptr_t -- but, in the form that OK with C90 compilers.
>>
> Right, by this reason we use in w64 not the gnu stdint.h header.
I think you've lost the plot. The gnu stdint.h header should
have the correct definition of uintptr_t even for w64. If not,
then that's what should be fixed.
> We
> define uintptr_t/intptr_t/size_t etc with __extension__ to avoid those
> warnings.
> I can introduce here an new type __extension__ typedef __SIZE_TYPE__
> c90_size_t;, if you prefer.
Huh?!? What exactly do you think __extension__ will accomplish?
r~
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 21:01 ` Richard Henderson
@ 2009-09-02 21:06 ` Kai Tietz
0 siblings, 0 replies; 16+ messages in thread
From: Kai Tietz @ 2009-09-02 21:06 UTC (permalink / raw)
To: Richard Henderson; +Cc: gdr, GCC Patches
2009/9/2 Richard Henderson <rth@redhat.com>:
> On 09/02/2009 12:50 PM, Kai Tietz wrote:
>>
>> 2009/9/2 Gabriel Dos Reis<dosreis@gmail.com>:
>>>
>>> On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> In general it is bad to use size_t to cast point to scalar, but here
>>>> in c-pretty-print.c is looks ok, as the scalar is truncated to an
>>>> unsigned int type here and just the lowest 16-bit are in fact used.
>>>> So here the patch for it
>>>
>>> I'm not sure the 'size_t' trick makes the code clearer. In fact, I
>>> believe
>>> we want uintptr_t -- but, in the form that OK with C90 compilers.
>>>
>> Right, by this reason we use in w64 not the gnu stdint.h header.
>
> I think you've lost the plot. The gnu stdint.h header should
> have the correct definition of uintptr_t even for w64. If not,
> then that's what should be fixed.
>
>> We
>> define uintptr_t/intptr_t/size_t etc with __extension__ to avoid those
>> warnings.
>> I can introduce here an new type __extension__ typedef __SIZE_TYPE__
>> c90_size_t;, if you prefer.
>
> Huh?!? What exactly do you think __extension__ will accomplish?
>
>
> r~
>
Well, I meant here stddef.h file too btw. If you try to use long long
in C90, you will get warnings. By using __extension__ you can avoid
them.
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 19:50 ` Kai Tietz
2009-09-02 21:01 ` Richard Henderson
@ 2009-09-02 21:18 ` Gabriel Dos Reis
2009-09-02 21:21 ` Kai Tietz
1 sibling, 1 reply; 16+ messages in thread
From: Gabriel Dos Reis @ 2009-09-02 21:18 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Wed, Sep 2, 2009 at 2:50 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
> 2009/9/2 Gabriel Dos Reis <dosreis@gmail.com>:
>> On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>>> Hi,
>>>
>>> In general it is bad to use size_t to cast point to scalar, but here
>>> in c-pretty-print.c is looks ok, as the scalar is truncated to an
>>> unsigned int type here and just the lowest 16-bit are in fact used.
>>> So here the patch for it
>>
>> I'm not sure the 'size_t' trick makes the code clearer. In fact, I believe
>> we want uintptr_t -- but, in the form that OK with C90 compilers.
>>
>> -- Gaby
>>
>
> Right, by this reason we use in w64 not the gnu stdint.h header. We
> define uintptr_t/intptr_t/size_t etc with __extension__ to avoid those
> warnings.
> I can introduce here an new type __extension__ typedef __SIZE_TYPE__
> c90_size_t;, if you prefer.
c-pretty-print.c is built in the first stage, so you cannot use
unconditional gnu extensions.
also we want uintptr_t (or equivalent for C90 compilers); but I would not use
size_t directly.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 21:18 ` Gabriel Dos Reis
@ 2009-09-02 21:21 ` Kai Tietz
2009-09-02 22:17 ` Richard Henderson
0 siblings, 1 reply; 16+ messages in thread
From: Kai Tietz @ 2009-09-02 21:21 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: GCC Patches
2009/9/2 Gabriel Dos Reis <gdr@integrable-solutions.net>:
> On Wed, Sep 2, 2009 at 2:50 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>> 2009/9/2 Gabriel Dos Reis <dosreis@gmail.com>:
>>> On Mon, Aug 31, 2009 at 1:13 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>>>> Hi,
>>>>
>>>> In general it is bad to use size_t to cast point to scalar, but here
>>>> in c-pretty-print.c is looks ok, as the scalar is truncated to an
>>>> unsigned int type here and just the lowest 16-bit are in fact used.
>>>> So here the patch for it
>>>
>>> I'm not sure the 'size_t' trick makes the code clearer. In fact, I believe
>>> we want uintptr_t -- but, in the form that OK with C90 compilers.
>>>
>>> -- Gaby
>>>
>>
>> Right, by this reason we use in w64 not the gnu stdint.h header. We
>> define uintptr_t/intptr_t/size_t etc with __extension__ to avoid those
>> warnings.
>> I can introduce here an new type __extension__ typedef __SIZE_TYPE__
>> c90_size_t;, if you prefer.
>
> c-pretty-print.c is built in the first stage, so you cannot use
> unconditional gnu extensions.
> also we want uintptr_t (or equivalent for C90 compilers); but I would not use
> size_t directly.
>
Ok, I can file a patch to add gstdint.h to system.h, or is it better
to use here just a config.h check for existing stdint.h and otherwise
fall back to long type for intptr_t?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 21:21 ` Kai Tietz
@ 2009-09-02 22:17 ` Richard Henderson
2009-09-03 10:52 ` Richard Guenther
0 siblings, 1 reply; 16+ messages in thread
From: Richard Henderson @ 2009-09-02 22:17 UTC (permalink / raw)
To: Kai Tietz; +Cc: Gabriel Dos Reis, GCC Patches
On 09/02/2009 02:21 PM, Kai Tietz wrote:
> Ok, I can file a patch to add gstdint.h to system.h, or is it better
> to use here just a config.h check for existing stdint.h and otherwise
> fall back to long type for intptr_t?
It's best to have a configure check.
See the standard autoconf macro AC_TYPE_UINTPTR_T.
r~
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-02 22:17 ` Richard Henderson
@ 2009-09-03 10:52 ` Richard Guenther
2009-09-03 13:30 ` Kai Tietz
0 siblings, 1 reply; 16+ messages in thread
From: Richard Guenther @ 2009-09-03 10:52 UTC (permalink / raw)
To: Richard Henderson; +Cc: Kai Tietz, Gabriel Dos Reis, GCC Patches
On Thu, Sep 3, 2009 at 12:17 AM, Richard Henderson<rth@redhat.com> wrote:
> On 09/02/2009 02:21 PM, Kai Tietz wrote:
>>
>> Ok, I can file a patch to add gstdint.h to system.h, or is it better
>> to use here just a config.h check for existing stdint.h and otherwise
>> fall back to long type for intptr_t?
>
> It's best to have a configure check.
> See the standard autoconf macro AC_TYPE_UINTPTR_T.
The LTO branch also makes use of uintptr_t and adds
AC_CHECK_TYPE(intptr_t, long)
which is obviously wrong for LLP64 hosts ;) But see config/stdint.m4
and config/stdint_h.m4.
Richard.
>
> r~
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 10:52 ` Richard Guenther
@ 2009-09-03 13:30 ` Kai Tietz
2009-09-03 13:52 ` Richard Guenther
0 siblings, 1 reply; 16+ messages in thread
From: Kai Tietz @ 2009-09-03 13:30 UTC (permalink / raw)
To: Richard Guenther; +Cc: Richard Henderson, Gabriel Dos Reis, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]
2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, Sep 3, 2009 at 12:17 AM, Richard Henderson<rth@redhat.com> wrote:
>> On 09/02/2009 02:21 PM, Kai Tietz wrote:
>>>
>>> Ok, I can file a patch to add gstdint.h to system.h, or is it better
>>> to use here just a config.h check for existing stdint.h and otherwise
>>> fall back to long type for intptr_t?
>>
>> It's best to have a configure check.
>> See the standard autoconf macro AC_TYPE_UINTPTR_T.
>
> The LTO branch also makes use of uintptr_t and adds
>
> AC_CHECK_TYPE(intptr_t, long)
>
> which is obviously wrong for LLP64 hosts ;) But see config/stdint.m4
> and config/stdint_h.m4.
>
> Richard.
So here is the revised patch using gstdint.h. Seems to work nice AFAIT.
ChangeLog
2009-09-03 Kai Tietz <kai.tietz@onevision.com>
* config.in (HAVE_STDINT_H): New.
* configure.ac (AC_CHECK_HEADERS): Add stdint.h check.
(GCC_HEADER_STDINT): Generated gstdint.h.
* configure: Regenerated.
* system.h (gstdint.h): Add include.
* Makefile.in (aclocal): Add config/stdint.m4.
* aclocal.m4: Regenerated.
Tested for x86_64-pc-linux, i686-pc-mingw32, and x86_64-w64-mingw32.
Ok for apply?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: stdint.diff --]
[-- Type: text/x-diff, Size: 2709 bytes --]
Index: gcc/gcc/config.in
===================================================================
--- gcc.orig/gcc/config.in 2009-08-24 08:11:35.000000000 +0200
+++ gcc/gcc/config.in 2009-09-03 14:52:19.123369700 +0200
@@ -1144,6 +1144,9 @@
#undef HAVE_MALLOC_H
#endif
+#ifndef USED_FOR_TARGET
+#undef HAVE_STDINT_H
+#endif
/* Define to 1 if you have the `mbstowcs' function. */
#ifndef USED_FOR_TARGET
Index: gcc/gcc/configure.ac
===================================================================
--- gcc.orig/gcc/configure.ac 2009-08-28 21:28:51.000000000 +0200
+++ gcc/gcc/configure.ac 2009-09-03 14:51:35.217369700 +0200
@@ -933,12 +933,15 @@
AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
sys/resource.h sys/param.h sys/times.h sys/stat.h \
- direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
+ direct.h malloc.h stdint.h langinfo.h ldfcn.h \
+ locale.h wchar.h)
# Check for thread headers.
AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
+GCC_HEADER_STDINT(gstdint.h)
+
# These tests can't be done till we know if we have limits.h.
gcc_AC_C_CHAR_BIT
AC_C_BIGENDIAN
Index: gcc/gcc/system.h
===================================================================
--- gcc.orig/gcc/system.h 2009-08-27 15:04:09.000000000 +0200
+++ gcc/gcc/system.h 2009-09-03 14:52:38.046369700 +0200
@@ -414,6 +414,8 @@
extern void *realloc (void *, size_t);
#endif
+#include "gstdint.h"
+
/* If the system doesn't provide strsignal, we get it defined in
libiberty but no declaration is supplied. */
#if !defined (HAVE_STRSIGNAL) \
Index: gcc/gcc/Makefile.in
===================================================================
--- gcc.orig/gcc/Makefile.in 2009-09-02 23:52:30.000000000 +0200
+++ gcc/gcc/Makefile.in 2009-09-03 13:40:53.469369700 +0200
@@ -1621,6 +1621,7 @@
$(srcdir)/../config/lib-prefix.m4 \
$(srcdir)/../config/override.m4 \
$(srcdir)/../config/progtest.m4 \
+ $(srcdir)/../config/stdint.m4 \
$(srcdir)/../config/unwind_ipinfo.m4 \
$(srcdir)/../config/warnings.m4 \
$(srcdir)/acinclude.m4
Index: gcc/gcc/aclocal.m4
===================================================================
--- gcc.orig/gcc/aclocal.m4 2009-09-03 01:31:07.000000000 +0200
+++ gcc/gcc/aclocal.m4 2009-09-03 13:36:54.565369700 +0200
@@ -114,6 +114,7 @@
m4_include([../config/lib-prefix.m4])
m4_include([../config/override.m4])
m4_include([../config/progtest.m4])
+m4_include([../config/stdint.m4])
m4_include([../config/unwind_ipinfo.m4])
m4_include([../config/warnings.m4])
m4_include([acinclude.m4])
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 13:30 ` Kai Tietz
@ 2009-09-03 13:52 ` Richard Guenther
2009-09-03 14:09 ` Kai Tietz
0 siblings, 1 reply; 16+ messages in thread
From: Richard Guenther @ 2009-09-03 13:52 UTC (permalink / raw)
To: Kai Tietz; +Cc: Richard Henderson, Gabriel Dos Reis, GCC Patches
On Thu, Sep 3, 2009 at 3:30 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
> 2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
>> On Thu, Sep 3, 2009 at 12:17 AM, Richard Henderson<rth@redhat.com> wrote:
>>> On 09/02/2009 02:21 PM, Kai Tietz wrote:
>>>>
>>>> Ok, I can file a patch to add gstdint.h to system.h, or is it better
>>>> to use here just a config.h check for existing stdint.h and otherwise
>>>> fall back to long type for intptr_t?
>>>
>>> It's best to have a configure check.
>>> See the standard autoconf macro AC_TYPE_UINTPTR_T.
>>
>> The LTO branch also makes use of uintptr_t and adds
>>
>> AC_CHECK_TYPE(intptr_t, long)
>>
>> which is obviously wrong for LLP64 hosts ;) But see config/stdint.m4
>> and config/stdint_h.m4.
>>
>> Richard.
>
> So here is the revised patch using gstdint.h. Seems to work nice AFAIT.
The check fro stdint.h is redundant I believe, thus
AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
sys/resource.h sys/param.h sys/times.h sys/stat.h \
- direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
+ direct.h malloc.h stdint.h langinfo.h ldfcn.h \
+ locale.h wchar.h)
can be omitted.
The rest of the patch looks fine though I cannot approve it.
Thanks,
Richard.
> ChangeLog
>
> 2009-09-03 Kai Tietz <kai.tietz@onevision.com>
>
> * config.in (HAVE_STDINT_H): New.
> * configure.ac (AC_CHECK_HEADERS): Add stdint.h check.
> (GCC_HEADER_STDINT): Generated gstdint.h.
> * configure: Regenerated.
> * system.h (gstdint.h): Add include.
> * Makefile.in (aclocal): Add config/stdint.m4.
> * aclocal.m4: Regenerated.
>
> Tested for x86_64-pc-linux, i686-pc-mingw32, and x86_64-w64-mingw32.
> Ok for apply?
>
> Cheers,
> Kai
>
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 13:52 ` Richard Guenther
@ 2009-09-03 14:09 ` Kai Tietz
2009-09-03 14:11 ` Richard Henderson
2009-09-04 2:12 ` Gabriel Dos Reis
0 siblings, 2 replies; 16+ messages in thread
From: Kai Tietz @ 2009-09-03 14:09 UTC (permalink / raw)
To: Richard Guenther; +Cc: Richard Henderson, Gabriel Dos Reis, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]
2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, Sep 3, 2009 at 3:30 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>> 2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
>>> On Thu, Sep 3, 2009 at 12:17 AM, Richard Henderson<rth@redhat.com> wrote:
>>>> On 09/02/2009 02:21 PM, Kai Tietz wrote:
>>>>>
>>>>> Ok, I can file a patch to add gstdint.h to system.h, or is it better
>>>>> to use here just a config.h check for existing stdint.h and otherwise
>>>>> fall back to long type for intptr_t?
>>>>
>>>> It's best to have a configure check.
>>>> See the standard autoconf macro AC_TYPE_UINTPTR_T.
>>>
>>> The LTO branch also makes use of uintptr_t and adds
>>>
>>> AC_CHECK_TYPE(intptr_t, long)
>>>
>>> which is obviously wrong for LLP64 hosts ;) But see config/stdint.m4
>>> and config/stdint_h.m4.
>>>
>>> Richard.
>>
>> So here is the revised patch using gstdint.h. Seems to work nice AFAIT.
>
> The check fro stdint.h is redundant I believe, thus
>
> AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
> fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
> sys/resource.h sys/param.h sys/times.h sys/stat.h \
> - direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
> + direct.h malloc.h stdint.h langinfo.h ldfcn.h \
> + locale.h wchar.h)
>
> can be omitted.
>
> The rest of the patch looks fine though I cannot approve it.
>
> Thanks,
> Richard.
Thanks for point to this. Indeed it is not necessary to add stdint.h
check in AC_HEADERS.
Here the adjusted patch
2009-09-03 Kai Tietz <kai.tietz@onevision.com>
* config.in (HAVE_STDINT_H): New.
* configure.ac (GCC_HEADER_STDINT): Generated gstdint.h.
* configure: Regenerated.
* system.h (gstdint.h): Add include.
* Makefile.in (aclocal): Add config/stdint.m4.
* aclocal.m4: Regenerated.
Ok for apply to trunk?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: stdint.diff --]
[-- Type: text/x-diff, Size: 2350 bytes --]
Index: gcc/gcc/config.in
===================================================================
--- gcc.orig/gcc/config.in 2009-08-24 08:11:35.000000000 +0200
+++ gcc/gcc/config.in 2009-09-03 14:52:19.123369700 +0200
@@ -1144,6 +1144,9 @@
#undef HAVE_MALLOC_H
#endif
+#ifndef USED_FOR_TARGET
+#undef HAVE_STDINT_H
+#endif
/* Define to 1 if you have the `mbstowcs' function. */
#ifndef USED_FOR_TARGET
Index: gcc/gcc/configure.ac
===================================================================
--- gcc.orig/gcc/configure.ac 2009-08-28 21:28:51.000000000 +0200
+++ gcc/gcc/configure.ac 2009-09-03 15:58:19.281369700 +0200
@@ -939,6 +939,8 @@
AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
+GCC_HEADER_STDINT(gstdint.h)
+
# These tests can't be done till we know if we have limits.h.
gcc_AC_C_CHAR_BIT
AC_C_BIGENDIAN
Index: gcc/gcc/system.h
===================================================================
--- gcc.orig/gcc/system.h 2009-08-27 15:04:09.000000000 +0200
+++ gcc/gcc/system.h 2009-09-03 14:52:38.046369700 +0200
@@ -414,6 +414,8 @@
extern void *realloc (void *, size_t);
#endif
+#include "gstdint.h"
+
/* If the system doesn't provide strsignal, we get it defined in
libiberty but no declaration is supplied. */
#if !defined (HAVE_STRSIGNAL) \
Index: gcc/gcc/Makefile.in
===================================================================
--- gcc.orig/gcc/Makefile.in 2009-09-02 23:52:30.000000000 +0200
+++ gcc/gcc/Makefile.in 2009-09-03 13:40:53.469369700 +0200
@@ -1621,6 +1621,7 @@
$(srcdir)/../config/lib-prefix.m4 \
$(srcdir)/../config/override.m4 \
$(srcdir)/../config/progtest.m4 \
+ $(srcdir)/../config/stdint.m4 \
$(srcdir)/../config/unwind_ipinfo.m4 \
$(srcdir)/../config/warnings.m4 \
$(srcdir)/acinclude.m4
Index: gcc/gcc/aclocal.m4
===================================================================
--- gcc.orig/gcc/aclocal.m4 2009-09-03 01:31:07.000000000 +0200
+++ gcc/gcc/aclocal.m4 2009-09-03 13:36:54.565369700 +0200
@@ -114,6 +114,7 @@
m4_include([../config/lib-prefix.m4])
m4_include([../config/override.m4])
m4_include([../config/progtest.m4])
+m4_include([../config/stdint.m4])
m4_include([../config/unwind_ipinfo.m4])
m4_include([../config/warnings.m4])
m4_include([acinclude.m4])
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 14:09 ` Kai Tietz
@ 2009-09-03 14:11 ` Richard Henderson
2009-09-03 14:19 ` Kai Tietz
2009-09-04 2:12 ` Gabriel Dos Reis
1 sibling, 1 reply; 16+ messages in thread
From: Richard Henderson @ 2009-09-03 14:11 UTC (permalink / raw)
To: Kai Tietz; +Cc: Richard Guenther, Gabriel Dos Reis, GCC Patches
On 09/03/2009 07:08 AM, Kai Tietz wrote:
> * config.in (HAVE_STDINT_H): New.
> * configure.ac (GCC_HEADER_STDINT): Generated gstdint.h.
> * configure: Regenerated.
> * system.h (gstdint.h): Add include.
> * Makefile.in (aclocal): Add config/stdint.m4.
> * aclocal.m4: Regenerated.
Ok.
r~
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 14:11 ` Richard Henderson
@ 2009-09-03 14:19 ` Kai Tietz
2009-09-03 15:59 ` Kai Tietz
0 siblings, 1 reply; 16+ messages in thread
From: Kai Tietz @ 2009-09-03 14:19 UTC (permalink / raw)
To: Richard Henderson; +Cc: Richard Guenther, Gabriel Dos Reis, GCC Patches
2009/9/3 Richard Henderson <rth@redhat.com>:
> On 09/03/2009 07:08 AM, Kai Tietz wrote:
>>
>> * config.in (HAVE_STDINT_H): New.
>> * configure.ac (GCC_HEADER_STDINT): Generated gstdint.h.
>> * configure: Regenerated.
>> * system.h (gstdint.h): Add include.
>> * Makefile.in (aclocal): Add config/stdint.m4.
>> * aclocal.m4: Regenerated.
>
> Ok.
>
>
> r~
>
Committed at revision 151379.
Thanks,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 14:19 ` Kai Tietz
@ 2009-09-03 15:59 ` Kai Tietz
0 siblings, 0 replies; 16+ messages in thread
From: Kai Tietz @ 2009-09-03 15:59 UTC (permalink / raw)
To: Richard Henderson; +Cc: Richard Guenther, Gabriel Dos Reis, GCC Patches
2009/9/3 Kai Tietz <ktietz70@googlemail.com>:
> 2009/9/3 Richard Henderson <rth@redhat.com>:
>> On 09/03/2009 07:08 AM, Kai Tietz wrote:
>>>
>>> * config.in (HAVE_STDINT_H): New.
>>> * configure.ac (GCC_HEADER_STDINT): Generated gstdint.h.
>>> * configure: Regenerated.
>>> * system.h (gstdint.h): Add include.
>>> * Makefile.in (aclocal): Add config/stdint.m4.
>>> * aclocal.m4: Regenerated.
>>
>> Ok.
>>
>>
>> r~
>>
>
> Committed at revision 151379.
>
> Thanks,
> Kai
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
Reverted patch due ada bootstrap failures on linux host.
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH]: Cast in c-pretty-print.c causes warning
2009-09-03 14:09 ` Kai Tietz
2009-09-03 14:11 ` Richard Henderson
@ 2009-09-04 2:12 ` Gabriel Dos Reis
1 sibling, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2009-09-04 2:12 UTC (permalink / raw)
To: Kai Tietz; +Cc: Richard Guenther, Richard Henderson, GCC Patches
On Thu, Sep 3, 2009 at 9:08 AM, Kai Tietz<ktietz70@googlemail.com> wrote:
> 2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
>> On Thu, Sep 3, 2009 at 3:30 PM, Kai Tietz<ktietz70@googlemail.com> wrote:
>>> 2009/9/3 Richard Guenther <richard.guenther@gmail.com>:
>>>> On Thu, Sep 3, 2009 at 12:17 AM, Richard Henderson<rth@redhat.com> wrote:
>>>>> On 09/02/2009 02:21 PM, Kai Tietz wrote:
>>>>>>
>>>>>> Ok, I can file a patch to add gstdint.h to system.h, or is it better
>>>>>> to use here just a config.h check for existing stdint.h and otherwise
>>>>>> fall back to long type for intptr_t?
>>>>>
>>>>> It's best to have a configure check.
>>>>> See the standard autoconf macro AC_TYPE_UINTPTR_T.
>>>>
>>>> The LTO branch also makes use of uintptr_t and adds
>>>>
>>>> AC_CHECK_TYPE(intptr_t, long)
>>>>
>>>> which is obviously wrong for LLP64 hosts ;) But see config/stdint.m4
>>>> and config/stdint_h.m4.
>>>>
>>>> Richard.
>>>
>>> So here is the revised patch using gstdint.h. Seems to work nice AFAIT.
>>
>> The check fro stdint.h is redundant I believe, thus
>>
>> AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
>> fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
>> sys/resource.h sys/param.h sys/times.h sys/stat.h \
>> - direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
>> + direct.h malloc.h stdint.h langinfo.h ldfcn.h \
>> + locale.h wchar.h)
>>
>> can be omitted.
>>
>> The rest of the patch looks fine though I cannot approve it.
>>
>> Thanks,
>> Richard.
>
> Thanks for point to this. Indeed it is not necessary to add stdint.h
> check in AC_HEADERS.
>
> Here the adjusted patch
>
> 2009-09-03 Kai Tietz <kai.tietz@onevision.com>
>
> * config.in (HAVE_STDINT_H): New.
> * configure.ac (GCC_HEADER_STDINT): Generated gstdint.h.
> * configure: Regenerated.
> * system.h (gstdint.h): Add include.
> * Makefile.in (aclocal): Add config/stdint.m4.
> * aclocal.m4: Regenerated.
>
> Ok for apply to trunk?
I do not see the corresponding hunk for c-pretty-print.c -- or is my mailer
playing tricks with me?
Where is what should happen
(1) check for uintptr_t; use it if available;
(2) otherwise; check for 'long long'; use it if available;
(3) otherwise; if 32-bit build; use 'unsigned long';
(4) otherwise; if 64-bit build, check for __int64 and use it;
otherwise moan. (this would happens only for curious w64-based builds).
You should introduce uintptr_t as a typedef for cases 2 through 4.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-09-04 2:12 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 20:34 [PATCH]: Cast in c-pretty-print.c causes warning Kai Tietz
2009-09-02 19:03 ` Gabriel Dos Reis
2009-09-02 19:50 ` Kai Tietz
2009-09-02 21:01 ` Richard Henderson
2009-09-02 21:06 ` Kai Tietz
2009-09-02 21:18 ` Gabriel Dos Reis
2009-09-02 21:21 ` Kai Tietz
2009-09-02 22:17 ` Richard Henderson
2009-09-03 10:52 ` Richard Guenther
2009-09-03 13:30 ` Kai Tietz
2009-09-03 13:52 ` Richard Guenther
2009-09-03 14:09 ` Kai Tietz
2009-09-03 14:11 ` Richard Henderson
2009-09-03 14:19 ` Kai Tietz
2009-09-03 15:59 ` Kai Tietz
2009-09-04 2:12 ` Gabriel Dos Reis
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).