From: Jakub Jelinek Date: Wed, 10 Sep 2008 21:06:25 +0000 (+0200) Subject: re PR target/36904 (vector context sensitive keyword vs macros) X-Git-Tag: releases/gcc-4.4.0~2506 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a76ddc7bda84d17ddc6577c60daf95897a2de515;p=thirdparty%2Fgcc.git re PR target/36904 (vector context sensitive keyword vs macros) PR target/36904 * config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Return NULL instead of tok->val.node if not expanding to something else. Handle intervening CPP_PADDING tokens. (altivec_categorize_keyword): Remove unneeded comparisons. * gcc.target/powerpc/altivec-27.c: New test. From-SVN: r140247 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c24b2e8bd2e3..48e59e6b4e6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2008-09-10 Jakub Jelinek + + PR target/36904 + * config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Return NULL + instead of tok->val.node if not expanding to something else. Handle + intervening CPP_PADDING tokens. + (altivec_categorize_keyword): Remove unneeded comparisons. + 2008-09-10 Richard Guenther * tree-ssa-pre.c (phi_translate_1): Fix memory leak. diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 8cbace8a7956..da1cb787169e 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -102,16 +102,13 @@ altivec_categorize_keyword (const cpp_token *tok) { cpp_hashnode *ident = tok->val.node; - if (ident == C_CPP_HASHNODE (vector_keyword) - || ident == C_CPP_HASHNODE (__vector_keyword)) + if (ident == C_CPP_HASHNODE (vector_keyword)) return C_CPP_HASHNODE (__vector_keyword); - if (ident == C_CPP_HASHNODE (pixel_keyword) - || ident == C_CPP_HASHNODE (__pixel_keyword)) + if (ident == C_CPP_HASHNODE (pixel_keyword)) return C_CPP_HASHNODE (__pixel_keyword); - if (ident == C_CPP_HASHNODE (bool_keyword) - || ident == C_CPP_HASHNODE (__bool_keyword)) + if (ident == C_CPP_HASHNODE (bool_keyword)) return C_CPP_HASHNODE (__bool_keyword); return ident; @@ -158,12 +155,18 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) ident = altivec_categorize_keyword (tok); + if (ident != expand_this) + expand_this = NULL; + if (ident == C_CPP_HASHNODE (__vector_keyword)) { - tok = cpp_peek_token (pfile, 0); + int idx = 0; + do + tok = cpp_peek_token (pfile, idx++); + while (tok->type == CPP_PADDING); ident = altivec_categorize_keyword (tok); - if (ident == C_CPP_HASHNODE (__pixel_keyword)) + if (ident == C_CPP_HASHNODE (__pixel_keyword)) { expand_this = C_CPP_HASHNODE (__vector_keyword); expand_bool_pixel = __pixel_keyword; @@ -178,8 +181,12 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) enum rid rid_code = (enum rid)(ident->rid_code); if (ident->type == NT_MACRO) { - (void)cpp_get_token (pfile); - tok = cpp_peek_token (pfile, 0); + do + (void) cpp_get_token (pfile); + while (--idx > 0); + do + tok = cpp_peek_token (pfile, idx++); + while (tok->type == CPP_PADDING); ident = altivec_categorize_keyword (tok); if (ident) rid_code = (enum rid)(ident->rid_code); @@ -193,19 +200,23 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) expand_this = C_CPP_HASHNODE (__vector_keyword); /* If the next keyword is bool or pixel, it will need to be expanded as well. */ - tok = cpp_peek_token (pfile, 1); + do + tok = cpp_peek_token (pfile, idx++); + while (tok->type == CPP_PADDING); ident = altivec_categorize_keyword (tok); - if (ident == C_CPP_HASHNODE (__pixel_keyword)) + if (ident == C_CPP_HASHNODE (__pixel_keyword)) expand_bool_pixel = __pixel_keyword; else if (ident == C_CPP_HASHNODE (__bool_keyword)) expand_bool_pixel = __bool_keyword; else { /* Try two tokens down, too. */ - tok = cpp_peek_token (pfile, 2); + do + tok = cpp_peek_token (pfile, idx++); + while (tok->type == CPP_PADDING); ident = altivec_categorize_keyword (tok); - if (ident == C_CPP_HASHNODE (__pixel_keyword)) + if (ident == C_CPP_HASHNODE (__pixel_keyword)) expand_bool_pixel = __pixel_keyword; else if (ident == C_CPP_HASHNODE (__bool_keyword)) expand_bool_pixel = __bool_keyword; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f4fca182c4ee..88463e9b491a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-10 Jakub Jelinek + + PR target/36904 + * gcc.target/powerpc/altivec-27.c: New test. + 2008-09-10 Andrew Pinski PR middle-end/37333 diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-27.c b/gcc/testsuite/gcc.target/powerpc/altivec-27.c new file mode 100644 index 000000000000..7db0ea01f2c7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/altivec-27.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec" } */ + +#define f0() void x0 (vector float x) { } +f0 () + +#define f1(type) void x1##type (vector type x) { } +f1 (float) + +#define f2(v, type) void x2##type (v type x) { } +f2 (vector, float) + +#define f3(type) void x3##type (vector bool type x) { } +f3 (int) + +#define f4(v, type) void x4##type (v bool type x) { } +f4 (vector, int) + +#define f5(b, type) void x5##type (vector b type x) { } +f5 (bool, int) + +#define f6(v, b, type) void x6##type (v b type x) { } +f6 (vector, bool, int) + +#define f7(v, b, type) void x7##type (v type b x) { } +f7 (vector, bool, int) + +int vector = 6; + +#define v1(v) int x8 (int v) { return v; } +v1(vector)