]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/39558 (Bad interaction of decls named 'vector' and -maltivec vector...
authorJakub Jelinek <jakub@redhat.com>
Mon, 30 Mar 2009 15:00:52 +0000 (17:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 30 Mar 2009 15:00:52 +0000 (17:00 +0200)
PR target/39558
* macro.c (cpp_get_token): If macro_to_expand returns NULL
and used some tokens, add CPP_PADDING before next token.

* gcc.target/powerpc/altivec-29.c: New test.

From-SVN: r145297

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/altivec-29.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/macro.c

index d672724fbbdc7fab9d3ded16521d8e066105d331..cf19d16e87f6c58fa774350261d28a027be409b0 100644 (file)
@@ -2,6 +2,9 @@
 
        * gfortran.dg/bind_c_usage_19.f90: New test.
 
+       PR target/39558
+       * gcc.target/powerpc/altivec-29.c: New test.
+
 2009-03-30  Joseph Myers  <joseph@codesourcery.com>
 
        PR rtl-optimization/323
diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-29.c b/gcc/testsuite/gcc.target/powerpc/altivec-29.c
new file mode 100644 (file)
index 0000000..10a25ec
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR target/39558 */
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -save-temps" } */
+
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+
+int *foo (int *vector)
+{
+  return vector;
+}
+
+int *bar (int *vector ATTRIBUTE_UNUSED)
+{
+  return vector;
+}
+
+int *baz (int *vector __attribute__((unused)))
+{
+  return vector;
+}
+
+/* { dg-final { cleanup-saved-temps } } */
index a9841c7314d4128ff5c9eb596d0fe46c915f90b6..4bf58690b6f3b9881c7d9f45037b9e1536942d4a 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/39558
+       * macro.c (cpp_get_token): If macro_to_expand returns NULL
+       and used some tokens, add CPP_PADDING before next token.
+
 2009-03-29  Joseph Myers  <joseph@codesourcery.com>
 
        PR preprocessor/34695
index 3a20c36ed39ef54a898a7f845da45a9e0a755d1d..fc70be67403c42aeaa6dfca5ca945c61e7433eb6 100644 (file)
@@ -1260,10 +1260,36 @@ cpp_get_token (cpp_reader *pfile)
 
          /* Conditional macros require that a predicate be evaluated
             first.  */
-         if (((!(node->flags & NODE_CONDITIONAL))
-              || (pfile->cb.macro_to_expand
-                  && (node = pfile->cb.macro_to_expand (pfile, result))))
-             && (ret = enter_macro_context (pfile, node, result)))
+         if ((node->flags & NODE_CONDITIONAL) != 0)
+           {
+             if (pfile->cb.macro_to_expand)
+               {
+                 bool whitespace_after;
+                 const cpp_token *peek_tok = cpp_peek_token (pfile, 0);
+
+                 whitespace_after = (peek_tok->type == CPP_PADDING
+                                     || (peek_tok->flags & PREV_WHITE));
+                 node = pfile->cb.macro_to_expand (pfile, result);
+                 if (node)
+                   ret = enter_macro_context (pfile, node, result);
+                 else if (whitespace_after)
+                   {
+                     /* If macro_to_expand hook returned NULL and it
+                        ate some tokens, see if we don't need to add
+                        a padding token in between this and the
+                        next token.  */
+                     peek_tok = cpp_peek_token (pfile, 0);
+                     if (peek_tok->type != CPP_PADDING
+                         && (peek_tok->flags & PREV_WHITE) == 0)
+                       _cpp_push_token_context (pfile, NULL,
+                                                padding_token (pfile,
+                                                               peek_tok), 1);
+                   }
+               }
+           }
+         else
+           ret = enter_macro_context (pfile, node, result);
+         if (ret)
            {
              if (pfile->state.in_directive || ret == 2)
                continue;