Hi!

DECL_THREAD_LOCAL_P may be used only on VAR_DECLs, not other decls
like PARM_DECL, RESULT_DECL etc.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2011-08-22  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/50141
        * expr.c (get_bit_range): Only use DECL_THREAD_LOCAL_P if
        innerdecl is a VAR_DECL.

        * c-c++-common/cxxbitfields-6.c: New test.

--- gcc/expr.c.jj       2011-08-22 08:17:07.000000000 +0200
+++ gcc/expr.c  2011-08-22 10:06:26.000000000 +0200
@@ -4354,7 +4354,8 @@ get_bit_range (unsigned HOST_WIDE_INT *b
           || TREE_CODE (innerdecl) == TARGET_MEM_REF)
          && !ptr_deref_may_alias_global_p (TREE_OPERAND (innerdecl, 0)))
       || (DECL_P (innerdecl)
-         && (DECL_THREAD_LOCAL_P (innerdecl)
+         && ((TREE_CODE (innerdecl) == VAR_DECL
+              && DECL_THREAD_LOCAL_P (innerdecl))
              || !TREE_STATIC (innerdecl))))
     {
       *bitstart = *bitend = 0;
--- gcc/testsuite/c-c++-common/cxxbitfields-6.c.jj      2011-08-22 
10:11:34.000000000 +0200
+++ gcc/testsuite/c-c++-common/cxxbitfields-6.c 2011-08-22 10:11:59.000000000 
+0200
@@ -0,0 +1,17 @@
+/* PR middle-end/50141 */
+/* { dg-do compile } */
+/* { dg-options "-O2 --param allow-store-data-races=0" } */
+
+struct S
+{
+  int i:8;
+};
+
+void bar (struct S, int);
+
+void
+foo (struct S s, int i)
+{
+  s.i = i;
+  bar (s, i);
+}

        Jakub

Reply via email to