]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/36904 (vector context sensitive keyword vs macros)
authorJakub Jelinek <jakub@redhat.com>
Wed, 10 Sep 2008 21:06:25 +0000 (23:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 10 Sep 2008 21:06:25 +0000 (23:06 +0200)
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

gcc/ChangeLog
gcc/config/rs6000/rs6000-c.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/altivec-27.c [new file with mode: 0644]

index c24b2e8bd2e35a701c284b326bd8f2b4205f3c15..48e59e6b4e6f5b8dd85474d876bcd38c57208d26 100644 (file)
@@ -1,3 +1,11 @@
+2008-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <rguenther@suse.de>
 
        * tree-ssa-pre.c (phi_translate_1): Fix memory leak.
index 8cbace8a7956e06b4854491928ce9e1845d813a3..da1cb787169ecafbbd46a9453c27c25695f2530f 100644 (file)
@@ -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;
index f4fca182c4eecd634a60608c8cafea55bad09cba..88463e9b491aca6672b8d93849e6a31ca1608b09 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/36904
+       * gcc.target/powerpc/altivec-27.c: New test.
+
 2008-09-10  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        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 (file)
index 0000000..7db0ea0
--- /dev/null
@@ -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)