* [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c)
@ 2008-06-24 5:23 Laurynas Biveinis
2008-06-24 11:16 ` Joseph S. Myers
0 siblings, 1 reply; 4+ messages in thread
From: Laurynas Biveinis @ 2008-06-24 5:23 UTC (permalink / raw)
To: gcc-patches
Another little patch in the valgrind on testsuite series.
To set unsignedp value, lex_charconst calls cpp_interpret_charconst.
Here it quits early with an error, leaving unsignedp uninitialized.
Fixed by checking error code and initializing unsignedp.
Bootstrapped/regtested x86_64-unknown-linux-gnu. OK for trunk?
2008-06-24 Laurynas Biveinis <laurynas.biveinis@gmail.com>
PR c/34867
* c-lex.c (lex_charconst): Set unsignedp value if
cpp_interpret_charconst call failed.
Index: gcc/c-lex.c
===================================================================
--- gcc/c-lex.c (revision 137030)
+++ gcc/c-lex.c (working copy)
@@ -981,6 +981,8 @@
result = cpp_interpret_charconst (parse_in, token,
&chars_seen, &unsignedp);
+ if (!result)
+ unsignedp = true;
if (token->type == CPP_WCHAR)
type = wchar_type_node;
--
Laurynas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c)
2008-06-24 5:23 [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c) Laurynas Biveinis
@ 2008-06-24 11:16 ` Joseph S. Myers
2008-06-27 11:24 ` Laurynas Biveinis
0 siblings, 1 reply; 4+ messages in thread
From: Joseph S. Myers @ 2008-06-24 11:16 UTC (permalink / raw)
To: Laurynas Biveinis; +Cc: gcc-patches
On Tue, 24 Jun 2008, Laurynas Biveinis wrote:
> Another little patch in the valgrind on testsuite series.
>
> To set unsignedp value, lex_charconst calls cpp_interpret_charconst.
> Here it quits early with an error, leaving unsignedp uninitialized.
> Fixed by checking error code and initializing unsignedp.
> Bootstrapped/regtested x86_64-unknown-linux-gnu. OK for trunk?
0 is not just an error return here, as far as I can tell it can also be a
valid return value in a non-error case. It just so happens that the value
of unsignedp doesn't matter if the return is 0, because it's only used in
"unsignedp || (cppchar_signed_t) result >= 0". I think it would be better
just to initialize unsignedp when declared (unconditionally), before
calling cpp_interpret_charconst.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c)
2008-06-24 11:16 ` Joseph S. Myers
@ 2008-06-27 11:24 ` Laurynas Biveinis
2008-06-27 12:40 ` Joseph S. Myers
0 siblings, 1 reply; 4+ messages in thread
From: Laurynas Biveinis @ 2008-06-27 11:24 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches
2008/6/24 Joseph S. Myers <joseph@codesourcery.com>:
>> To set unsignedp value, lex_charconst calls cpp_interpret_charconst.
>> Here it quits early with an error, leaving unsignedp uninitialized.
>> Fixed by checking error code and initializing unsignedp.
>> Bootstrapped/regtested x86_64-unknown-linux-gnu. OK for trunk?
>
> 0 is not just an error return here, as far as I can tell it can also be a
> valid return value in a non-error case. It just so happens that the value
> of unsignedp doesn't matter if the return is 0, because it's only used in
> "unsignedp || (cppchar_signed_t) result >= 0". I think it would be better
> just to initialize unsignedp when declared (unconditionally), before
> calling cpp_interpret_charconst.
So there is no way to know if cpp_interpret_charconst failed? OK, here
is the updated patch, bootstrapped/regtested on
x86_64-unknown-linux-gnu, OK for trunk?
Thanks,
Laurynas
2008-06-27 Laurynas Biveinis <laurynas.biveinis@gmail.com>
PR c/34867
* c-lex.c (lex_charconst): Initialize unsignedp.
Index: gcc/c-lex.c
===================================================================
--- gcc/c-lex.c (revision 137083)
+++ gcc/c-lex.c (working copy)
@@ -977,7 +977,7 @@
cppchar_t result;
tree type, value;
unsigned int chars_seen;
- int unsignedp;
+ int unsignedp = 0;
result = cpp_interpret_charconst (parse_in, token,
&chars_seen, &unsignedp);
--
Laurynas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c)
2008-06-27 11:24 ` Laurynas Biveinis
@ 2008-06-27 12:40 ` Joseph S. Myers
0 siblings, 0 replies; 4+ messages in thread
From: Joseph S. Myers @ 2008-06-27 12:40 UTC (permalink / raw)
To: Laurynas Biveinis; +Cc: gcc-patches
On Fri, 27 Jun 2008, Laurynas Biveinis wrote:
> So there is no way to know if cpp_interpret_charconst failed? OK, here
> is the updated patch, bootstrapped/regtested on
> x86_64-unknown-linux-gnu, OK for trunk?
>
> Thanks,
> Laurynas
>
> 2008-06-27 Laurynas Biveinis <laurynas.biveinis@gmail.com>
>
> PR c/34867
> * c-lex.c (lex_charconst): Initialize unsignedp.
This is OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-27 11:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 5:23 [PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c) Laurynas Biveinis
2008-06-24 11:16 ` Joseph S. Myers
2008-06-27 11:24 ` Laurynas Biveinis
2008-06-27 12:40 ` Joseph S. Myers
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).