diff mbox

[buildrobot] libcpp/lex.c: Use enum properly

Message ID 20131024090529.GV19160@lug-owl.de
State New
Headers show

Commit Message

Jan-Benedict Glaw Oct. 24, 2013, 9:05 a.m. UTC
Hi!

While building with IBM's XL C/C++ compiler, I noticed (cf.
http://toolchain.lug-owl.de/buildbot/deliver_artifact.php?mode=view&id=128806):

source='/home/jbglaw/repos-IBM-XL/gcc/libcpp/lex.c' object='lex.o' libtool=no DEPDIR=.deps depmode=aix /bin/sh /home/jbglaw/repos-IBM-XL/gcc/libcpp/../depcomp /usr/vacpp/bin/xlc++  -I/home/jbglaw/repos-IBM-XL/gcc/libcpp -I. -I/home/jbglaw/repos-IBM-XL/gcc/libcpp/../include -I/home/jbglaw/repos-IBM-XL/gcc/libcpp/include  -g -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute   -fno-exceptions -fno-rtti -I/home/jbglaw/repos-IBM-XL/gcc/libcpp -I. -I/home/jbglaw/repos-IBM-XL/gcc/libcpp/../include -I/home/jbglaw/repos-IBM-XL/gcc/libcpp/include   -c /home/jbglaw/repos-IBM-XL/gcc/libcpp/lex.c
/usr/vacpp/bin/xlc++: 1501-289 (W) Option -Wall was incorrectly specified. The option will be ignored.
/usr/vacpp/bin/xlc++: 1501-289 (W) Option -Wno-narrowing was incorrectly specified. The option will be ignored.
/usr/vacpp/bin/xlc++: 1501-289 (W) Option -Wwrite-strings was incorrectly specified. The option will be ignored.
/usr/vacpp/bin/xlc++: 1501-289 (W) Option -Wmissing-format-attribute was incorrectly specified. The option will be ignored.
"/home/jbglaw/repos-IBM-XL/gcc/libcpp/lex.c", line 1381.17: 1506-277 (S) Syntax error: possible missing ';' or ','?
"/home/jbglaw/repos-IBM-XL/gcc/libcpp/lex.c", line 1381.3: 1506-045 (S) Undeclared identifier raw_str_phase.
"/home/jbglaw/repos-IBM-XL/gcc/libcpp/lex.c", line 1500.11: 1506-045 (S) Undeclared identifier phase.
make[1]: *** [lex.o] Error 1

Fixed like this:

2013-10-24  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

libcpp/
	* lex.c (lex_raw_string): Use proper type.



Ok?

MfG, JBG

Comments

Mike Stump Oct. 25, 2013, 1:22 a.m. UTC | #1
On Oct 24, 2013, at 2:05 AM, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> -  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX };
> -  raw_str_phase phase = RAW_STR_PREFIX;
> +  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX } phase = RAW_STR_PREFIX;

Since no one else chimed in…  seems obvious to me…  though the line is too long.  Better likely would be to just say:

  enum raw_str_phase phase = RAW_STR_PREFIX;
Andrew Pinski Oct. 25, 2013, 1:25 a.m. UTC | #2
On Thu, Oct 24, 2013 at 6:22 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Oct 24, 2013, at 2:05 AM, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>> -  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX };
>> -  raw_str_phase phase = RAW_STR_PREFIX;
>> +  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX } phase = RAW_STR_PREFIX;
>
> Since no one else chimed in…  seems obvious to me…  though the line is too long.  Better likely would be to just say:

No it does not due to in C++ the name is injected without the enum tag too.

>
>   enum raw_str_phase phase = RAW_STR_PREFIX;

This is a good work around but please add a comment of why this is
needed (to work around a bug in XLC++).

Thanks,
Andrew
Mike Stump Oct. 25, 2013, 1:37 a.m. UTC | #3
On Oct 24, 2013, at 6:25 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>>  enum raw_str_phase phase = RAW_STR_PREFIX;
> 
> This is a good work around but please add a comment of why this is
> needed (to work around a bug in XLC++).

Oh, curious, I was assuming that file was compiled by the C compiler…  not as obvious as I first thought.
Tom Tromey Oct. 25, 2013, 2:29 p.m. UTC | #4
>>>>> "Andrew" == Andrew Pinski <pinskia@gmail.com> writes:

>> enum raw_str_phase phase = RAW_STR_PREFIX;

Andrew> This is a good work around but please add a comment of why this is
Andrew> needed (to work around a bug in XLC++).

I agree.
It's ok with this update.

thanks,
Tom
diff mbox

Patch

diff --git a/libcpp/lex.c b/libcpp/lex.c
index ed794d5..4fa244d 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1377,8 +1377,7 @@  lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
   uchar temp_buffer[18];
   const uchar *orig_base;
   unsigned int raw_prefix_len = 0, raw_suffix_len = 0;
-  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX };
-  raw_str_phase phase = RAW_STR_PREFIX;
+  enum raw_str_phase { RAW_STR_PREFIX, RAW_STR, RAW_STR_SUFFIX } phase = RAW_STR_PREFIX;
   enum cpp_ttype type;
   size_t total_len = 0;
   /* Index into temp_buffer during phases other than RAW_STR,