re PR c/38700 (ICE with __builtin_expect and label)
authorJakub Jelinek <jakub@redhat.com>
Sat, 3 Jan 2009 00:52:51 +0000 (01:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 3 Jan 2009 00:52:51 +0000 (01:52 +0100)
PR c/38700
* builtins.c (fold_builtin_expect): Only check DECL_WEAK for VAR_DECLs
and FUNCTION_DECLs.

* gcc.dg/pr38700.c: New test.

From-SVN: r143028

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr38700.c [new file with mode: 0644]

index ba31727..5980890 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/38700
+       * builtins.c (fold_builtin_expect): Only check DECL_WEAK for VAR_DECLs
+       and FUNCTION_DECLs.
+
 2009-01-02  Kenneth Zadeck <zadeck@naturalbridge.com>
 
        PR rtl-optimization/35805
index 607d7dd..cda94c3 100644 (file)
@@ -1,6 +1,6 @@
 /* Expand builtin functions.
    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -7324,7 +7324,9 @@ fold_builtin_expect (tree arg0, tree arg1)
        }
       while (TREE_CODE (inner) == COMPONENT_REF
             || TREE_CODE (inner) == ARRAY_REF);
-      if (DECL_P (inner) && DECL_WEAK (inner))
+      if ((TREE_CODE (inner) == VAR_DECL
+           || TREE_CODE (inner) == FUNCTION_DECL)
+         && DECL_WEAK (inner))
        return NULL_TREE;
     }
 
index 199784f..4a0c0c6 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/38700
+       * gcc.dg/pr38700.c: New test.
+
 2009-01-02  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/initlist11.C: New test.
diff --git a/gcc/testsuite/gcc.dg/pr38700.c b/gcc/testsuite/gcc.dg/pr38700.c
new file mode 100644 (file)
index 0000000..bfa75b0
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/38700 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int
+foo ()
+{
+  __SIZE_TYPE__ s = __builtin_expect ((__SIZE_TYPE__)&&L, 0);
+L:
+  return 0;
+}