diff options
author | Jiufu Guo <guojiufu@linux.ibm.com> | 2022-05-09 17:48:00 +0800 |
---|---|---|
committer | guojiufu <guojiufu@linux.ibm.com> | 2022-05-10 11:36:22 +0800 |
commit | 067fe66c8ba9b16feacf66fce9ae668091e42821 (patch) | |
tree | 190e8892ca7c27f8e4f765d1ebb01728ae3030a7 | |
parent | bd022ff9752262a70f44b57808447f823392989e (diff) | |
download | gcc-067fe66c8ba9b16feacf66fce9ae668091e42821.zip gcc-067fe66c8ba9b16feacf66fce9ae668091e42821.tar.gz gcc-067fe66c8ba9b16feacf66fce9ae668091e42821.tar.bz2 |
rs6000: avoid peeking eof after __vector
There is a rare corner case: where vector is followed only by one
valid identifer and the ";" which is near the end of the file.
Like the case in PR101168:
using vdbl = __vector double;
#define BREAK 1
For this case, "vector double" is followed by CPP_SEMICOLON and then
EOF. There is no more tokens need to check for this case.
PR preprocessor/101168
gcc/ChangeLog:
* config/rs6000/rs6000-c.cc (rs6000_macro_to_expand):
Avoid empty identifier.
gcc/testsuite/ChangeLog:
* g++.target/powerpc/pr101168.C: New test.
-rw-r--r-- | gcc/config/rs6000/rs6000-c.cc | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/powerpc/pr101168.C | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index 84bb98f..9c8cbd7 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -178,9 +178,8 @@ rid_int128(void) return RID_MAX + 1; } -/* Called to decide whether a conditional macro should be expanded. - Since we have exactly one such macro (i.e, 'vector'), we do not - need to examine the 'tok' parameter. */ +/* Called to decide whether a conditional macro should be expanded + by peeking two or more tokens(_bool/_pixel/int/long/double/...). */ static cpp_hashnode * rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) @@ -282,7 +281,9 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) expand_bool_pixel = __pixel_keyword; else if (ident == C_CPP_HASHNODE (__bool_keyword)) expand_bool_pixel = __bool_keyword; - else + + /* If there are more tokens to check. */ + else if (ident) { /* Try two tokens down, too. */ do diff --git a/gcc/testsuite/g++.target/powerpc/pr101168.C b/gcc/testsuite/g++.target/powerpc/pr101168.C new file mode 100644 index 0000000..284e77f --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr101168.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec" } */ + +using vdbl = __vector double; +#define BREAK 1 |