(truthvalue_conversion, case ADDR_EXPR): Don't treat address of
authorRichard Kenner <kenner@gcc.gnu.org>
Mon, 6 May 1996 19:41:35 +0000 (15:41 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Mon, 6 May 1996 19:41:35 +0000 (15:41 -0400)
external decl as always nonzero.

From-SVN: r11941

gcc/c-common.c

index 3c9018ad268711fd10300114180d501d0d1c52ab..8a834dd072f1aa6e9d1fe6f547d446e92f3ca3ef 100644 (file)
@@ -2080,6 +2080,12 @@ truthvalue_conversion (expr)
       return real_zerop (expr) ? boolean_false_node : boolean_true_node;
 
     case ADDR_EXPR:
+      /* If we are taking the address of a external decl, it might be zero
+        if it is weak, so we cannot optimize.  */
+      if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (expr, 0))) == 'd'
+         && DECL_EXTERNAL (TREE_OPERAND (expr, 0)))
+       break;
+
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)))
        return build (COMPOUND_EXPR, boolean_type_node,
                      TREE_OPERAND (expr, 0), boolean_true_node);