[llvm-commits] [llvm-gcc-4.2] r55675 - in /llvm-gcc-4.2/trunk/gcc: ./ config/i386/ cp/ objc/ testsuite/g++.apple/ testsuite/g++.dg/ testsuite/gcc.c-torture/execute/builtins/lib/ testsuite/gcc.dg/cpp/trad/ testsuite/gcc.target/i386/ testsuite/objc.dg/

Bill Wendling isanbard at gmail.com
Tue Sep 2 15:20:13 PDT 2008


Author: void
Date: Tue Sep  2 17:20:12 2008
New Revision: 55675

URL: http://llvm.org/viewvc/llvm-project?rev=55675&view=rev
Log:
This syncs LLVM-GCC up with Apple's GCC tree, r150332. This sync is important
because it brings in important bug fixes for blocks. At this point, the "blocks"
syntax should be pretty stable.

Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/6128170.m
Modified:
    llvm-gcc-4.2/trunk/gcc/c-common.c
    llvm-gcc-4.2/trunk/gcc/c-common.h
    llvm-gcc-4.2/trunk/gcc/c-cppbuiltin.c
    llvm-gcc-4.2/trunk/gcc/c-decl.c
    llvm-gcc-4.2/trunk/gcc/c-parser.c
    llvm-gcc-4.2/trunk/gcc/c-typeck.c
    llvm-gcc-4.2/trunk/gcc/c.opt
    llvm-gcc-4.2/trunk/gcc/calls.c
    llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
    llvm-gcc-4.2/trunk/gcc/cp/call.c
    llvm-gcc-4.2/trunk/gcc/cp/decl.c
    llvm-gcc-4.2/trunk/gcc/cp/decl2.c
    llvm-gcc-4.2/trunk/gcc/cp/parser.c
    llvm-gcc-4.2/trunk/gcc/cp/semantics.c
    llvm-gcc-4.2/trunk/gcc/cp/typeck.c
    llvm-gcc-4.2/trunk/gcc/dbxout.c
    llvm-gcc-4.2/trunk/gcc/dwarf2out.c
    llvm-gcc-4.2/trunk/gcc/dwarf2out.h
    llvm-gcc-4.2/trunk/gcc/except.c
    llvm-gcc-4.2/trunk/gcc/expmed.c
    llvm-gcc-4.2/trunk/gcc/expr.c
    llvm-gcc-4.2/trunk/gcc/expr.h
    llvm-gcc-4.2/trunk/gcc/final.c
    llvm-gcc-4.2/trunk/gcc/fold-const.c
    llvm-gcc-4.2/trunk/gcc/function.c
    llvm-gcc-4.2/trunk/gcc/gcov-io.c
    llvm-gcc-4.2/trunk/gcc/global.c
    llvm-gcc-4.2/trunk/gcc/ifcvt.c
    llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
    llvm-gcc-4.2/trunk/gcc/rtl.h
    llvm-gcc-4.2/trunk/gcc/stmt.c
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5596043.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-3.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/inline-limit-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/cpp/trad/include.c
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/20020616-1.c
    llvm-gcc-4.2/trunk/gcc/tree.h
    llvm-gcc-4.2/trunk/gcc/varasm.c
    llvm-gcc-4.2/trunk/gcc/version.c

Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Tue Sep  2 17:20:12 2008
@@ -302,7 +302,8 @@
 /* Warn about format/argument anomalies in calls to formatted I/O functions
    (*printf, *scanf, strftime, strfmon, etc.).  */
 
-int warn_format;
+/* APPLE LOCAL default to Wformat-security 5764921 */
+int warn_format = 1;
 
 /* Warn about using __null (as NULL in C++) as sentinel.  For code compiled
    with GCC this doesn't matter as __null is guaranteed to have the right
@@ -1228,7 +1229,20 @@
   if (warn_shorten_64_to_32
       && TYPE_PRECISION (TREE_TYPE (expr)) == 64
       && TYPE_PRECISION (type) == 32)
-    warning (0, "implicit conversion shortens 64-bit value into a 32-bit value");
+    /* APPLE LOCAL begin 64bit shorten warning 5429810 */
+    {
+      /* As a special case, don't warn when we are working with small
+	 constants as the enum forming code shortens them into smaller
+	 types.  */
+      if (TREE_CODE (expr) == INTEGER_CST)
+	{
+	  bool unsignedp = tree_int_cst_sgn (expr) >= 0;
+	  if (min_precision (expr, unsignedp) <= TYPE_PRECISION (type))
+	    return;
+	}
+      warning (0, "implicit conversion shortens 64-bit value into a 32-bit value");
+    }
+    /* APPLE LOCAL end 64bit shorten warning 5429810 */
 }
 
 /* Convert EXPR to TYPE, warning about conversion problems with constants.
@@ -6128,6 +6142,35 @@
 /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
 
 /* APPLE LOCAL begin blocks 6040305 */
+
+/* This routine builds:
+   *(id *)(EXP+20) expression which references the object id pointer.
+*/
+tree
+build_indirect_object_id_exp (tree exp)
+{
+  tree dst_obj;
+  int  int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
+  int offset;
+  /* dst->object = [src->object retail]; In thid case 'object' is the field
+   of the object passed offset by: void* + int + int + void* + void *
+   This must match definition of Block_byref structs. */
+  offset = GET_MODE_SIZE (Pmode) + int_size + int_size + GET_MODE_SIZE (Pmode) +
+           GET_MODE_SIZE (Pmode);
+  dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
+                    build_int_cst (NULL_TREE, offset));
+  /* APPLE LOCAL begin radar 6180456 */
+  if (c_dialect_objc ())
+    {
+      /* Type case to: 'id *' */
+      dst_obj = cast_to_pointer_to_id (dst_obj);
+      dst_obj = build_indirect_ref (dst_obj, "unary *");
+    }
+  /* APPLE LOCAL end radar 6180456 */
+  return dst_obj;
+}
+
+/* APPLE LOCAL begin radar 6180456 */
 static tree block_byref_release_decl;
 
 /* Build a: void _Block_byref_release (void *) if not done
@@ -6151,6 +6194,29 @@
   }
   return block_byref_release_decl;
 }
+/* APPLE LOCAL end radar 6180456 */
+
+static tree block_byref_assign_copy_decl;
+tree
+build_block_byref_assign_copy_decl (void)
+{
+  /* Build a: void _Block_byref_assign_copy (void *, void *) if not done already. */
+  if (!block_byref_assign_copy_decl
+      && !(block_byref_assign_copy_decl
+             = lookup_name (get_identifier ("_Block_byref_assign_copy"))))
+    {
+      tree func_type
+        = build_function_type (void_type_node,
+                               tree_cons (NULL_TREE, ptr_type_node,
+                                          tree_cons (NULL_TREE, ptr_type_node, void_list_node)));
+
+      block_byref_assign_copy_decl
+        = builtin_function ("_Block_byref_assign_copy", func_type,
+                            0, NOT_BUILT_IN, 0, NULL_TREE);
+      TREE_NOTHROW (block_byref_assign_copy_decl) = 0;
+    }
+  return block_byref_assign_copy_decl;
+}
 
 /* This routine builds call to:
  _Block_byref_release(VAR_DECL.forwarding);
@@ -6209,6 +6275,29 @@
 }
 /* APPLE LOCAL end radar 5803600 */
 
+/* APPLE LOCAL begin radar 6160536 */
+tree
+build_block_helper_name (int unique_count)
+{
+  char *buf;
+  if (!current_function_decl)
+    {
+      buf = (char *)alloca (32);
+      sprintf (buf, "__block_global_%d", unique_count);
+    }
+  else
+    {
+      tree outer_decl = current_function_decl;
+      while (outer_decl && DECL_CONTEXT (outer_decl))
+        outer_decl = DECL_CONTEXT (outer_decl);
+      buf = (char *)alloca (IDENTIFIER_LENGTH (DECL_NAME (outer_decl)) + 32); 
+      sprintf (buf, "__%s_block_invoke_%d", 
+	       IDENTIFIER_POINTER (DECL_NAME (outer_decl)), unique_count);
+    }
+   return get_identifier (buf); 
+}
+/* APPLE LOCAL end radar 6160536 */
+
 /* Handle a "sentinel" attribute.  */
 
 static tree
@@ -6538,11 +6627,13 @@
       message = NULL;
     }
   else
-    error (gmsgid);
+    /* APPLE LOCAL default to Wformat-security 5764921 */
+    error (gmsgid, "");
 
   if (message)
     {
-      error (message);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      error (message, "");
       free (message);
     }
 #undef catenate_messages
@@ -7266,9 +7357,10 @@
       once = 1;
       /* LLVM LOCAL begin */
 #ifdef ENABLE_LLVM
-      for (i=0; i < sizeof (db) / sizeof(db[0]) - 2; ++i)
+      for (i=0; i + 2 < sizeof (db) / sizeof(db[0]); ++i)
 #else
-      for (i=0; i < sizeof (db) / sizeof(db[0]) - 1; ++i)
+      /* APPLE LOCAL 6141565 fix comparison always false warning */
+      for (i=0; i + 1 < sizeof (db) / sizeof(db[0]); ++i)
 #endif
       /* LLVM LOCAL end */
 	gcc_assert (iasm_op_comp (&db[i+1], &db[i]) >= 0);
@@ -8499,11 +8591,11 @@
 #ifdef ENABLE_LLVM
   tree stmt, label;
 #else
-   tree sexpr;
-   tree inputs = NULL_TREE, outputs = NULL_TREE, clobbers = NULL_TREE;
-   tree stmt;
-   tree label, l;
-   tree str, one;
+  tree sexpr;
+  tree inputs = NULL_TREE, outputs = NULL_TREE, clobbers = NULL_TREE;
+  tree stmt;
+  tree label, l;
+  tree str, one;
 #endif
 /* LLVM LOCAL end */
   STRIP_NOPS (labid);

Modified: llvm-gcc-4.2/trunk/gcc/c-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.h?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.h (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.h Tue Sep  2 17:20:12 2008
@@ -1124,7 +1124,9 @@
      BLOCK_NEEDS_FREE =        (1 << 24),
      BLOCK_HAS_COPY_DISPOSE =  (1 << 25),
      BLOCK_NO_COPY =           (1 << 26), /* interim byref: no copies allowed */
-     BLOCK_IS_GC =             (1 << 27)
+     BLOCK_IS_GC =             (1 << 27),
+     /* APPLE LOCAL radar 5822844 */
+     BLOCK_IS_GLOBAL = 	       (1 << 28)
 };
 
 struct block_sema_info {
@@ -1145,6 +1147,8 @@
   bool isVariadic;
   bool BlockHasCopyDispose;
   bool BlockHasByrefVar;
+  /* APPLE LOCAL radar 5822844 */
+  bool block_is_complete; /* When true, we are done analyzing block. */
 
   /* the_scope - This is the scope for the block itself, which
      contains arguments etc.  Use only for C.  */
@@ -1198,6 +1202,7 @@
 extern void gen_block_byref_release_exp (tree);
 extern tree build_block_byref_release_exp (tree);
 extern tree build_block_byref_release_decl (void);
+extern tree build_block_byref_assign_copy_decl (void);
 extern void release_all_local_byrefs_at_return (void);
 void diagnose_byref_var_in_current_scope (void);
 extern void release_local_byrefs_at_break (void);
@@ -1205,6 +1210,12 @@
 extern void outof_bc_stmt_block (void);
 /* APPLE LOCAL end radar 6083129 - byref escapes */
 
+/* APPLE LOCAL radar 6040305 - blocks */
+extern tree build_indirect_object_id_exp (tree);
+
+/* APPLE LOCAL radar 6160536 */
+extern tree build_block_helper_name (int);
+
 /* In c-omp.c  */
 extern tree c_finish_omp_master (tree);
 extern tree c_finish_omp_critical (tree, tree);

Modified: llvm-gcc-4.2/trunk/gcc/c-cppbuiltin.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-cppbuiltin.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-cppbuiltin.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-cppbuiltin.c Tue Sep  2 17:20:12 2008
@@ -584,7 +584,7 @@
      options.  */
   /* APPLE LOCAL begin blocks */
   /* APPLE LOCAL radar 5868913 */
-  if (flag_blocks && !c_dialect_cxx ())
+  if (flag_blocks)
     cpp_define (pfile, "__BLOCKS__=1"); 
   /* APPLE LOCAL end blocks */
   if (optimize_size)

Modified: llvm-gcc-4.2/trunk/gcc/c-decl.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-decl.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-decl.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-decl.c Tue Sep  2 17:20:12 2008
@@ -326,13 +326,13 @@
   tree blocks;
   tree blocks_last;
 
-  /* APPLE LOCAL begin radar 6083129 -  byref escapes */
-  /* None-zero if outermost block of a statement which can have a 
+  /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
+  /* Non-zero if outermost block of a statement which can have a 
      break/continue stmt; such as while, switch, etc. This cannot be
      a boolen field because the same scope can be used for a nested
      while/for statement; as in, while(...) while (...). */
   unsigned int  bc_stmt_body;
-  /* APPLE LOCAL end radar 6083129 -  byref escapes */
+  /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
 
   /* The depth of this scope.  Used to keep the ->shadowed chain of
      bindings sorted innermost to outermost.  */
@@ -360,11 +360,11 @@
   /* True means make a BLOCK for this scope no matter what.  */
   BOOL_BITFIELD keep : 1;
 
-  /* APPLE LOCAL begin radar 6083129 -  byref escapes */
+  /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
   /* When true, current scope has at least one local __byref variable
-     in its scope. This flag is used for compile-time performance. */
+     in its scope. This flag is used for compile-time performance.  */
   BOOL_BITFIELD byref_in_current_scope : 1;
-  /* APPLE LOCAL end radar 6083129 -  byref escapes */
+  /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
 };
 
 /* The scope currently in effect.  */
@@ -688,10 +688,10 @@
       scope->keep          = keep_next_level_flag;
       scope->outer         = current_scope;
       scope->depth	   = current_scope ? (current_scope->depth + 1) : 0;
-      /* APPLE LOCAL begin radar 6083129 -  byref escapes */
+      /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
       scope->byref_in_current_scope = 
         current_scope ? current_scope->byref_in_current_scope : false;
-      /* APPLE LOCAL end radar 6083129 -  byref escapes */
+      /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
 
       /* Check for scope depth overflow.  Unlikely (2^28 == 268,435,456) but
 	 possible.  */
@@ -716,11 +716,12 @@
     TYPE_CONTEXT (type) = context;
 }
 
-/* APPLE LOCAL begin radar 6083129 -  byref escapes */
+/* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
 /* This routine is called at the begining of parsing of a while/for, etc.
-   statement and sets bc_stmt_body in current scope to say that outer scope 
+   statement and sets bc_stmt_body in current scope to say that outer scope
    is for such a statement. */
-void in_bc_stmt_block (void)
+void
+in_bc_stmt_block (void)
 {
   gcc_assert (current_scope);
   ++current_scope->bc_stmt_body;
@@ -728,7 +729,8 @@
 
 /*  This routine resets the bc_stmt_body flag before exiting the top-most
     block of while/for, etc. statement. */
-void outof_bc_stmt_block (void)
+void
+outof_bc_stmt_block (void)
 {
   gcc_assert (current_scope && current_scope->bc_stmt_body > 0);
   --current_scope->bc_stmt_body;
@@ -737,15 +739,16 @@
 /* This routine generates calls of _Block_byref_release(VAR_DECL.forwarding);
    for all byref variables seen in the scope of the return statement.
 */
-void release_all_local_byrefs_at_return (void)
+void
+release_all_local_byrefs_at_return (void)
 {
   struct c_scope *scope;
   struct c_binding *b;
-  
+
   gcc_assert (current_scope);
   if (flag_objc_gc_only || !current_scope->byref_in_current_scope)
     return;
-  
+
   scope = current_scope;
   while (scope && scope != file_scope)
   {
@@ -753,28 +756,27 @@
     {
       tree p = b->decl;
       if (p && TREE_CODE (p) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (p))
-        gen_block_byref_release_exp (p);
+	gen_block_byref_release_exp (p);
     }
-    /* APPLE LOCAL begin radar 6083129 */
     /* Release up to scope of the block. */
     if (cur_block && cur_block->the_scope == scope)
       break;
-    /* APPLE LOCAL end radar 6083129 */
     scope = scope->outer;
   }
 }
 
 /* This routine issues a diagnostic if a __byref variable is seen in
-   current scope. This is for now called from a goto statement. */
-void diagnose_byref_var_in_current_scope (void)
+   current scope. This is for now called from a goto statement.  */
+void
+diagnose_byref_var_in_current_scope (void)
 {
   struct c_scope *scope;
   struct c_binding *b;
-  
+
   gcc_assert (current_scope);
   if (flag_objc_gc_only || !current_scope->byref_in_current_scope)
     return;
-  
+
   scope = current_scope;
   while (scope && scope != file_scope)
   {
@@ -790,18 +792,20 @@
     scope = scope->outer;
   }
 }
-/* This routine generates call to _Block_byref_release(VAR_DECL.forwarding);
-   for all __byref variables which go out of scope when 'break' is executed.
-*/
-void release_local_byrefs_at_break (void)
+
+/* This routine generates call to
+   _Block_byref_release(VAR_DECL.forwarding); for all __byref
+   variables which go out of scope when 'break' is executed.  */
+void
+release_local_byrefs_at_break (void)
 {
   struct c_scope *scope;
   struct c_binding *b;
-  
+
   gcc_assert (current_scope);
   if (flag_objc_gc_only || !current_scope->byref_in_current_scope)
     return;
-  
+
   scope = current_scope;
   while (scope && !scope->bc_stmt_body)
   {
@@ -809,13 +813,13 @@
     {
       tree p = b->decl;
       if (p && TREE_CODE (p) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (p))
-        gen_block_byref_release_exp (p);
+	gen_block_byref_release_exp (p);
     }
     scope = scope->outer;
   }
 }
 
-/* APPLE LOCAL end radar 6083129 -  byref escapes */
+/* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
 
 /* Exit a scope.  Restore the state of the identifier-decl mappings
    that were in effect when this scope was entered.  Return a BLOCK
@@ -947,10 +951,10 @@
 	  goto common_symbol;
 
 	case VAR_DECL:
-         /* APPLE LOCAL begin radar 6083129 -  byref escapes */
+         /* APPLE LOCAL begin radar 6083129 -  byref escapes (C++ cp) */
             if (!flag_objc_gc_only && COPYABLE_BYREF_LOCAL_VAR (p))
-              gen_block_byref_release_exp (p);
-         /* APPLE LOCAL end radar 6083129 -  byref escapes */
+	      gen_block_byref_release_exp (p);
+         /* APPLE LOCAL end radar 6083129 -  byref escapes (C++ cp) */
 
 	  /* Warnings for unused variables.  */
 	  if (!TREE_USED (p)
@@ -1416,14 +1420,14 @@
 	{
 	  /* APPLE LOCAL begin disable typechecking for SPEC --dbj */
 	  /* Accept incompatible function declarations, and incompatible
-	     global variables provided they are in different files. 
+	     global variables provided they are in different files.
 	     (Would be nice to check this for functions also, but
 	     context is not set for them.)  */
 	  bool warn = false;
-	  if (disable_typechecking_for_spec_flag 
+	  if (disable_typechecking_for_spec_flag
 	      && TREE_PUBLIC (olddecl)
 	      && TREE_PUBLIC (newdecl)
-	      && ((TREE_CODE (olddecl) == VAR_DECL 
+	      && ((TREE_CODE (olddecl) == VAR_DECL
 	            && TREE_CODE (newdecl) == VAR_DECL
 		    && !same_translation_unit_p (olddecl, newdecl))
 	          || (TREE_CODE (olddecl) == FUNCTION_DECL
@@ -3637,7 +3641,7 @@
 
     
   /* APPLE LOCAL begin radar 4281748 */
-  if (c_dialect_objc () 
+  if (c_dialect_objc ()
       && (TREE_CODE (decl) == VAR_DECL
           || TREE_CODE (decl) == FUNCTION_DECL))
       objc_check_global_decl (decl);
@@ -3697,46 +3701,24 @@
   using_eh_for_cleanups ();
 }
 
-/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ cr) */
 static tree block_byref_id_object_copy;
 static tree block_byref_id_object_dispose;
 
-/* This routine builds:
-   *(id *)(EXP+20) expression which references the object id pointer.
-*/
-static tree
-build_indirect_object_id_exp (tree exp)
-{
-  tree dst_obj;
-  int  int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
-  int offset;
-  /* dst->object = [src->object retail]; In thid case 'object' is the field
-   of the object passed offset by: void* + int + int + void* + void *
-   This must match definition of Block_byref structs. */
-  offset = GET_MODE_SIZE (Pmode) + int_size + int_size + GET_MODE_SIZE (Pmode) +
-           GET_MODE_SIZE (Pmode);
-  dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
-                    build_int_cst (NULL_TREE, offset));
-  /* Type case to: 'id *' */
-  dst_obj = cast_to_pointer_to_id (dst_obj);
-  dst_obj = build_indirect_ref (dst_obj, "unary *");
-  return dst_obj;
-}
-
-
 /**
  This routine builds:
 
  void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
-                                   struct Block_byref_id_object *src) {
-   dst->object = [src->object retain];
- }
-*/
-static void synth_block_byref_id_object_copy_func (void)
+				   struct Block_byref_id_object *src) {
+   dst->object = [src->object retain];  // objective-c only
+   _Block_byref_assign_copy(&_dest->object, _src->object)  // or: c language
+ }  */
+static void
+synth_block_byref_id_object_copy_func (void)
 {
   tree stmt, fnbody;
   tree dst_arg, src_arg;
-  tree dst_obj, src_obj, retain_exp, store;
+  tree dst_obj, src_obj;
   struct c_arg_info * arg_info;
 
   gcc_assert (block_byref_id_object_copy);
@@ -3770,12 +3752,25 @@
   /* src_obj is: _src->object. */
   src_obj = build_indirect_object_id_exp (src_arg);
 
-  retain_exp = retain_block_component (src_obj);
-
-  /* dst->object = [src->object retain]; */
-  store = build_modify_expr (dst_obj, NOP_EXPR, retain_exp);
+  /* APPLE LOCAL begin radar 6180456 */
+  if (c_dialect_objc ())
+    {
+      tree retain_exp = retain_block_component (src_obj);
 
-  add_stmt (store);
+      /* dst->object = [src->object retain]; */
+      tree store = build_modify_expr (dst_obj, NOP_EXPR, retain_exp);
+      add_stmt (store);
+    }
+  else 
+    {
+      /* _Block_byref_assign_copy(&_dest->object, _src->object) */
+      tree func_params = tree_cons (NULL_TREE, build_fold_addr_expr (dst_obj),
+                                    tree_cons (NULL_TREE, src_obj,
+                                               NULL_TREE));
+      tree call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
+      add_stmt (call_exp);
+    }
+  /* APPLE LOCAL end radar 6180456 */
 
   fnbody = c_end_compound_stmt (stmt, true);
   add_stmt (fnbody);
@@ -3787,11 +3782,12 @@
 /**
   This routine builds:
 
- void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
-   [_src->object release];
- }
-*/
-static void synth_block_byref_id_object_dispose_func (void)
+  void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
+    [_src->object release];   // objective-c or:
+    _Block_byref_release(_src->object) // c language
+  }  */
+static void
+synth_block_byref_id_object_dispose_func (void)
 {
   tree stmt, fnbody;
   tree src_arg, src_obj, rel_exp;
@@ -3814,10 +3810,19 @@
 
   /* Body of the function. */
   stmt = c_begin_compound_stmt (true);
-  /* [_src->object release]; */
   src_obj = build_indirect_object_id_exp (src_arg);
 
-  rel_exp = release_block_component (src_obj);
+  /* APPLE LOCAL begin radar 6180456 */
+  if (c_dialect_objc ())
+    /* [_src->object release]; */
+    rel_exp = release_block_component (src_obj);
+  else
+    {
+      /* _Block_byref_release(_src->object) */
+      tree func_params = tree_cons (NULL_TREE, src_obj, NULL_TREE);
+      rel_exp = build_function_call (build_block_byref_release_decl (), func_params);
+    }
+  /* APPLE LOCAL end radar 6180456 */
   add_stmt (rel_exp);
 
   fnbody = c_end_compound_stmt (stmt, true);
@@ -3829,14 +3834,14 @@
 
 /* new_block_byref_decl - This routine changes a 'typex x' declared variable into:
 
- struct __Block_byref_x {
- struct Block_byref_x *forwarding;
- int32_t flags;
- int32_t size;
- void *ByrefKeepFuncPtr;    // Only if variable is __byref ObjC object
- void *ByrefDestroyFuncPtr; // Only if variable is __byref ObjC object
- typex x;
- } x;
+  struct __Block_byref_x {
+    struct Block_byref_x *forwarding;
+    int32_t flags;
+    int32_t size;
+    void *ByrefKeepFuncPtr;    // Only if variable is __byref ObjC object
+    void *ByrefDestroyFuncPtr; // Only if variable is __byref ObjC object
+    typex x;
+  } x;
 */
 
 static tree
@@ -3910,7 +3915,6 @@
 
    { &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
      &initializer-expr};
-
 */
 static tree
 init_byref_decl (tree decl, tree init)
@@ -3987,7 +3991,7 @@
   init =  build_constructor_from_list (block_byref_type, nreverse (initlist));
   return init;
 }
-/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ cr) */
 
 /* Finish processing of a declaration;
    install its initial value.
@@ -4015,7 +4019,7 @@
   /* Don't crash if parm is initialized.  */
   if (TREE_CODE (decl) == PARM_DECL)
     init = 0;
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ cq) */
   /* We build a new type for each local variable declared as __byref
      and initialize it to a list of initializers. */
   else if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
@@ -4035,7 +4039,7 @@
           current_scope->byref_in_current_scope = true;
 	}
     }
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+  /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ cq) */
   
   if (init)
     store_init_value (decl, init);
@@ -7950,6 +7954,7 @@
 tree
 build_block_byref_decl (tree name, tree decl, tree exp)
 {
+  struct c_scope *scope = current_scope;
   /* If it is already a byref declaration, do not add the pointer type
      because such declarations already have the pointer type
      added. This happens when we have two nested byref declarations in
@@ -7957,6 +7962,10 @@
   tree ptr_type = (TREE_CODE (decl) == VAR_DECL && BLOCK_DECL_BYREF (decl))
                    ? TREE_TYPE (decl) : build_pointer_type (TREE_TYPE (decl));
   tree byref_decl = build_decl (VAR_DECL, name, ptr_type);
+  /* APPLE LOCAL begin radars 6144664 & 6145471  */
+  DECL_SOURCE_LOCATION (byref_decl) = DECL_SOURCE_LOCATION 
+                                               (cur_block->helper_func_decl);
+  /* APPLE LOCAL end radars 6144664 & 6145471  */
   BLOCK_DECL_BYREF (byref_decl) = 1;
 
   /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
@@ -7967,10 +7976,15 @@
     }
   /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
 
+  /* In the presence of nested "{" 
+     move up the scope chain until reaching the main function body's scope.
+  */
+  while (scope && !scope->function_body)
+    scope = scope->outer;
   /* Current scope must be that of the main function body. */
-  gcc_assert (current_scope->function_body);
+  gcc_assert (scope && scope->function_body);
   bind (name, byref_decl,
-        current_scope, /*invisible=*/false, /*nested=*/false);
+        scope, /*invisible=*/false, /*nested=*/false);
   cur_block->block_byref_decl_list =
     tree_cons (NULL_TREE, byref_decl, cur_block->block_byref_decl_list);
   cur_block->block_original_byref_decl_list =
@@ -7995,28 +8009,28 @@
   if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
     decl = build_byref_local_var_access (decl, DECL_NAME (decl));
   else {
-    /* APPLE LOCAL begin radar 5988451 */
+    /* APPLE LOCAL begin radar 5988451 (C++ ch) */
     if (cur_block->prev_block_info) {
-      /* Traverse enclosing blocks. Insert a copied-in variable in each
-         enclosing block which has no declaration of this variable. This is
-         to ensure that the current (inner) block has the 'frozen' value of the
-         copied-in variable; which means the value of the copied in variable
-         is at the point of the block declaration and *not* when the inner block
-         is envoked.
-      */
+      /* Traverse enclosing blocks. Insert a copied-in variable in
+         each enclosing block which has no declaration of this
+         variable. This is to ensure that the current (inner) block
+         has the 'frozen' value of the copied-in variable; which means
+         the value of the copied in variable is at the point of the
+         block declaration and *not* when the inner block is
+         invoked.  */
       struct block_sema_info *cb = cur_block->prev_block_info;
       while (cb) {
         struct c_binding *b = I_SYMBOL_BINDING (name);
         /* Find the first declaration not in current block. */
-        while (b && b->decl 
-               && (TREE_CODE (b->decl) == VAR_DECL 
+        while (b && b->decl
+               && (TREE_CODE (b->decl) == VAR_DECL
                    || TREE_CODE (b->decl) == PARM_DECL)
                && b->depth >= cur_block->the_scope->depth)
           b = b->shadowed;
-        
+
         /* Is the next declaration not in enclosing block? */
-        if (b && b->decl 
-            && (TREE_CODE (b->decl) == VAR_DECL 
+        if (b && b->decl
+            && (TREE_CODE (b->decl) == VAR_DECL
                 || TREE_CODE (b->decl) == PARM_DECL)
             && b->depth < cb->the_scope->depth) {
           /* No declaration of variable seen in the block. Must insert one,
@@ -8029,16 +8043,20 @@
           cur_block = save_current_block;
           current_scope = save_scope;
         }
-        cb = cb->prev_block_info; 
+        cb = cb->prev_block_info;
       }
     }
-    /* APPLE LOCAL end radar 5988451 */
+    /* APPLE LOCAL end radar 5988451 (C++ ch) */
   }
   /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
 
   ref_decl = build_decl (VAR_DECL, name,
                          build_qualified_type (TREE_TYPE (decl),
                                                TYPE_QUAL_CONST));
+  /* APPLE LOCAL begin radars 6144664 & 6145471  */
+  DECL_SOURCE_LOCATION (ref_decl) = DECL_SOURCE_LOCATION 
+                                               (cur_block->helper_func_decl);
+  /* APPLE LOCAL end radars 6144664 & 6145471  */
   DECL_INITIAL (ref_decl) = error_mark_node;
   /* APPLE LOCAL radar 5805175 - blocks (C++ ch) */
   c_apply_type_quals_to_decl (TYPE_QUAL_CONST, ref_decl);
@@ -8152,7 +8170,9 @@
 begin_block (void)
 {
   struct block_sema_info *csi;
+#if 0
   push_scope ();
+#endif
   csi = (struct block_sema_info*)xcalloc (1, sizeof (struct block_sema_info));
   csi->prev_block_info = cur_block;
   cur_block = csi;
@@ -8164,7 +8184,9 @@
 {
   struct block_sema_info *csi = cur_block;
   cur_block = cur_block->prev_block_info;
+#if 0
   pop_scope ();
+#endif
   return csi;
 }
 
@@ -8175,13 +8197,13 @@
   return (cur_block && cur_block->the_scope == current_scope);
 }
 
-/* This routine returns 'true' if 'name' has a declaration inside
-   block, 'false' otherwise. If 'name' has no declaration in current
-   block, it returns in DECL the user declaration for 'name' found in
-   the enclosing scope. Note that if it is declared in current
-   declaration, it can be either a user declaration or a
-   byref/copied-in declaration added in current block's scope by
-   the compiler.  */
+/* This routine returns 'true' if 'name' has a declaration inside the
+   current block, 'false' otherwise.  If 'name' has no declaration in
+   the current block, it returns in DECL the user declaration for
+   'name' found in the enclosing scope.  Note that if it is declared
+   in current declaration, it can be either a user declaration or a
+   byref/copied-in declaration added in current block's scope by the
+   compiler.  */
 bool
 lookup_name_in_block (tree name, tree *decl)
 {
@@ -8204,7 +8226,7 @@
          enclosing block is found, it must be returned as this is
          where the variable in current (nested block) will have to get
          its value. */
-      while (b && b->decl 
+      while (b && b->decl
 	     && (TREE_CODE (b->decl) == VAR_DECL)
              && BLOCK_DECL_BYREF (b->decl))
         b = b->shadowed;
@@ -8245,6 +8267,8 @@
   TREE_PUBLIC (func_decl) = 0;
   TREE_USED (func_decl) = 1;
   TREE_NOTHROW (func_decl) = 0;
+  /* APPLE LOCAL radar 6172148 */
+  BLOCK_SYNTHESIZED_FUNC (func_decl) = 1;
   return func_decl;
 }
 
@@ -9274,7 +9298,7 @@
   code = TREE_CODE (typename);
   class = TREE_CODE_CLASS (code);
 
-  if (code != IDENTIFIER_NODE 
+  if (code != IDENTIFIER_NODE
       || class != tcc_exceptional)
     return retval;
 

Modified: llvm-gcc-4.2/trunk/gcc/c-parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-parser.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-parser.c Tue Sep  2 17:20:12 2008
@@ -2401,6 +2401,7 @@
       ret.spec = TREE_TYPE (expr.value);
       /* APPLE LOCAL begin radar 4204796 (in 4.2 n) */
       if (c_dialect_objc() 
+	  && ret.spec != error_mark_node
 	  && lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (ret.spec)))
 	ret.spec = build_qualified_type
 	  (ret.spec, (TYPE_QUALS (ret.spec) & ~TYPE_QUAL_VOLATILE));
@@ -9383,11 +9384,7 @@
 /* APPLE LOCAL begin radar 5732232 - blocks (C++ ce) */
 static tree block_copy_assign_decl;
 static tree block_destroy_decl;
-/* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
-static tree block_byref_assign_copy_decl;
-/* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ce) */
 
-/* APPLE LOCAL begin radar 6083129 - byref escapes (C++ ce) */
 void
 gen_block_byref_release_exp (tree var_decl)
 {
@@ -9395,7 +9392,6 @@
   if (cleanup)
     add_stmt (cleanup);
 }
-/* APPLE LOCAL end radar 6083129 - byref escapes (C++ ce) */
 
 bool building_block_byref_decl = false;
 static bool
@@ -9417,10 +9413,8 @@
     building_block_byref_decl = false;
     if (byref_decl_expr.value != error_mark_node &&
         !(TREE_CODE (byref_decl_expr.value) == VAR_DECL &&
-          /* APPLE LOCAL begin radar 5803600 (C++ ce) */
           (BLOCK_DECL_BYREF (byref_decl_expr.value) ||
            in_block_global_byref_list (byref_decl_expr.value))))
-          /* APPLE LOCAL end radar 5803600 (C++ ce) */
       error (
         "only a visible variable may be used in a block byref declaration");
   } while (c_parser_next_token_is (parser, CPP_COMMA));
@@ -9464,7 +9458,6 @@
       break;
     }
 
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
   /* Further check to see that we have __byref variables which require
      Copy/Dispose helpers. */
   for (chain = block_impl->block_byref_decl_list; chain;
@@ -9475,7 +9468,6 @@
 	block_impl->BlockHasByrefVar = TRUE;
 	break;
       }
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ce) */
 
   sprintf(buffer, "__block_%d", ++unique_count);
   push_to_top_level ();
@@ -9484,7 +9476,6 @@
   field_decl = build_decl (FIELD_DECL, get_identifier ("impl"),
                            TREE_TYPE (invoke_impl_ptr_type));
   field_decl_chain = field_decl;
-  /* APPLE LOCAL radar 5932809 - copyable byref blocks (C++ ce) */
   if (block_impl->BlockHasCopyDispose)
   {
     /* void *CopyFuncPtr; */
@@ -9495,12 +9486,10 @@
     field_decl = build_decl (FIELD_DECL, get_identifier ("DestroyFuncPtr"),
                              ptr_type_node);
     chainon (field_decl_chain, field_decl);
-    /* APPLE LOCAL begin radar 5988451 (C++ ce) */
     /* If inner block of a nested block has BlockHasCopyDispose, so
        does its outer block. */
     if (block_impl->prev_block_info)
       block_impl->prev_block_info->BlockHasCopyDispose = TRUE;
-    /* APPLE LOCAL end radar 5988451 (C++ ce) */
   }
 
   /* int x; // ref variable list ... */
@@ -9531,8 +9520,8 @@
 
 /**
  build_block_struct_initlist - builds the initializer list:
- { &_NSConcreteStackBlock // isa,
- BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE // flags,
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // isa,
+ BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // flags,
  sizeof(struct block_1),
  helper_1 },
  copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
@@ -9549,10 +9538,9 @@
   int size;
   tree helper_addr, chain, fields;
   unsigned flags = 0;
-  /* APPLE LOCAL radar 5811599 (C++ ce) */
   static tree NSConcreteStackBlock_decl = NULL_TREE;
+  static tree NSConcreteGlobalBlock_decl = NULL_TREE;
 
-  /* APPLE LOCAL radar 5932809 - copyable byref blocks (C++ ce) */
   if (block_impl->BlockHasCopyDispose)
     /* Note! setting of this flag merely indicates to the runtime that
        we have destroy_helper_block/copy_helper_block helper
@@ -9565,25 +9553,48 @@
 
   fields = TYPE_FIELDS (TREE_TYPE (invoke_impl_ptr_type));
 
-  /* APPLE LOCAL begin radar 5811599 (C++ ce) */
-  /* Find an existing declaration for _NSConcreteStackBlock or declare
-     extern void *_NSConcreteStackBlock; */
-  if (NSConcreteStackBlock_decl == NULL_TREE)
-    {
-      tree name_id = get_identifier("_NSConcreteStackBlock");
-      NSConcreteStackBlock_decl = lookup_name (name_id);
-      if (!NSConcreteStackBlock_decl)
-	{
-	  NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
-	  DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
-	  TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
-	  pushdecl_top_level (NSConcreteStackBlock_decl);
-	  rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
-	}
-    }
-  initlist = build_tree_list (fields,
-			      build_fold_addr_expr (NSConcreteStackBlock_decl));
-  /* APPLE LOCAL end radar 5811599 (C++ ce) */
+  if (!current_function_decl)
+    {
+      /* This is a global block. */
+      /* Find an existing declaration for _NSConcreteGlobalBlock or declare
+	 extern void *_NSConcreteGlobalBlock; */
+      if (NSConcreteGlobalBlock_decl == NULL_TREE)
+	{
+	  tree name_id = get_identifier("_NSConcreteGlobalBlock");
+	  NSConcreteGlobalBlock_decl = lookup_name (name_id);
+	  if (!NSConcreteGlobalBlock_decl)
+	    {
+	      NSConcreteGlobalBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+	      DECL_EXTERNAL (NSConcreteGlobalBlock_decl) = 1;
+	      TREE_PUBLIC (NSConcreteGlobalBlock_decl) = 1;
+	      pushdecl_top_level (NSConcreteGlobalBlock_decl);
+	      rest_of_decl_compilation (NSConcreteGlobalBlock_decl, 0, 0);
+	    }
+	}
+      initlist = build_tree_list (fields,
+				  build_fold_addr_expr (NSConcreteGlobalBlock_decl));
+      flags |= BLOCK_IS_GLOBAL;
+    }
+  else
+    {
+      /* Find an existing declaration for _NSConcreteStackBlock or declare
+	 extern void *_NSConcreteStackBlock; */
+      if (NSConcreteStackBlock_decl == NULL_TREE)
+	{
+	  tree name_id = get_identifier("_NSConcreteStackBlock");
+	  NSConcreteStackBlock_decl = lookup_name (name_id);
+	  if (!NSConcreteStackBlock_decl)
+	    {
+	      NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+	      DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
+	      TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
+	      pushdecl_top_level (NSConcreteStackBlock_decl);
+	      rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
+	    }
+	}
+      initlist = build_tree_list (fields,
+				  build_fold_addr_expr (NSConcreteStackBlock_decl));
+    }
   fields = TREE_CHAIN (fields);
 
   initlist = tree_cons (fields,
@@ -9603,7 +9614,6 @@
                                           nreverse (initlist));
   fields = TYPE_FIELDS (block_struct_type);
   initlist = build_tree_list (fields, initlist);
-  /* APPLE LOCAL radar 5932809 - copyable byref blocks (C++ ce) */
   if (block_impl->BlockHasCopyDispose)
     {
       fields = TREE_CHAIN (fields);
@@ -9618,18 +9628,15 @@
   for (chain = block_impl->block_original_ref_decl_list; chain;
        chain = TREE_CHAIN (chain))
     {
-      /* APPLE LOCAL begin radar 5834569 (C++ ce) */
       tree y = TREE_VALUE (chain);
       TREE_USED (y) = 1;
       fields = TREE_CHAIN (fields);
       initlist = tree_cons (fields, copy_in_object (y), initlist);
-      /* APPLE LOCAL end radar 5834569 (C++ ce) */
     }
   for (chain = block_impl->block_original_byref_decl_list; chain;
        chain = TREE_CHAIN (chain))
     {
       tree y = TREE_VALUE (chain);
-      /* APPLE LOCAL radar 5834569 (C++ ce) */
       TREE_USED (y) = 1;
       fields = TREE_CHAIN (fields);
       y = build_fold_addr_expr (y);
@@ -9655,8 +9662,8 @@
 
  3) build the temporary initialization:
  struct block_1 I = {
- { &_NSConcreteStackBlock // isa,
-   BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE // flags,
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // isa,
+   BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // flags,
    sizeof(struct block_1),
    helper_1 },
  copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
@@ -9698,6 +9705,12 @@
   bind = build3 (BIND_EXPR, void_type_node, block_holder_tmp_decl, exp, NULL);
   TREE_SIDE_EFFECTS (bind) = 1;
   add_stmt (bind);
+  /* Temporary representing a global block is made global static.  */
+  if (global_bindings_p ()) {
+    TREE_PUBLIC (block_holder_tmp_decl) = 0;
+    TREE_STATIC (block_holder_tmp_decl) = 1;
+    finish_decl (block_holder_tmp_decl, constructor, NULL_TREE);
+  }
   return block_holder_tmp_decl;
 }
 
@@ -9790,7 +9803,6 @@
       }
     }
 
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
   /* For each __byref declared variable used in |...| Must generate call to:
      _Block_byref_assign_copy(&_dest->myImportedBlock, _src->myImportedBlock)
   */
@@ -9807,30 +9819,13 @@
 						   DECL_NAME (p));
 
 	/* _Block_byref_assign_copy(&_dest->myImportedClosure, _src->myImportedClosure) */
-	/* Build a: void _Block_byref_assign_copy (void *, void *) if
-	   not done already. */
-	if (!block_byref_assign_copy_decl
-	    && !(block_byref_assign_copy_decl
-		 = lookup_name (get_identifier ("_Block_byref_assign_copy"))))
-	  {
-	    tree func_type
-	      = build_function_type (void_type_node,
-				     tree_cons (NULL_TREE, ptr_type_node,
-						tree_cons (NULL_TREE, ptr_type_node, void_list_node)));
-
-	    block_byref_assign_copy_decl
-	      = builtin_function ("_Block_byref_assign_copy", func_type,
-				  0, NOT_BUILT_IN, 0, NULL_TREE);
-	    TREE_NOTHROW (block_byref_assign_copy_decl) = 0;
-	  }
 	dst_block_component = build_fold_addr_expr (dst_block_component);
 	func_params = tree_cons (NULL_TREE, dst_block_component,
 				 tree_cons (NULL_TREE, src_block_component,
 					    NULL_TREE));
-	call_exp = build_function_call (block_byref_assign_copy_decl, func_params);
+	call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
 	add_stmt (call_exp);
       }
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ce) */
 
   fnbody = c_end_compound_stmt (stmt, true);
   add_stmt (fnbody);
@@ -9877,10 +9872,8 @@
         /* _Block_destroy(_src->myImportedClosure); */
         /* _Block_destroy (void *); */
         /* Build a: void _Block_destroy (void *) if not done already. */
-	/* APPLE LOCAL begin radar 5992047 (C++ ce) */
         if (!block_destroy_decl &&
 	    !(block_destroy_decl = lookup_name (get_identifier ("_Block_destroy"))))
-	/* APPLE LOCAL end radar 5992047 (C++ ce) */
         {
           tree func_type =
           build_function_type (void_type_node,
@@ -9903,7 +9896,6 @@
       }
     }
 
-  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ce) */
   /* For each __byref declared variable used in |...| Must generate call to:
    _Block_byref_release(_src->myImportedClosure)
    */
@@ -9924,7 +9916,6 @@
       call_exp = build_function_call (build_block_byref_release_decl (), func_params);
       add_stmt (call_exp);
     }
-  /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ce) */
 
   fnbody = c_end_compound_stmt (stmt, true);
   add_stmt (fnbody);
@@ -9955,8 +9946,6 @@
   tree restype, resdecl;
   tree fnbody, typelist;
   tree helper_function_type;
-  /* APPLE LOCAL radar 5824092 (C++ ce) */
-  bool at_file_scope = global_bindings_p ();
   tree block;
 
   c_parser_consume_token (parser); /* eat '^' */
@@ -10019,7 +10008,6 @@
    function, even though we do not know its type yet. */
   self_arg = build_decl (PARM_DECL, get_identifier ("_self"),
                          ptr_type_node);
-  /* APPLE LOCAL radar 5925784 (C++ ce) */
   TREE_USED (self_arg) = 1;  /* Prevent unused parameter '_self' warning. */
   TREE_CHAIN (self_arg) = cur_block->arg_info->parms;
   cur_block->arg_info->types = tree_cons (NULL_TREE, ptr_type_node, arg_type);
@@ -10028,10 +10016,10 @@
   /* Build the declaration of the helper function (we do not know its result
      type yet, so assume it is 'void'). Treat this as a nested function and use
      nested function infrastructure for its generation. */
-  sprintf (name, "__helper_%d", unique_count);
 
   ftype = build_function_type (void_type_node, cur_block->arg_info->types);
-  block_helper_function_decl = build_helper_func_decl (get_identifier (name),
+  /* APPLE LOCAL radar 6160536 */
+  block_helper_function_decl = build_helper_func_decl (build_block_helper_name (unique_count),
                                                          ftype);
   DECL_CONTEXT (block_helper_function_decl) = current_function_decl;
   BLOCK_HELPER_FUNC (block_helper_function_decl) = 1;
@@ -10039,12 +10027,10 @@
 
   push_function_context ();
   start_block_helper_function (cur_block->helper_func_decl, false);
-  /* APPLE LOCAL begin radar 5988451 (C++ ce) */
   /* Set block's scope to the scope of the helper function's main body.
      This is primarily used when nested blocks are declared. */
   /* FIXME: Name of objc_get_current_scope needs to get changed. */
   cur_block->the_scope = (struct c_scope*)objc_get_current_scope ();
-  /* APPLE LOCAL end radar 5988451 (C++ ce) */
 
   /* Enter parameter list to the scope of the helper function. */
   store_parm_decls_from (cur_block->arg_info);
@@ -10066,7 +10052,6 @@
   else {
     struct c_expr expr;
     stmt = c_begin_compound_stmt (true);
-    /* APPLE LOCAL radar 6034839 */
     error ("blocks require { }");
     expr = c_parser_cast_expression (parser, NULL);
     body = expr.value;
@@ -10092,13 +10077,6 @@
 
   restype = !cur_block->return_type ? void_type_node
                                       : cur_block->return_type;
-  /* APPLE LOCAL begin radar 5824092 (C++ ce) */
-  if (at_file_scope)
-  {
-    error ("block literal cannot be declared at global scope");
-    return clean_and_exit (block);
-  }
-  /* APPLE LOCAL end radar 5824092 (C++ ce) */
   if (restype == error_mark_node)
     return clean_and_exit (block);
 
@@ -10117,13 +10095,33 @@
 
   fnbody = c_end_compound_stmt (stmt, true);
   add_stmt (fnbody);
+
+  /* We are done parsing of the block body. Return type of block is now known.
+     We also know all we need to know about the helper function. So, fix its
+    type here. */
+  /* We moved this here because for global blocks, helper function body is
+     not nested and is gimplified in call to finish_function() and return type 
+     of the function must be correct. */
+  ftype = build_function_type (restype, arg_type);
+  /* Declare helper function; as in:
+     double helper_1(struct block_1 *ii, int z); */
+  typelist = TYPE_ARG_TYPES (ftype);
+  /* (struct block_1 *ii, int z, ...) */
+  typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+                        typelist);
+  helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
+  TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
+  /* Let tree builder know that we are done analyzing block's return type so it
+     does not do it twice (and produce bad return expression tree). This case is 
+     for global blocks as finish_function () for them builds AST for the entire
+     body of the function. */
+  cur_block->block_is_complete = true;
   finish_function ();
   pop_function_context ();
 
   /* Build the declaration for copy_helper_block and destroy_helper_block
    helper functions for later use. */
 
-  /* APPLE LOCAL radar 5932809 - copyable byref blocks (C++ ce) */
   if (cur_block->BlockHasCopyDispose)
   {
     /* void copy_helper_block (struct block*, struct block *); */
@@ -10147,20 +10145,6 @@
     synth_destroy_helper_block_func (cur_block);
   }
 
-
-  /* We are out of helper function scope and back in its enclosing scope.
-     We also know all we need to know about the helper function. So, fix its
-     type here. */
-  ftype = build_function_type (restype, arg_type);
-  /* Declare helper function; as in:
-     double helper_1(struct block_1 *ii, int z); */
-  typelist = TYPE_ARG_TYPES (ftype);
-  /* (struct block_1 *ii, int z, ...) */
-  typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
-                        typelist);
-  helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
-  TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
-
   block_impl = finish_block (block);
 
   /* Build unqiue name of the temporary used in code gen. */

Modified: llvm-gcc-4.2/trunk/gcc/c-typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-typeck.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-typeck.c Tue Sep  2 17:20:12 2008
@@ -75,13 +75,13 @@
 static int require_constant_value;
 static int require_constant_elements;
 
-/* APPLE LOCAL begin radar 5732232 - blocks */
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
 /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks  */
 /* Move declaration of invoke_impl_ptr_type to c-common.c  */
 /* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks  */
 static bool types_are_block_compatible (tree lhptee, tree rhptee);
 static tree build_block_call (tree, tree, tree);
-/* APPLE LOCAL end radar 5732232 - blocks */
+/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
 static bool null_pointer_constant_p (tree);
 static tree qualify_type (tree, tree);
 static int tagged_types_tu_compatible_p (tree, tree);
@@ -550,8 +550,12 @@
   if (t2 == error_mark_node)
     return t1;
 
-  gcc_assert (TREE_CODE (t1) == POINTER_TYPE
-	      && TREE_CODE (t2) == POINTER_TYPE);
+  /* APPLE LOCAL begin blocks 6065211 */
+  gcc_assert ((TREE_CODE (t1) == POINTER_TYPE
+	       && TREE_CODE (t2) == POINTER_TYPE)
+	      || (TREE_CODE (t1) == BLOCK_POINTER_TYPE
+		  && TREE_CODE (t2) == BLOCK_POINTER_TYPE));
+  /* APPLE LOCAL end blocks 6065211 */
 
   /* Merge the attributes.  */
   attributes = targetm.merge_type_attributes (t1, t2);
@@ -566,10 +570,15 @@
   if (TREE_CODE (mv2) != ARRAY_TYPE)
     mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
   target = composite_type (mv1, mv2);
-  t1 = build_pointer_type (c_build_qualified_type
-			   (target,
-			    TYPE_QUALS (pointed_to_1) |
-			    TYPE_QUALS (pointed_to_2)));
+  /* APPLE LOCAL begin blocks 6065211 */
+  t1 = c_build_qualified_type (target,
+			       TYPE_QUALS (pointed_to_1) |
+			       TYPE_QUALS (pointed_to_2));
+  if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
+    t1 = build_block_pointer_type (t1);
+  else
+    t1 = build_pointer_type (t1);
+  /* APPLE LOCAL end blocks 6065211 */
   return build_type_attribute_variant (t1, attributes);
 }
 
@@ -952,6 +961,15 @@
   int val;
   tree mvl, mvr;
 
+  /* APPLE LOCAL begin blocks 6065211 */
+  if (TREE_CODE (ttl) == BLOCK_POINTER_TYPE
+      && TREE_CODE (ttr) == BLOCK_POINTER_TYPE)
+    return types_are_block_compatible (TREE_TYPE (ttl),
+				       TREE_TYPE (ttr));
+  if (TREE_CODE (ttl) != TREE_CODE (ttr))
+    return 0;
+  /* APPLE LOCAL end blocks 6065211 */
+
   /* Do not lose qualifiers on element types of array types that are
      pointer targets by taking their TYPE_MAIN_VARIANT.  */
   mvl = TREE_TYPE (ttl);
@@ -2057,7 +2075,12 @@
 	}
 
       type = TREE_TYPE (TREE_TYPE (array));
-      if (TREE_CODE (type) != ARRAY_TYPE)
+      /* APPLE LOCAL begin radar 6164211 */
+      /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
+         only in <protocol> qualifications.  But when constructing an array type,
+         the protocols do matter and must be kept around.  */
+      if (TREE_CODE (type) != ARRAY_TYPE && !objc_is_object_ptr (type))
+      /* APPLE LOCAL end radar 6164211 */
 	type = TYPE_MAIN_VARIANT (type);
       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
       /* Array ref is const/volatile if the array elements are
@@ -2166,14 +2189,14 @@
 		      (TREE_CODE (decl) == VAR_DECL
 		       || TREE_CODE (decl) == PARM_DECL));
 	  gdecl = (TREE_CODE (decl) == VAR_DECL && 
-		   (DECL_EXTERNAL (decl)
-		    || (TREE_STATIC (decl) && !DECL_CONTEXT (decl))));
+	           /* APPLE LOCAL radar 6177162 */
+		   (DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
 	  /* Treat all 'global' variables as 'byref' by default. */
-          /* APPLE LOCAL begin radar 6014138 */
+          /* APPLE LOCAL begin radar 6014138 (C++ ci) */
 	  if (building_block_byref_decl || gdecl 
               || (TREE_CODE (decl) == VAR_DECL 
                   && COPYABLE_BYREF_LOCAL_VAR (decl)))
-          /* APPLE LOCAL end radar 6014138 */
+          /* APPLE LOCAL end radar 6014138 (C++ ci) */
 	    {
 	      /* APPLE LOCAL begin radar 5803600 (C++ ci) */
 	      /* byref globals are directly accessed. */
@@ -2751,7 +2774,8 @@
       else if ((invalid_func_diag =
 		targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
 	{
-	  error (invalid_func_diag);
+	  /* APPLE LOCAL default to Wformat-security 5764921 */
+	  error (invalid_func_diag, "");
 	  return error_mark_node;
 	}
       else
@@ -3070,7 +3094,8 @@
   if ((invalid_op_diag
        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
     {
-      error (invalid_op_diag);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      error (invalid_op_diag, "");
       return error_mark_node;
     }
 
@@ -3626,7 +3651,12 @@
 	pedwarn ("ISO C forbids conditional expr with only one void side");
       result_type = void_type_node;
     }
-  else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
+  /* APPLE LOCAL begin blocks 6065211 */
+  else if ((code1 == POINTER_TYPE
+	    || code1 == BLOCK_POINTER_TYPE)
+	   && (code2 == POINTER_TYPE
+	       || code2 == BLOCK_POINTER_TYPE))
+  /* APPLE LOCAL end blocks 6065211 */
     {
       if (comp_target_types (type1, type2))
 	result_type = common_pointer_type (type1, type2);
@@ -3634,6 +3664,14 @@
 	result_type = qualify_type (type2, type1);
       else if (null_pointer_constant_p (orig_op2))
 	result_type = qualify_type (type1, type2);
+      /* APPLE LOCAL begin blocks 6065211 */
+      else if (code2 == BLOCK_POINTER_TYPE
+	       && VOID_TYPE_P (TREE_TYPE (type1)))
+	result_type = type2;
+      else if (code1 == BLOCK_POINTER_TYPE
+	       && VOID_TYPE_P (TREE_TYPE (type2)))
+	result_type = type1;
+      /* APPLE LOCAL end blocks 6065211 */
       else if (VOID_TYPE_P (TREE_TYPE (type1)))
 	{
 	  if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
@@ -3684,27 +3722,27 @@
     }
   /* APPLE LOCAL begin radar 5732232 - blocks (C++ co) */
   /* APPLE LOCAL radar 5957801 */
-  else if (code1 == BLOCK_POINTER_TYPE && (code2 == INTEGER_TYPE || code2 == POINTER_TYPE))
-  {
-    if (!null_pointer_constant_p (orig_op2))
-      error ("block pointer/integer type mismatch in conditional expression");
-    else
+  else if (code1 == BLOCK_POINTER_TYPE && code2 == INTEGER_TYPE)
     {
-      op2 = convert (type1, null_pointer_node);
+      if (!null_pointer_constant_p (orig_op2))
+	error ("block pointer/integer type mismatch in conditional expression");
+      else
+	{
+	  op2 = convert (type1, null_pointer_node);
+	}
+      result_type = type1;
     }
-    result_type = type1;
-  }
   /* APPLE LOCAL radar 5957801 */
-  else if (code2 == BLOCK_POINTER_TYPE && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE))
-  {
-    if (!null_pointer_constant_p (orig_op1))
-      error ("block pointer/integer type mismatch in conditional expression");
-    else
+  else if (code2 == BLOCK_POINTER_TYPE && code1 == INTEGER_TYPE)
     {
-      op1 = convert (type2, null_pointer_node);
+      if (!null_pointer_constant_p (orig_op1))
+	error ("block pointer/integer type mismatch in conditional expression");
+      else
+	{
+	  op1 = convert (type2, null_pointer_node);
+	}
+      result_type = type2;
     }
-    result_type = type2;
-  }
   
   /* APPLE LOCAL end radar 5732232 - blocks (C++ co) */
   if (!result_type)
@@ -4039,15 +4077,15 @@
     return true;
   if (TREE_CODE (lhptee) == FUNCTION_TYPE && TREE_CODE (rhptee) == FUNCTION_TYPE)
     return functiontypes_are_block_compatible (lhptee, rhptee);
-  /* APPLE LOCAL begin radar 5882266 */
+  /* APPLE LOCAL begin radar 5882266 (C++ cm) */
   if (TREE_CODE (lhptee) == POINTER_TYPE && TREE_CODE (rhptee) == POINTER_TYPE)
     return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
-  /* APPLE LOCAL end radar 5882266 */
-  /* APPLE LOCAL begin radar 5988995 */
+  /* APPLE LOCAL end radar 5882266 (C++ cm) */
+  /* APPLE LOCAL begin radar 5988995 (C++ cm) */
   if (TREE_CODE (lhptee) == BLOCK_POINTER_TYPE
       && TREE_CODE (rhptee) == BLOCK_POINTER_TYPE)
     return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
-  /* APPLE LOCAL end radar 5988995 */
+  /* APPLE LOCAL end radar 5988995 (C++ cm) */
   return false;
 }
 
@@ -5324,7 +5362,10 @@
 	}
 
       /* Added to enable additional -Wmissing-format-attribute warnings.  */
-      if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
+      /* APPLE LOCAL begin radar 5822844 */
+      if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE ||
+	  TREE_CODE (TREE_TYPE (inside_init)) == BLOCK_POINTER_TYPE)
+      /* APPLE LOCAL end radar 5822844 */
 	inside_init = convert_for_assignment (type, inside_init, ic_init, NULL_TREE,
 					      NULL_TREE, 0);
       return inside_init;
@@ -7722,7 +7763,8 @@
   tree valtype, ret_stmt;
   bool no_warning = false;
   
-  if (cur_block) {
+  /* APPLE LOCAL radar 5822844 */
+  if (cur_block && !cur_block->block_is_complete) {
     /* APPLE LOCAL radar 6083129 - byref escapes (C++ cp) */
     release_all_local_byrefs_at_return ();
     retval = c_finish_block_return_stmt (retval);
@@ -8651,7 +8693,8 @@
   if ((invalid_op_diag
        = targetm.invalid_binary_op (code, type0, type1)))
     {
-      error (invalid_op_diag);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      error (invalid_op_diag, "");
       return error_mark_node;
     }
 
@@ -8842,7 +8885,10 @@
 	  && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
 	      || code1 == COMPLEX_TYPE))
 	short_compare = 1;
-      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+      /* APPLE LOCAL begin blocks 6065211 */
+      else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
+	       && (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
+      /* APPLE LOCAL end blocks 6065211 */
 	{
 	  tree tt0 = TREE_TYPE (type0);
 	  tree tt1 = TREE_TYPE (type1);
@@ -8851,6 +8897,12 @@
 	     and both must be object or both incomplete.  */
 	  if (comp_target_types (type0, type1))
 	    result_type = common_pointer_type (type0, type1);
+	  /* APPLE LOCAL begin blocks 6065211 */
+	  else if (code1 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt0))
+	    ;
+	  else if (code0 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt1))
+	    ;
+	  /* APPLE LOCAL end blocks 6065211 */
 	  else if (VOID_TYPE_P (tt0))
 	    {
 	      /* op0 != orig_op0 detects the case of something
@@ -8870,7 +8922,14 @@
 	  else
 	    /* Avoid warning about the volatile ObjC EH puts on decls.  */
 	    if (!objc_ok)
-	      pedwarn ("comparison of distinct pointer types lacks a cast");
+	      /* APPLE LOCAL begin blocks 6065211 */
+	      {
+		if (code0 == BLOCK_POINTER_TYPE || code1 == BLOCK_POINTER_TYPE)
+		  pedwarn ("comparison of distinct block types lacks a cast");
+		else
+		  pedwarn ("comparison of distinct pointer types lacks a cast");
+	      }
+	      /* APPLE LOCAL end blocks 6065211 */
 
 	  if (result_type == NULL_TREE)
 	    result_type = ptr_type_node;
@@ -8908,30 +8967,10 @@
 	  pedwarn ("comparison between pointer and integer");
 	}
       /* APPLE LOCAL begin radar 5732232 - blocks (C++ cl) */
-      if (code0 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op1))
+      else if (code0 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op1))
         result_type = type0;
-      else if (code1 == BLOCK_POINTER_TYPE 
-               && null_pointer_constant_p (orig_op0))
+      else if (code1 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op0))
         result_type = type1;
-      else if (code0 == BLOCK_POINTER_TYPE && code1 == BLOCK_POINTER_TYPE)
-	{
-	  if (!types_are_block_compatible (TREE_TYPE(type0), TREE_TYPE(type1)))
-	    error ("comparison of distinct block types (%qT and %qT)",
-		   type0, type1);
-	  result_type = type0;
-	}
-      else if (code0 == BLOCK_POINTER_TYPE && code1 == INTEGER_TYPE)
-	{
-	  result_type = type0;
-	  error ("comparison between pointer and integer (%qT and %qT)",
-		 type0, type1);
-	}
-      else if (code0 == INTEGER_TYPE && code1 == BLOCK_POINTER_TYPE)
-	{
-	  result_type = type1;
-	  error ("comparison between integer and pointer (%qT and %qT)",
-		 type0, type1);
-	}
       /* APPLE LOCAL end radar 5732232 - blocks (C++ cl) */
       break;
 

Modified: llvm-gcc-4.2/trunk/gcc/c.opt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c.opt?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c.opt (original)
+++ llvm-gcc-4.2/trunk/gcc/c.opt Tue Sep  2 17:20:12 2008
@@ -236,9 +236,11 @@
 C ObjC C++ ObjC++ Var(warn_format_nonliteral)
 Warn about format strings that are not literals
 
+; APPLE LOCAL begin default to Wformat-security 5764921
 Wformat-security
-C ObjC C++ ObjC++ Var(warn_format_security)
+C ObjC C++ ObjC++ Var(warn_format_security) Init(1)
 Warn about possible security problems with format functions
+; APPLE LOCAL end default to Wformat-security 5764921
 
 Wformat-y2k
 C ObjC C++ ObjC++ Var(warn_format_y2k)
@@ -360,9 +362,11 @@
 C++ ObjC++ Var(warn_nonvdtor)
 Warn about non-virtual destructors
 
+; APPLE LOCAL begin turn on for C++/Objective-C++
 Wnonnull
-C ObjC Var(warn_nonnull)
+C ObjC C++ ObjC++ Var(warn_nonnull)
 Warn about NULL being passed to argument slots marked as requiring non-NULL
+; APPLE LOCAL end turn on for C++/Objective-C++
 
 Wnormalized=
 C ObjC C++ ObjC++ Joined
@@ -769,6 +773,12 @@
 Enable Objective-C new property syntax and semantics
 ; APPLE LOCAL end objc new property - not for  merge to the FSF
 
+; APPLE LOCAL begin radar 5435299 
+fnew-property-ivar-synthesis
+ObjC ObjC++ Var(flag_new_property_ivar_synthesis) Init(0)
+Enable new style of fragile-ivar synthesis for properties
+; APPLE LOCAL end radar 5435299 
+
 ; APPLE LOCAL begin radar 4810609
 fobjc-gc-only
 ObjC ObjC++ Var(flag_objc_gc_only)  Init(0)

Modified: llvm-gcc-4.2/trunk/gcc/calls.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/calls.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/calls.c (original)
+++ llvm-gcc-4.2/trunk/gcc/calls.c Tue Sep  2 17:20:12 2008
@@ -910,7 +910,9 @@
 
 	    bytes -= bitsize / BITS_PER_UNIT;
 	    store_bit_field (reg, bitsize, endian_correction, word_mode,
-			     word);
+			     /* APPLE LOCAL begin 6020402 */
+			     word, NULL_TREE);
+			     /* APPLE LOCAL end 6020402 */
 	  }
       }
 }

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Tue Sep  2 17:20:12 2008
@@ -5837,13 +5837,20 @@
       gcc_assert (style);
       r11 = gen_rtx_REG (DImode, FIRST_REX_INT_REG + 3 /* R11 */);
       insn = emit_insn (gen_rtx_SET (DImode, r11, offset));
-      if (style < 0)
+      /* APPLE LOCAL async unwind info 5949469 */
+      if (style < 0 || flag_asynchronous_unwind_tables)
 	RTX_FRAME_RELATED_P (insn) = 1;
       insn = emit_insn (gen_pro_epilogue_adjust_stack_rex64_2 (dest, src, r11,
 							       offset));
     }
   if (style < 0)
     RTX_FRAME_RELATED_P (insn) = 1;
+  /* APPLE LOCAL begin async unwind info 5949350 5949469 */
+  else if (flag_asynchronous_unwind_tables
+	   && (src == hard_frame_pointer_rtx
+	       || src == stack_pointer_rtx))
+    RTX_FRAME_RELATED_P (insn) = 1;
+  /* APPLE LOCAL end async unwind info 5949350 5949469 */
 }
 
 /* Handle the TARGET_INTERNAL_ARG_POINTER hook.  */
@@ -6278,7 +6285,13 @@
       /* If not an i386, mov & pop is faster than "leave".  */
       else if (TARGET_USE_LEAVE || optimize_size
 	       || !cfun->machine->use_fast_prologue_epilogue)
-	emit_insn (TARGET_64BIT ? gen_leave_rex64 () : gen_leave ());
+	/* APPLE LOCAL begin async unwind info 5949350 */
+	{
+	  rtx insn = emit_insn (TARGET_64BIT ? gen_leave_rex64 () : gen_leave ());
+	  if (flag_asynchronous_unwind_tables)
+	    RTX_FRAME_RELATED_P (insn) = 1;
+	}
+	/* APPLE LOCAL end async unwind info 5949350 */
       else
 	{
 	  pro_epilogue_adjust_stack (stack_pointer_rtx,
@@ -6318,7 +6331,13 @@
 	  /* Leave results in shorter dependency chains on CPUs that are
 	     able to grok it fast.  */
 	  if (TARGET_USE_LEAVE)
-	    emit_insn (TARGET_64BIT ? gen_leave_rex64 () : gen_leave ());
+	    /* APPLE LOCAL begin async unwind info 5949350 */
+	    {
+	      rtx insn = emit_insn (TARGET_64BIT ? gen_leave_rex64 () : gen_leave ());
+	      if (flag_asynchronous_unwind_tables)
+		RTX_FRAME_RELATED_P (insn) = 1;
+	    }
+	  /* APPLE LOCAL end async unwind info 5949350 */
 	  else if (TARGET_64BIT)
 	    emit_insn (gen_popdi1 (hard_frame_pointer_rtx));
 	  else

Modified: llvm-gcc-4.2/trunk/gcc/cp/call.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/call.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/call.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/call.c Tue Sep  2 17:20:12 2008
@@ -708,7 +708,7 @@
 	  if (c_dialect_objc ())
 	    nfrom = objc_non_volatilized_type (nfrom);
 	  from = build_pointer_type
-	    (cp_build_qualified_type (void_type_node, 
+	    (cp_build_qualified_type (void_type_node,
 			              cp_type_quals (nfrom)));
 	  /* APPLE LOCAL end radar 4451818 */
 	  conv = build_conv (ck_ptr, from, conv);
@@ -758,8 +758,8 @@
 	       && COMPLETE_TYPE_P (TREE_TYPE (from)))
 	{
 	  /* APPLE LOCAL begin radar 4668465 */
-	  tree fr = c_dialect_objc () ? 
-		   objc_non_volatilized_type (TREE_TYPE (from)) 
+	  tree fr = c_dialect_objc () ?
+		   objc_non_volatilized_type (TREE_TYPE (from))
 		   : TREE_TYPE (from);
 	  from =
 	    cp_build_qualified_type (TREE_TYPE (to),
@@ -3576,11 +3576,10 @@
 	   /* APPLE LOCAL begin blocks 6040305 (co) */
 	       && (TYPE_PTR_P (arg2_type) || TYPE_PTR_TO_MEMBER_P (arg2_type)
 		   || TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE))
-	   /* APPLE LOCAL end blocks 6040305 (co) */
-	   || (TYPE_PTR_P (arg2_type) && TYPE_PTR_P (arg3_type))
-	   /* APPLE LOCAL begin blocks 6040305 (co) */
-	   || (TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE
-	       && TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE)
+	   || ((TYPE_PTR_P (arg2_type)
+		||  TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE)
+	       && (TYPE_PTR_P (arg3_type)
+		   || TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE))
 	   /* APPLE LOCAL end blocks 6040305 (co) */
 	   || (TYPE_PTRMEM_P (arg2_type) && TYPE_PTRMEM_P (arg3_type))
 	   || (TYPE_PTRMEMFUNC_P (arg2_type) && TYPE_PTRMEMFUNC_P (arg3_type)))

Modified: llvm-gcc-4.2/trunk/gcc/cp/decl.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/decl.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/decl.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/decl.c Tue Sep  2 17:20:12 2008
@@ -2475,11 +2475,11 @@
   /* FIXME finish this off. */
   struct c_scope *scope;
   struct c_binding *b;
-  
+
   gcc_assert (current_scope);
   if (flag_objc_gc_only || !current_scope->byref_in_current_scope)
     return;
-  
+
   scope = current_scope;
   while (scope && scope != file_scope)
   {
@@ -2496,7 +2496,7 @@
   }
 #endif
 }
-/* APPLE LOCAL begin blocks 6040305 (cp) */
+/* APPLE LOCAL end blocks 6040305 (cp) */
 
 /* Check that a new jump to a label DECL is OK.  Called by
    finish_goto_stmt.  */
@@ -4848,6 +4848,14 @@
      which reshape_init exists).  */
   if (!first_initializer_p)
     {
+      /* APPLE LOCAL begin 6052773 */
+      if (init == error_mark_node)
+	{
+	  ++d->cur;
+	  return init;
+	}
+      /* APPLE LOCAL end 6052773 */
+
       if (TREE_CODE (init) == CONSTRUCTOR)
 	{
 	  if (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))
@@ -5313,6 +5321,339 @@
   return false;
 }
 
+/* APPLE LOCAL begin blocks 6040305 (cr) */
+static tree block_byref_id_object_copy;
+static tree block_byref_id_object_dispose;
+
+/**
+ This routine builds:
+
+ void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
+				   struct Block_byref_id_object *src) {
+   dst->object = [src->object retain];
+ }  */
+static void
+synth_block_byref_id_object_copy_func (void)
+{
+  tree stmt;
+  tree dst_arg, src_arg;
+  tree dst_obj, src_obj;
+
+  gcc_assert (block_byref_id_object_copy);
+  /* Set up: (void* _dest, void*_src) parameters. */
+  dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
+                        ptr_type_node);
+  TREE_USED (dst_arg) = 1;
+  DECL_ARG_TYPE (dst_arg) = ptr_type_node;
+  src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+                        ptr_type_node);
+  TREE_USED (src_arg) = 1;
+  DECL_ARG_TYPE (src_arg) = ptr_type_node;
+  /* arg_info = xcalloc (1, sizeof (struct c_arg_info)); */
+  TREE_CHAIN (dst_arg) = src_arg;
+  /* arg_info->parms = dst_arg; */
+  /* arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+                               tree_cons (NULL_TREE,
+                                          ptr_type_node,
+                                          NULL_TREE)); */
+  DECL_ARGUMENTS (block_byref_id_object_copy) = dst_arg;
+  /* function header synthesis. */
+  push_function_context ();
+  /* start_block_helper_function (block_byref_id_object_copy, true); */
+  /* store_parm_decls_from (arg_info); */
+  start_preparsed_function (block_byref_id_object_copy,
+                            /*attrs*/NULL_TREE,
+                            SF_PRE_PARSED);
+
+  /* Body of the function. */
+  stmt = begin_compound_stmt (BCS_FN_BODY);
+  /* Build dst->object */
+  dst_obj = build_indirect_object_id_exp (dst_arg);
+
+
+  /* src_obj is: _src->object. */
+  src_obj = build_indirect_object_id_exp (src_arg);
+  /* APPLE LOCAL begin radar 6180456 */
+  if (c_dialect_objc ())
+    {
+      tree retain_exp = retain_block_component (src_obj);
+
+      /* dst->object = [src->object retain]; */
+      tree store = build_modify_expr (dst_obj, NOP_EXPR, retain_exp);
+      add_stmt (store);
+    }
+  else
+    {
+      /* _Block_byref_assign_copy(&_dest->object, _src->object) */
+      tree func_params = tree_cons (NULL_TREE, build_fold_addr_expr (dst_obj),
+                                    tree_cons (NULL_TREE, src_obj,
+                                               NULL_TREE));
+      tree call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
+      add_stmt (call_exp);
+    }
+  /* APPLE LOCAL end radar 6180456 */
+
+  finish_compound_stmt (stmt);
+  finish_function (0);
+  pop_function_context ();
+}
+
+/**
+  This routine builds:
+
+  void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
+    [_src->object release];  // objective-c++ or:
+    _Block_byref_release(_src->object) // c++ language
+  }  */
+static void synth_block_byref_id_object_dispose_func (void)
+{
+  tree stmt;
+  tree src_arg, src_obj, rel_exp;
+
+  gcc_assert (block_byref_id_object_dispose);
+  /* Set up: (void *_src) parameter. */
+  src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+                        ptr_type_node);
+  TREE_USED (src_arg) = 1;
+  DECL_ARG_TYPE (src_arg) = ptr_type_node;
+  /* arg_info = xcalloc (1, sizeof (struct c_arg_info));
+     arg_info->parms = src_arg;
+     arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+                                  NULL_TREE); */
+  DECL_ARGUMENTS (block_byref_id_object_dispose) = src_arg;
+  /* function header synthesis. */
+  push_function_context ();
+  /* start_block_helper_function (block_byref_id_object_dispose, true); */
+  /* store_parm_decls_from (arg_info); */
+  start_preparsed_function (block_byref_id_object_dispose,
+                            /*attrs*/NULL_TREE,
+                            SF_PRE_PARSED);
+
+  /* Body of the function. */
+  stmt = begin_compound_stmt (BCS_FN_BODY);
+  src_obj = build_indirect_object_id_exp (src_arg);
+
+  /* APPLE LOCAL begin radar 6180456 */
+  if (c_dialect_objc ())
+    /* [_src->object release]; */
+    rel_exp = release_block_component (src_obj);
+  else
+    {
+      /* _Block_byref_release(_src->object) */
+      tree func_params = tree_cons (NULL_TREE, src_obj, NULL_TREE);
+      rel_exp = build_function_call (build_block_byref_release_decl (), func_params);
+    }
+  /* APPLE LOCAL end radar 6180456 */
+  add_stmt (rel_exp);
+
+  finish_compound_stmt (stmt);
+  finish_function (0);
+  pop_function_context ();
+}
+
+static tree
+block_start_struct (tree name)
+{
+  tree s;
+  /* The idea here is to mimic the actions that the C++ parser takes when
+   constructing 'extern "C" struct NAME {'.  */
+  push_lang_context (lang_name_c);
+
+  s = xref_tag (record_type, name, ts_global, 0);
+  CLASSTYPE_DECLARED_CLASS (s) = 0;  /* this is a 'struct', not a 'class'.  */
+  xref_basetypes (s, NULL_TREE);     /* no base classes here!  */
+
+  return begin_class_definition (s, NULL_TREE);
+}
+
+static tree
+block_finish_struct (tree t, tree fieldlist)
+{
+  tree field, next_field;
+
+  for (field = fieldlist; field; field = next_field)
+  {
+    next_field = TREE_CHAIN (field);      /* insert one field at a time;  */
+    TREE_CHAIN (field) = NULL_TREE;       /* otherwise, grokfield croaks. */
+    finish_member_declaration (field);
+  }
+  t = finish_struct (t, NULL);
+  pop_lang_context ();
+
+  return t;
+}
+
+/* new_block_byref_decl - This routine changes a 'typex x' declared variable into:
+
+  struct __Block_byref_x {
+    struct Block_byref_x *forwarding;
+    int32_t flags;
+    int32_t size;
+    void *ByrefKeepFuncPtr;    // Only if variable is __byref ObjC object
+    void *ByrefDestroyFuncPtr; // Only if variable is __byref ObjC object
+    typex x;
+  } x;
+*/
+
+static tree
+new_block_byref_decl (tree decl)
+{
+  static int unique_count;
+  tree Block_byref_type;
+  tree fields = NULL_TREE, field;
+  const char *prefix = "__Block_byref_";
+  char *string = (char*)alloca (strlen (IDENTIFIER_POINTER (DECL_NAME (decl))) +
+				strlen (prefix) + 8 /* to hold the count */);
+
+  sprintf (string, "%s%d_%s", prefix, ++unique_count,
+           IDENTIFIER_POINTER (DECL_NAME (decl)));
+
+  push_to_top_level ();
+  /* Block_byref_type = start_struct (RECORD_TYPE, get_identifier (string)); */
+  Block_byref_type = block_start_struct (get_identifier (string));
+
+  /* struct Block_byref_x *forwarding; */
+  field = build_decl (FIELD_DECL, get_identifier ("forwarding"),
+                      build_pointer_type (Block_byref_type));
+  fields = field;
+
+  /* int32_t flags; */
+  field = build_decl (FIELD_DECL, get_identifier ("flags"),
+                      unsigned_type_node);
+  chainon (fields, field);
+
+  /* int32_t size; */
+  field = build_decl (FIELD_DECL, get_identifier ("size"),
+                      unsigned_type_node);
+  chainon (fields, field);
+
+  if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+  {
+    /* void *ByrefKeepFuncPtr; */
+    field = build_decl (FIELD_DECL, get_identifier ("ByrefKeepFuncPtr"),
+                        ptr_type_node);
+    chainon (fields, field);
+
+    /* void *ByrefDestroyFuncPtr; */
+    field = build_decl (FIELD_DECL, get_identifier ("ByrefDestroyFuncPtr"),
+                        ptr_type_node);
+    chainon (fields, field);
+  }
+
+  /* typex x; */
+  field = build_decl (FIELD_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+  chainon (fields, field);
+
+  /* finish_struct (Block_byref_type, field_decl_chain, NULL_TREE); */
+  block_finish_struct (Block_byref_type, fields);
+  pop_from_top_level ();
+
+  TREE_TYPE (decl) = Block_byref_type;
+  /* Force layout_decl to recompute these fields. */
+  DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0;
+  layout_decl (decl, 0);
+  return decl;
+}
+
+/* init_byref_decl - This routine builds the initializer for the __Block_byref_x
+   type in the form of:
+   { &x, 0, sizeof(struct __Block_byref_x), initializer-expr};
+
+   or:
+   { &x, 0, sizeof(struct __Block_byref_x)};
+   when INIT is NULL_TREE
+
+   For __byref ObjC objects, it also adds "byref_keep" and "byref_destroy"
+   Funtion pointers. So the most general initializers would be:
+
+   { &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
+     &initializer-expr};
+ */
+static tree
+init_byref_decl (tree decl, tree init)
+{
+  tree initlist;
+  tree block_byref_type = TREE_TYPE (decl);
+  int size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_byref_type));
+  unsigned flags = 0;
+  tree fields;
+
+  if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+    flags = BLOCK_HAS_COPY_DISPOSE;
+
+  fields = TYPE_FIELDS (block_byref_type);
+  initlist = tree_cons (fields,
+                        build_unary_op (ADDR_EXPR, decl, 0), 0);
+  fields = TREE_CHAIN (fields);
+
+  initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), flags),
+                        initlist);
+  fields = TREE_CHAIN (fields);
+  initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), size),
+                        initlist);
+  fields = TREE_CHAIN (fields);
+
+  if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+    {
+      char name [64];
+      /* Add &__Block_byref_id_object_copy, &__Block_byref_id_object_dispose
+	 initializers. */
+      if (!block_byref_id_object_copy)
+	{
+	  tree func_type;
+	  push_lang_context (lang_name_c);
+	  /* Build a void __Block_byref_id_object_copy(void*, void*) type. */
+	  func_type =
+	    build_function_type (void_type_node,
+				 tree_cons (NULL_TREE, ptr_type_node,
+					    tree_cons (NULL_TREE, ptr_type_node,
+						       void_list_node)));
+	  strcpy (name, "__Block_byref_id_object_copy");
+	  block_byref_id_object_copy = build_helper_func_decl (get_identifier (name),
+							       func_type);
+	  DECL_CONTEXT (block_byref_id_object_copy) = current_function_decl;
+	  /* Synthesize function definition. */
+	  synth_block_byref_id_object_copy_func ();
+	  pop_lang_context ();
+	}
+      initlist = tree_cons (fields,
+			    build_fold_addr_expr (block_byref_id_object_copy),
+			    initlist);
+      fields = TREE_CHAIN (fields);
+
+      if (!block_byref_id_object_dispose)
+	{
+	  tree func_type;
+	  push_lang_context (lang_name_c);
+	  /* Synthesize void __Block_byref_id_object_dispose (void*) and
+	     build &__Block_byref_id_object_dispose. */
+	  func_type =
+	    build_function_type (void_type_node,
+				 tree_cons (NULL_TREE, ptr_type_node, void_list_node));
+	  strcpy (name, "__Block_byref_id_object_dispose");
+	  block_byref_id_object_dispose = build_helper_func_decl (get_identifier (name),
+								  func_type);
+	  DECL_CONTEXT (block_byref_id_object_dispose) = current_function_decl;
+	  /* Synthesize function definition. */
+	  synth_block_byref_id_object_dispose_func ();
+	  pop_lang_context ();
+	}
+      initlist = tree_cons (fields,
+			    build_fold_addr_expr (block_byref_id_object_dispose),
+			    initlist);
+      fields = TREE_CHAIN (fields);
+    }
+
+  if (init)
+    {
+      init = digest_init (TREE_TYPE (fields), init);
+      initlist = tree_cons (fields, init, initlist);
+    }
+  init =  build_constructor_from_list (block_byref_type, nreverse (initlist));
+  return init;
+}
+/* APPLE LOCAL end blocks 6040305 (cr) */
+
 /* Finish processing of a declaration;
    install its line number and initial value.
    If the length of an array type is not known before,
@@ -5448,6 +5789,25 @@
       if (DECL_THREAD_LOCAL_P (decl) && !pod_type_p (TREE_TYPE (decl)))
 	error ("%qD cannot be thread-local because it has non-POD type %qT",
 	       decl, TREE_TYPE (decl));
+      /* APPLE LOCAL begin blocks 6040305 (cq) */
+      if (COPYABLE_BYREF_LOCAL_VAR (decl)) {
+        if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
+        {
+	    warning (0,
+		     "__byref attribute is only allowed on local variables - ignored");
+	    COPYABLE_BYREF_LOCAL_VAR (decl) = 0;
+	    COPYABLE_BYREF_LOCAL_NONPOD (decl) = 0;
+	  }
+        else
+	  {
+	    decl = new_block_byref_decl (decl);
+	    if (! flag_objc_gc_only)
+	      push_cleanup (decl, build_block_byref_release_exp (decl), false);
+	    init = init_byref_decl (decl, init);
+	  }
+      }
+      /* APPLE LOCAL end blocks 6040305 (cq) */
+      
       /* If this is a local variable that will need a mangled name,
 	 register it now.  We must do this before processing the
 	 initializer for the variable, since the initialization might
@@ -5916,7 +6276,7 @@
   /* APPLE LOCAL begin radar 5733674 */
   if (c_dialect_objc () && flag_objc_gc && init && TREE_CODE (init) == INIT_EXPR)
   {
-    tree result = objc_generate_write_barrier (TREE_OPERAND (init, 0), 
+    tree result = objc_generate_write_barrier (TREE_OPERAND (init, 0),
                                                INIT_EXPR, TREE_OPERAND (init, 1));
     if (result)
       init = result;

Modified: llvm-gcc-4.2/trunk/gcc/cp/decl2.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/decl2.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/decl2.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/decl2.c Tue Sep  2 17:20:12 2008
@@ -1895,7 +1895,9 @@
 	if (subvis == VISIBILITY_ANON)
           /* LLVM LOCAL begin - Fix for GCC PR c++/29365 */
 	  {
+#ifdef ENABLE_LLVM
 	    if (!in_main_input_context ())
+#endif
 	      warning (0, "\
 %qT has a field %qD whose type uses the anonymous namespace",
 		   type, t);
@@ -1917,7 +1919,9 @@
       if (subvis == VISIBILITY_ANON)
         /* LLVM LOCAL begin - Fix for GCC PR c++/29365 */
         {
+#ifdef ENABLE_LLVM
 	  if (!in_main_input_context())
+#endif
 	    warning (0, "\
 %qT has a base %qT whose type uses the anonymous namespace",
 		 type, TREE_TYPE (t));

Modified: llvm-gcc-4.2/trunk/gcc/cp/parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/parser.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/parser.c Tue Sep  2 17:20:12 2008
@@ -20496,15 +20496,14 @@
 tree
 build_component_ref (tree e, tree member)
 {
-  /* See declare_block_prologue_local_vars for code to find
-     FIELD_DECLs, if the below doesn't work.  */
+  if (!DECL_P (member))
+    member = lookup_member (TREE_TYPE (e), member, 0, 0);
   return build_class_member_access_expr (e, member,
 					 NULL_TREE, false);
 }
 
 static tree block_copy_assign_decl;
 static tree block_destroy_decl;
-static tree block_byref_assign_copy_decl;
 
 /** build_block_struct_type -
  struct block_1 {
@@ -20614,8 +20613,8 @@
 
 /**
  build_block_struct_initlist - builds the initializer list:
- { &_NSConcreteStackBlock // isa,
- BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE // flags,
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // isa,
+ BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // flags,
  sizeof(struct block_1),
  helper_1 },
  copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
@@ -20633,6 +20632,7 @@
   tree helper_addr, chain, fields;
   unsigned flags = 0;
   static tree NSConcreteStackBlock_decl = NULL_TREE;
+  static tree NSConcreteGlobalBlock_decl = NULL_TREE;
 
   if (block_impl->BlockHasCopyDispose)
     /* Note! setting of this flag merely indicates to the runtime that
@@ -20646,23 +20646,48 @@
 
   fields = TYPE_FIELDS (TREE_TYPE (invoke_impl_ptr_type));
 
-  /* Find an existing declaration for _NSConcreteStackBlock or declare
-     extern void *_NSConcreteStackBlock; */
-  if (NSConcreteStackBlock_decl == NULL_TREE)
-    {
-      tree name_id = get_identifier("_NSConcreteStackBlock");
-      NSConcreteStackBlock_decl = lookup_name (name_id);
-      if (!NSConcreteStackBlock_decl)
+  if (!current_function_decl)
+    {
+      /* This is a global block. */
+      /* Find an existing declaration for _NSConcreteGlobalBlock or declare
+	 extern void *_NSConcreteGlobalBlock; */
+      if (NSConcreteGlobalBlock_decl == NULL_TREE)
 	{
-	  NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
-	  DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
-	  TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
-	  pushdecl_top_level (NSConcreteStackBlock_decl);
-	  rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
+	  tree name_id = get_identifier("_NSConcreteGlobalBlock");
+	  NSConcreteGlobalBlock_decl = lookup_name (name_id);
+	  if (!NSConcreteGlobalBlock_decl)
+	    {
+	      NSConcreteGlobalBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+	      DECL_EXTERNAL (NSConcreteGlobalBlock_decl) = 1;
+	      TREE_PUBLIC (NSConcreteGlobalBlock_decl) = 1;
+	      pushdecl_top_level (NSConcreteGlobalBlock_decl);
+	      rest_of_decl_compilation (NSConcreteGlobalBlock_decl, 0, 0);
+	    }
 	}
+      initlist = build_tree_list (fields,
+				  build_fold_addr_expr (NSConcreteGlobalBlock_decl));
+      flags |= BLOCK_IS_GLOBAL;
+    }
+  else
+    {
+      /* Find an existing declaration for _NSConcreteStackBlock or declare
+	 extern void *_NSConcreteStackBlock; */
+      if (NSConcreteStackBlock_decl == NULL_TREE)
+	{
+	  tree name_id = get_identifier("_NSConcreteStackBlock");
+	  NSConcreteStackBlock_decl = lookup_name (name_id);
+	  if (!NSConcreteStackBlock_decl)
+	    {
+	      NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+	      DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
+	      TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
+	      pushdecl_top_level (NSConcreteStackBlock_decl);
+	      rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
+	    }
+	}
+      initlist = build_tree_list (fields,
+				  build_fold_addr_expr (NSConcreteStackBlock_decl));
     }
-  initlist = build_tree_list (fields,
-			      build_fold_addr_expr (NSConcreteStackBlock_decl));
   fields = TREE_CHAIN (fields);
 
   initlist = tree_cons (fields,
@@ -20675,6 +20700,7 @@
                         initlist);
   fields = TREE_CHAIN (fields);
   helper_addr = build_fold_addr_expr (block_impl->helper_func_decl);
+  /* mark_used (block_impl->helper_func_decl); */
   helper_addr = convert (ptr_type_node, helper_addr);
   initlist = tree_cons (fields, helper_addr, initlist);
   gcc_assert (invoke_impl_ptr_type);
@@ -20731,8 +20757,8 @@
 
  3) build the temporary initialization:
  struct block_1 I = {
- { &_NSConcreteStackBlock // isa,
-   BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE // flags,
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // isa,
+   BLOCK_NO_COPY | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // flags,
    sizeof(struct block_1),
    helper_1 },
  copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
@@ -20774,6 +20800,12 @@
   bind = build3 (BIND_EXPR, void_type_node, block_holder_tmp_decl, exp, NULL);
   TREE_SIDE_EFFECTS (bind) = 1;
   add_stmt (bind);
+  /* Temporary representing a global block is made global static.  */
+  if (global_bindings_p ()) {
+    TREE_PUBLIC (block_holder_tmp_decl) = 0;
+    TREE_STATIC (block_holder_tmp_decl) = 1;
+    finish_decl (block_holder_tmp_decl, constructor, NULL_TREE);
+  }
   return block_holder_tmp_decl;
 }
 
@@ -20782,7 +20814,8 @@
 {
   pop_function_context ();
   pop_lang_context ();
-  free (finish_block (block));
+  if (current_function_decl)
+    free (finish_block (block));
   return error_mark_node;
 }
 
@@ -20889,32 +20922,19 @@
 						   DECL_NAME (p));
 
 	/* _Block_byref_assign_copy(&_dest->myImportedClosure, _src->myImportedClosure) */
-	/* Build a: void _Block_byref_assign_copy (void *, void *) if
-	   not done already. */
-	if (!block_byref_assign_copy_decl
-	    && !(block_byref_assign_copy_decl
-		 = lookup_name (get_identifier ("_Block_byref_assign_copy"))))
-	  {
-	    tree func_type
-	      = build_function_type (void_type_node,
-				     tree_cons (NULL_TREE, ptr_type_node,
-						tree_cons (NULL_TREE, ptr_type_node, void_list_node)));
-
-	    block_byref_assign_copy_decl
-	      = builtin_function ("_Block_byref_assign_copy", func_type,
-				  0, NOT_BUILT_IN, 0, NULL_TREE);
-	    TREE_NOTHROW (block_byref_assign_copy_decl) = 0;
-	  }
 	dst_block_component = build_fold_addr_expr (dst_block_component);
 	func_params = tree_cons (NULL_TREE, dst_block_component,
 				 tree_cons (NULL_TREE, src_block_component,
 					    NULL_TREE));
-	call_exp = build_function_call (block_byref_assign_copy_decl, func_params);
+	call_exp = build_function_call (build_block_byref_assign_copy_decl (), func_params);
 	add_stmt (call_exp);
       }
 
   finish_compound_stmt (stmt);
   finish_function (0);
+  /* Hum, would be nice if someone else did this for us.  */
+  if (global_bindings_p ())
+    cgraph_finalize_function (block_impl->copy_helper_func_decl, false);
   pop_function_context ();
   /* free (arg_info); */
 }
@@ -21011,6 +21031,9 @@
 
   finish_compound_stmt (stmt);
   finish_function (0);
+  /* Hum, would be nice if someone else did this for us.  */
+  if (global_bindings_p ())
+    cgraph_finalize_function (block_impl->destroy_helper_func_decl, false);
   pop_function_context ();
 }
 
@@ -21036,7 +21059,6 @@
   tree restype, resdecl;
   tree typelist;
   tree helper_function_type;
-  bool at_file_scope = global_bindings_p ();
   tree block;
 
   cp_lexer_consume_token (parser->lexer); /* eat '^' */
@@ -21105,13 +21127,14 @@
   /* Build the declaration of the helper function (we do not know its result
      type yet, so assume it is 'void'). Treat this as a nested function and use
      nested function infrastructure for its generation. */
-  sprintf (name, "__helper_%d", unique_count);
 
   push_lang_context (lang_name_c);
   ftype = build_function_type (void_type_node, arg_type);
-  block_helper_function_decl = build_helper_func_decl (get_identifier (name),
+  /* APPLE LOCAL radar 6160536 */
+  block_helper_function_decl = build_helper_func_decl (build_block_helper_name (unique_count),
 						       ftype);
-  DECL_NO_STATIC_CHAIN (current_function_decl) = 0;
+  if (current_function_decl)
+    DECL_NO_STATIC_CHAIN (current_function_decl) = 0;
   DECL_CONTEXT (block_helper_function_decl) = current_function_decl;
   BLOCK_HELPER_FUNC (block_helper_function_decl) = 1;
   cur_block->helper_func_decl = block_helper_function_decl;
@@ -21126,10 +21149,6 @@
 			    /*attrs*/NULL_TREE,
 			    SF_PRE_PARSED);
 
-  /* Set block's scope to the scope of the helper function's main body.
-     This is primarily used when nested blocks are declared. */
-  cur_block->cp_the_scope = current_binding_level;
-
   /* Start parsing body or expression part of the block literal. */
   {
     unsigned save = parser->in_statement;
@@ -21137,6 +21156,9 @@
      emit the proper error message in c_finish_bc_stmt.  */
     parser->in_statement = 0;
     stmt = begin_compound_stmt (BCS_FN_BODY);
+    /* Set block's scope to the scope of the helper function's main body.
+       This is primarily used when nested blocks are declared. */
+    cur_block->cp_the_scope = current_binding_level;
     cp_parser_compound_statement (parser, NULL, false, false);
     parser->in_statement = save;
   }
@@ -21146,11 +21168,6 @@
 
   restype = !cur_block->return_type ? void_type_node
                                     : cur_block->return_type;
-  if (at_file_scope)
-  {
-    error ("block literal cannot be declared at global scope");
-    return clean_and_exit (block);
-  }
   if (restype == error_mark_node)
     return clean_and_exit (block);
 
@@ -21169,8 +21186,32 @@
 
   finish_compound_stmt (stmt);
   /* add_stmt (fnbody); */
+
+  /* We are done parsing of the block body. Return type of block is now known.
+     We also know all we need to know about the helper function. So, fix its
+    type here. */
+  /* We moved this here because for global blocks, helper function body is
+     not nested and is gimplified in call to finish_function() and return type 
+     of the function must be correct. */
+  ftype = build_function_type (restype, TREE_CHAIN (arg_type));
+  /* Declare helper function; as in:
+     double helper_1(struct block_1 *ii, int z); */
+  typelist = TYPE_ARG_TYPES (ftype);
+  /* (struct block_1 *ii, int z, ...) */
+  typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+                        typelist);
+  helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
+  TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
+  /* Let tree builder know that we are done analyzing block's return type so it
+     does not do it twice (and produce bad return expression tree). This case is 
+     for global blocks as finish_function () for them builds AST for the entire
+     body of the function. */
+  cur_block->block_is_complete = true;
   finish_function (0);
   pop_function_context ();
+  /* Hum, would be nice if someone else did this for us.  */
+  if (global_bindings_p ())
+    cgraph_finalize_function (cur_block->helper_func_decl, false);
   pop_lang_context ();
 
   /* Build the declaration for copy_helper_block and destroy_helper_block
@@ -21178,15 +21219,19 @@
 
   if (cur_block->BlockHasCopyDispose)
   {
+    tree s_ftype;
+
+    push_lang_context (lang_name_c);
     /* void copy_helper_block (struct block*, struct block *); */
-    tree s_ftype = build_function_type (void_type_node,
-                                        tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
-                                                   tree_cons (NULL_TREE,
-                                                              cur_block->block_arg_ptr_type,
-                                                              void_list_node)));
+    s_ftype = build_function_type (void_type_node,
+				   tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+					      tree_cons (NULL_TREE,
+							 cur_block->block_arg_ptr_type,
+							 void_list_node)));
     sprintf (name, "__copy_helper_block_%d", unique_count);
     cur_block->copy_helper_func_decl =
     build_helper_func_decl (get_identifier (name), s_ftype);
+    DECL_CONTEXT (cur_block->copy_helper_func_decl) = current_function_decl;
     synth_copy_helper_block_func (cur_block);
 
     /* void destroy_helper_block (struct block*); */
@@ -21196,23 +21241,11 @@
     sprintf (name, "__destroy_helper_block_%d", unique_count);
     cur_block->destroy_helper_func_decl =
     build_helper_func_decl (get_identifier (name), s_ftype);
+    DECL_CONTEXT (cur_block->destroy_helper_func_decl) = current_function_decl;
     synth_destroy_helper_block_func (cur_block);
+    pop_lang_context ();
   }
 
-
-  /* We are out of helper function scope and back in its enclosing scope.
-     We also know all we need to know about the helper function. So, fix its
-     type here. */
-  ftype = build_function_type (restype, TREE_CHAIN (arg_type));
-  /* Declare helper function; as in:
-     double helper_1(struct block_1 *ii, int z); */
-  typelist = TYPE_ARG_TYPES (ftype);
-  /* (struct block_1 *ii, int z, ...) */
-  typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
-                        typelist);
-  helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
-  TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
-
   block_impl = finish_block (block);
 
   /* Build unqiue name of the temporary used in code gen. */
@@ -21265,6 +21298,7 @@
   /* Current scope must be that of the main function body. */
   /* FIXME gcc_assert (current_scope->function_body);*/
   pushdecl (byref_decl);
+  mark_used (byref_decl);
   /* APPLE LOCAL begin radar 6083129 -  byref escapes (cp) */
   /* FIXME: finish this off, ensure the decl is scoped appropriately
      for when we want the cleanup to run.  */
@@ -21275,6 +21309,10 @@
     tree_cons (NULL_TREE, byref_decl, cur_block->block_byref_decl_list);
   cur_block->block_original_byref_decl_list =
     tree_cons (NULL_TREE, exp, cur_block->block_original_byref_decl_list);
+  /* APPLE LOCAL begin radar 6144664  */
+  DECL_SOURCE_LOCATION (byref_decl)
+    = DECL_SOURCE_LOCATION (cur_block->helper_func_decl);
+  /* APPLE LOCAL end radar 6144664  */
   return byref_decl;
 }
 
@@ -21289,6 +21327,8 @@
 tree
 build_block_ref_decl (tree name, tree decl)
 {
+  /* FIXME - Broken, should be found via objc runtime testcases.  */
+  /* FIXME - Don't use DECL_CONTEXT on any helpers */
   tree ref_decl;
   /* 'decl' was previously declared as __block.  Simply, copy the value
      embedded in the above variable. */
@@ -21296,13 +21336,13 @@
     decl = build_byref_local_var_access (decl, DECL_NAME (decl));
   else {
     if (cur_block->prev_block_info) {
-      /* Traverse enclosing blocks. Insert a copied-in variable in each
-         enclosing block which has no declaration of this variable. This is
-         to ensure that the current (inner) block has the 'frozen' value of the
-         copied-in variable; which means the value of the copied in variable
-         is at the point of the block declaration and *not* when the inner block
-         is invoked.
-      */
+      /* Traverse enclosing blocks. Insert a copied-in variable in
+         each enclosing block which has no declaration of this
+         variable. This is to ensure that the current (inner) block
+         has the 'frozen' value of the copied-in variable; which means
+         the value of the copied in variable is at the point of the
+         block declaration and *not* when the inner block is
+         invoked.  */
       struct block_sema_info *cb = cur_block->prev_block_info;
       while (cb) {
         struct cxx_binding *b = I_SYMBOL_BINDING (name);
@@ -21355,6 +21395,10 @@
   ref_decl = build_decl (VAR_DECL, name,
                          build_qualified_type (TREE_TYPE (decl),
                                                TYPE_QUAL_CONST));
+  /* APPLE LOCAL begin radar 6144664  */
+  DECL_SOURCE_LOCATION (ref_decl) = DECL_SOURCE_LOCATION 
+                                                 (cur_block->helper_func_decl);
+  /* APPLE LOCAL end radar 6144664  */
   DECL_CONTEXT (ref_decl) = current_function_decl;
   DECL_INITIAL (ref_decl) = error_mark_node;
   c_apply_type_quals_to_decl (TYPE_QUAL_CONST, ref_decl);
@@ -21468,6 +21512,8 @@
 bool
 lookup_name_in_block (tree name, tree *decl)
 {
+  /* FIXME - Broken, should be found via objc runtime testcases.  */
+  /* FIXME - Don't use DECL_CONTEXT on any helpers */
   cxx_binding *b = I_SYMBOL_BINDING (name);
   if (b && b->declared_in_block
       && DECL_CONTEXT (BINDING_VALUE (b)) == current_function_decl)
@@ -21500,6 +21546,8 @@
   TREE_PUBLIC (func_decl) = 0;
   TREE_USED (func_decl) = 1;
   TREE_NOTHROW (func_decl) = 0;
+  /* APPLE LOCAL radar 6172148 */
+  BLOCK_SYNTHESIZED_FUNC (func_decl) = 1;
   retrofit_lang_decl (func_decl);
   return func_decl;
 }
@@ -21517,10 +21565,8 @@
   tree decl_stmt;
 
   decl = component;
-  component = lookup_member (TREE_TYPE (TREE_TYPE (self_parm)),
-			     DECL_NAME (component), 0, 0);
   block_component = build_component_ref (build_indirect_ref (self_parm, "->"),
-					 component);
+					 DECL_NAME (component));
   gcc_assert (block_component);
   DECL_EXTERNAL (decl) = 0;
   TREE_STATIC (decl) = 0;
@@ -21532,6 +21578,9 @@
   i = tsi_start (stmt);
   decl_stmt = build_stmt (DECL_EXPR, decl);
   SET_EXPR_LOCATION (decl_stmt, DECL_SOURCE_LOCATION (decl));
+  decl_stmt = build3 (BIND_EXPR, void_type_node, decl, decl_stmt, NULL);
+  TREE_SIDE_EFFECTS (decl_stmt) = 1;
+
   tsi_link_before (&i, decl_stmt, TSI_SAME_STMT);
 }
 

Modified: llvm-gcc-4.2/trunk/gcc/cp/semantics.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/semantics.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/semantics.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/semantics.c Tue Sep  2 17:20:12 2008
@@ -774,11 +774,11 @@
 
   expr = check_return_expr (expr, &no_warning);
 
-  /* APPLE LOCAL begin radar 6040305 - blocks */
+  /* APPLE LOCAL begin blocks 6040305 */
   if (current_function_decl && BLOCK_HELPER_FUNC (current_function_decl)
       && !cur_block)
     return expr;
-  /* APPLE LOCAL end radar 6040305 - blocks */
+  /* APPLE LOCAL end blocks 6040305 */
 
   if (flag_openmp && !check_omp_return ())
     return error_mark_node;
@@ -2942,12 +2942,10 @@
 		  (TREE_CODE (decl) == VAR_DECL
 		   || TREE_CODE (decl) == PARM_DECL));
       gdecl = (TREE_CODE (decl) == VAR_DECL && 
-	       (DECL_EXTERNAL (decl)
-		|| (TREE_STATIC (decl)
-		    && (!DECL_CONTEXT (decl)
-			|| DECL_NAMESPACE_SCOPE_P (decl)))));
+	       (DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
       /* Treat all 'global' variables as 'byref' by default. */
-      if (gdecl)
+      if (gdecl
+	  || (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
 	{
 	  /* byref globals are directly accessed. */
 	  if (!gdecl)
@@ -4073,7 +4071,12 @@
   struct block_sema_info *csi;
   tree block;
   /* push_scope (); */
+  current_stmt_tree ()->stmts_are_full_exprs_p = 1;
+#if 0
   block = do_pushlevel (sk_block);
+#else
+  block = NULL_TREE;
+#endif
   csi = (struct block_sema_info*)xcalloc (1, sizeof (struct block_sema_info));
   csi->prev_block_info = cur_block;
   cur_block = csi;
@@ -4086,7 +4089,12 @@
   struct block_sema_info *csi = cur_block;
   cur_block = cur_block->prev_block_info;
   /* pop_scope (); */
-  do_poplevel (block);
+#if 0
+  if (block)
+    do_poplevel (block);
+#else
+  block = 0;
+#endif
   return csi;
 }
 /* APPLE LOCAL end blocks 6040305 (ch) */

Modified: llvm-gcc-4.2/trunk/gcc/cp/typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/typeck.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/typeck.c Tue Sep  2 17:20:12 2008
@@ -57,7 +57,8 @@
 static bool casts_away_constness (tree, tree);
 static void maybe_warn_about_returning_address_of_local (tree);
 static tree lookup_destructor (tree, tree, tree);
-static tree convert_arguments (tree, tree, tree, int);
+/* APPLE LOCAL radar 6087117 */
+static tree convert_arguments (tree, tree, tree, int, int);
 
 /* Do `exp = require_complete_type (exp);' to make sure exp
    does not have an incomplete type.  (That includes void types.)
@@ -454,8 +455,13 @@
       result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1),
 				       result_type);
     }
+  /* APPLE LOCAL begin blocks 6065211 */
+  else if (TREE_CODE (t1) == BLOCK_POINTER_TYPE
+	   && result_type != void_type_node)
+    result_type = build_block_pointer_type (result_type);
   else
     result_type = build_pointer_type (result_type);
+  /* APPLE LOCAL end blocks 6065211 */
 
   /* Merge the attributes.  */
   attributes = (*targetm.merge_type_attributes) (t1, t2);
@@ -575,6 +581,14 @@
 	  return error_mark_node;
 	}
     }
+  /* APPLE LOCAL begin blocks 6065211 */
+  else if (TREE_CODE (t1) != TREE_CODE (t2))
+    {
+      error ("%s between distinct pointer types %qT and %qT "
+	     "lacks a cast", location, t1, t2);
+      return error_mark_node;
+    }
+  /* APPLE LOCAL end blocks 6065211 */
 
   return composite_pointer_type_r (t1, t2, location);
 }
@@ -1041,15 +1055,15 @@
       if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
 	return false;
       break;
-        
+
       /* APPLE LOCAL begin blocks 6040305 */
       case BLOCK_POINTER_TYPE:
         if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
         {
           tree pt1 = TREE_TYPE (t1);
           tree pt2 = TREE_TYPE (t2);
-          if (!same_type_ignoring_top_level_qualifiers_p (
-                 TREE_TYPE (pt1), TREE_TYPE (pt2)))
+          if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (pt1),
+							  TREE_TYPE (pt2)))
             return false;
           if (!compparms (TYPE_ARG_TYPES (pt1), TYPE_ARG_TYPES (pt2)))
             return false;
@@ -1064,7 +1078,7 @@
 	  || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
 	return false;
       break;
-                
+
     case METHOD_TYPE:
     case FUNCTION_TYPE:
       if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
@@ -2747,7 +2761,7 @@
   return function;
 }
 
-/* APPLE LOCAL begin blocks 6040305 */
+/* APPLE LOCAL begin blocks 6040305 (cm) */
 /**
  build_block_call - Routine to build a block call; as in:
  ((double(*)(struct invok_impl *, int))(BLOCK_PTR_VAR->FuncPtr))(I, 42);
@@ -2781,7 +2795,7 @@
   return  build3 (CALL_EXPR, TREE_TYPE (fntype),
                   function_ptr_exp, params, NULL_TREE);
 }
-/* APPLE LOCAL end blocks 6040305 */
+/* APPLE LOCAL end blocks 6040305 (cm) */
 
 tree
 build_function_call (tree function, tree params)
@@ -2861,8 +2875,11 @@
   /* Convert the parameters to the types declared in the
      function prototype, or apply default promotions.  */
 
+  /* APPLE LOCAL begin radar 6087117 */
   coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype),
-				      params, fndecl, LOOKUP_NORMAL);
+				      params, fndecl, LOOKUP_NORMAL,
+				      (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE));
+  /* APPLE LOCAL end radar 6087117 */
   if (coerced_params == error_mark_node)
     return error_mark_node;
 
@@ -2897,7 +2914,8 @@
    default arguments, if such were specified.  Do so here.  */
 
 static tree
-convert_arguments (tree typelist, tree values, tree fndecl, int flags)
+/* APPLE LOCAL radar 6087117 */
+convert_arguments (tree typelist, tree values, tree fndecl, int flags, int block_call)
 {
   tree typetail, valtail;
   tree result = NULL_TREE;
@@ -2939,7 +2957,8 @@
 	      error ("at this point in file");
 	    }
 	  else
-	    error ("too many arguments to function");
+	    /* APPLE LOCAL radar 6087117 */
+	    error ("too many arguments to %s", (block_call ? "block call" : "function"));
 	  /* In case anybody wants to know if this argument
 	     list is valid.  */
 	  if (result)
@@ -3041,7 +3060,8 @@
 	      error ("at this point in file");
 	    }
 	  else
-	    error ("too few arguments to function");
+	    /* APPLE LOCAL radar 6087117 */
+	    error ("too few arguments to %s", (block_call ? "block call" : "function"));
 	  return error_mark_node;
 	}
     }
@@ -3234,7 +3254,8 @@
   if ((invalid_op_diag
        = targetm.invalid_binary_op (code, type0, type1)))
     {
-      error (invalid_op_diag);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      error (invalid_op_diag, "");
       return error_mark_node;
     }
 
@@ -3442,15 +3463,13 @@
 	  && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
 	      || code1 == COMPLEX_TYPE))
 	short_compare = 1;
-      else if ((code0 == POINTER_TYPE && code1 == POINTER_TYPE)
-	       || (TYPE_PTRMEM_P (type0) && TYPE_PTRMEM_P (type1)))
-	result_type = composite_pointer_type (type0, type1, op0, op1,
-					      "comparison");
       /* APPLE LOCAL begin blocks 6040305 */
-      else if (code0 == BLOCK_POINTER_TYPE && code1 == BLOCK_POINTER_TYPE)
+      else if (((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
+		&& (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
+	       || (TYPE_PTRMEM_P (type0) && TYPE_PTRMEM_P (type1)))
+      /* APPLE LOCAL end blocks 6040305 */
 	result_type = composite_pointer_type (type0, type1, op0, op1,
 					      "comparison");
-      /* APPLE LOCAL end blocks 6040305 */
       /* APPLE LOCAL blocks 6040305 (cl) */
       else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE || TYPE_PTRMEM_P (type0))
 	       && null_ptr_cst_p (op1))
@@ -3919,12 +3938,24 @@
 
   if (! converted)
     {
-      /* APPLE LOCAL begin mainline */
-      if (TREE_TYPE (op0) != result_type)
-	op0 = cp_convert_and_check (result_type, op0);
-      if (TREE_TYPE (op1) != result_type)
-	op1 = cp_convert_and_check (result_type, op1);
-      /* APPLE LOCAL end mainline */
+      /* APPLE LOCAL begin 64bit shorten warning 6183168 */
+      if (final_type == 0)
+	{
+	  /* APPLE LOCAL begin mainline */
+	  if (TREE_TYPE (op0) != result_type)
+	    op0 = cp_convert_and_check (result_type, op0);
+	  if (TREE_TYPE (op1) != result_type)
+	    op1 = cp_convert_and_check (result_type, op1);
+	  /* APPLE LOCAL end mainline */
+	}
+      else
+	{
+	  if (TREE_TYPE (op0) != result_type)
+	    op0 = cp_convert (result_type, op0);
+	  if (TREE_TYPE (op1) != result_type)
+	    op1 = cp_convert (result_type, op1);
+	}
+      /* APPLE LOCAL end 64bit shorten warning 6183168 */
 
       if (op0 == error_mark_node || op1 == error_mark_node)
 	return error_mark_node;
@@ -4176,7 +4207,8 @@
 				    : code),
 				   TREE_TYPE (xarg))))
     {
-      error (invalid_op_diag);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      error (invalid_op_diag, "");
       return error_mark_node;
     }
 
@@ -7537,7 +7569,7 @@
   return win;
 }
 
-/* APPLE LOCAL begin radar 6040305 - blocks */
+/* APPLE LOCAL begin blocks 6040305 */
 tree c_finish_return (tree exp)
 {
   /* Unlike c front-end, genericize gets called in the middle of
@@ -7549,4 +7581,4 @@
               && BLOCK_HELPER_FUNC (current_function_decl));
   return finish_return_stmt (exp);
 }
-/* APPLE LOCAL end radar 6040305 - blocks */
+/* APPLE LOCAL end blocks 6040305 */

Modified: llvm-gcc-4.2/trunk/gcc/dbxout.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/dbxout.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/dbxout.c (original)
+++ llvm-gcc-4.2/trunk/gcc/dbxout.c Tue Sep  2 17:20:12 2008
@@ -2112,6 +2112,8 @@
     {
     case VOID_TYPE:
     case LANG_TYPE:
+      /* APPLE LOCAL blocks 6034272 */
+    case BLOCK_POINTER_TYPE:
       dbxout_void_type (type);
       break;
 
@@ -2314,6 +2316,8 @@
     {
     case VOID_TYPE:
     case LANG_TYPE:
+      /* APPLE LOCAL blocks 6034272 */
+    case BLOCK_POINTER_TYPE:
       dbxout_void_type (type);
       break;
 

Modified: llvm-gcc-4.2/trunk/gcc/dwarf2out.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/dwarf2out.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/dwarf2out.c (original)
+++ llvm-gcc-4.2/trunk/gcc/dwarf2out.c Tue Sep  2 17:20:12 2008
@@ -214,6 +214,8 @@
 typedef struct cfa_loc GTY(())
 {
   HOST_WIDE_INT offset;
+  /* APPLE LOCAL async unwind info 5949350 */
+  HOST_WIDE_INT fp_offset;
   HOST_WIDE_INT base_offset;
   unsigned int reg;
   int indirect;            /* 1 if CFA is accessed via a dereference.  */
@@ -731,6 +733,21 @@
 /* The last args_size we actually output.  */
 static HOST_WIDE_INT old_args_size;
 
+/* APPLE LOCAL begin async unwind info 5949350 */
+/* This routine should be called anytime the cfa.reg can be switched
+   away from the fp.  We record the offset used with the fp, so that
+   if we go from using the fp to the sp and then update the sp from
+   the fp, we know what offset to use instead of the current offset in
+   use for the sp.  */
+
+static inline void
+notice_cfa_fp_offset (void)
+{
+  if (cfa.reg == (unsigned) HARD_FRAME_POINTER_REGNUM)
+    cfa.fp_offset = cfa.offset;
+}
+/* APPLE LOCAL end async unwind info 5949350 */
+
 /* Entry point to update the canonical frame address (CFA).
    LABEL is passed to add_fde_cfi.  The value of CFA is now to be
    calculated from REG+OFFSET.  */
@@ -741,6 +758,8 @@
   dw_cfa_location loc;
   loc.indirect = 0;
   loc.base_offset = 0;
+  /* APPLE LOCAL async unwind info 5949350 */
+  notice_cfa_fp_offset ();
   loc.reg = reg;
   loc.offset = offset;
   def_cfa_1 (label, &loc);
@@ -773,6 +792,8 @@
   if (cfa_store.reg == loc.reg && loc.indirect == 0)
     cfa_store.offset = loc.offset;
 
+  /* APPLE LOCAL async unwind info 5949350 */
+  notice_cfa_fp_offset ();
   loc.reg = DWARF_FRAME_REGNUM (loc.reg);
   lookup_cfa (&old_cfa);
 
@@ -1108,7 +1129,20 @@
      insns to be marked, and to be able to handle saving state around
      epilogues textually in the middle of the function.  */
   if (prologue_epilogue_contains (insn) || sibcall_epilogue_contains (insn))
-    return;
+    /* APPLE LOCAL begin async unwind info 5949350 */
+    {
+      if (!flag_asynchronous_unwind_tables)
+	return;
+
+      /* We now handle epilogues for flag_asynchronous_unwind_tables.
+	 We do this by saving the cfa information around the epilogue
+	 instructions and restoring that information after the
+	 epilogue instructions.  See dwarf2out_frame_debug_noncall for
+	 the information that is saved and restored.  */
+      if (!epilogue_contains (insn))
+	return;
+    }
+    /* APPLE LOCAL end async unwind info 5949350 */
 
   /* If only calls can throw, and we have a frame pointer,
      save up adjustments until we see the CALL_INSN.  */
@@ -1563,6 +1597,8 @@
 	case REG:
 	  if (cfa.reg == (unsigned) REGNO (src))
 	    {
+	      /* APPLE LOCAL async unwind info 5949350 */
+	      notice_cfa_fp_offset ();
 	      /* Rule 1 */
 	      /* Update the CFA rule wrt SP or FP.  Make sure src is
 		 relative to the current CFA register.
@@ -1609,8 +1645,24 @@
 
 	      if (XEXP (src, 0) == hard_frame_pointer_rtx)
 		{
+		  /* APPLE LOCAL begin async unwind info 5949350 */
+		  /* In the epilogue, sometimes we switch from fp to
+		     sp and then play with sp, then do another switch
+		     from fp to sp.  In order for this to work, we
+		     have to save a copy of the offset against fp, and
+		     restore that here, back into cfa.offset when we
+		     notice that we were using sp and not fp.  */
+		  if (cfa.reg == (unsigned) STACK_POINTER_REGNUM)
+		    {
+		      cfa.reg = HARD_FRAME_POINTER_REGNUM;
+		      cfa.offset = cfa.fp_offset;
+		    }
+		  /* APPLE LOCAL end async unwind info 5949350 */
+
 		  /* Restoring SP from FP in the epilogue.  */
 		  gcc_assert (cfa.reg == (unsigned) HARD_FRAME_POINTER_REGNUM);
+		  /* APPLE LOCAL async unwind info 5949350 */
+		  notice_cfa_fp_offset ();
 		  cfa.reg = STACK_POINTER_REGNUM;
 		}
 	      else if (GET_CODE (src) == LO_SUM)
@@ -1651,6 +1703,8 @@
 		  && REGNO (XEXP (src, 0)) == cfa.reg
 		  && GET_CODE (XEXP (src, 1)) == CONST_INT)
 		{
+		  /* APPLE LOCAL async unwind info 5949350 */
+		  notice_cfa_fp_offset ();
 		  /* Setting a temporary CFA register that will be copied
 		     into the FP later on.  */
 		  offset = - INTVAL (XEXP (src, 1));
@@ -1843,6 +1897,8 @@
 		x = XEXP (x, 0);
 	      gcc_assert (REG_P (x));
 
+	      /* APPLE LOCAL async unwind info 5949350 */
+	      notice_cfa_fp_offset ();
 	      cfa.reg = REGNO (x);
 	      cfa.base_offset = offset;
 	      cfa.indirect = 1;
@@ -1860,6 +1916,53 @@
     }
 }
 
+/* APPLE LOCAL begin async unwind info 5949350 */
+/* Mirror routine to dwarf2out_frame_debug_noncall, except this
+   routine is only called for all non-CALL_P instructions and only
+   before the instruction.  We use this to save and restore the cfa
+   state around epilogue instructions so that we can track frame
+   related instructions from the epilogue when
+   flag_asynchronous_unwind_tables is on.  */
+void
+dwarf2out_frame_debug_noncall (bool inside_epilogue)
+{
+  static dw_cfa_location saved_cfa;
+  static dw_cfa_location saved_cfa_store;
+  static dw_cfa_location saved_cfa_temp;
+  static HOST_WIDE_INT saved_args_size;
+
+  const char *label;
+
+  if (inside_epilogue)
+    {
+      if (saved_cfa.reg == 0)
+	{
+	  /* When we enter an epilogue, we save the current cfa so
+	     that we can restore it when we leave the epilogue.  */
+	  saved_cfa = cfa;
+	  saved_cfa_store = cfa_store;
+	  saved_cfa_temp = cfa_temp;
+	  saved_args_size = args_size;
+	}
+    }
+  else if (saved_cfa.reg != 0)
+    {
+      /* We have now left the epilogue, so restore the saved cfa.  */
+      cfa = saved_cfa;
+      cfa_store = saved_cfa_store;
+      cfa_temp = saved_cfa_temp;
+      args_size = saved_args_size;
+
+      label = dwarf2out_cfi_label ();
+      def_cfa_1 (label, &cfa);
+
+      /* Once restored, we might need to save it again.  */
+      saved_cfa.reg = 0;
+      return;
+    }
+}
+/* APPLE LOCAL end async unwind info 5949350 */
+
 /* Record call frame debugging information for INSN, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
    register to the stack.  If INSN is NULL_RTX, initialize our state.
@@ -14303,8 +14406,8 @@
 	 a plain function, this will be fixed up in decls_for_scope.  If
 	 we're a method, it will be ignored, since we already have a DIE.  */
       if (decl_function_context (decl)
-	  /* APPLE LOCAL blocks 5811952 */
-	  && (! BLOCK_HELPER_FUNC (decl))
+	  /* APPLE LOCAL blocks 5811952 - radar 6172148 */
+	  && (! BLOCK_SYNTHESIZED_FUNC (decl))
 	  /* But if we're in terse mode, we don't care about scope.  */
 	  && debug_info_level > DINFO_LEVEL_TERSE)
 	context_die = NULL;

Modified: llvm-gcc-4.2/trunk/gcc/dwarf2out.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/dwarf2out.h?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/dwarf2out.h (original)
+++ llvm-gcc-4.2/trunk/gcc/dwarf2out.h Tue Sep  2 17:20:12 2008
@@ -21,6 +21,8 @@
 
 extern void dwarf2out_decl (tree);
 extern void dwarf2out_frame_debug (rtx, bool);
+/* APPLE LOCAL async unwind info 5949350 */
+extern void dwarf2out_frame_debug_noncall (bool);
 
 extern void debug_dwarf (void);
 struct die_struct;

Modified: llvm-gcc-4.2/trunk/gcc/except.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/except.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/except.c (original)
+++ llvm-gcc-4.2/trunk/gcc/except.c Tue Sep  2 17:20:12 2008
@@ -3763,8 +3763,9 @@
   switch_to_exception_section ();
 #endif
 
-  /* If the target wants a label to begin the table, emit it here.  */
-  targetm.asm_out.except_table_label (asm_out_file);
+  /* APPLE LOCAL begin 6128170 */
+  /* deletion; code moved down 26 lines */
+  /* APPLE LOCAL end 6128170 */
 
   have_tt_data = (VEC_length (tree, cfun->eh->ttype_data) > 0
 		  || VARRAY_ACTIVE_SIZE (cfun->eh->ehspec_data) > 0);
@@ -3784,6 +3785,11 @@
       assemble_align (tt_format_size * BITS_PER_UNIT);
     }
 
+  /* APPLE LOCAL begin 6128170 */
+  /* If the target wants a label to begin the table, emit it here.  */
+  targetm.asm_out.except_table_label (asm_out_file);
+  /* APPLE LOCAL end 6128170 */
+
   targetm.asm_out.internal_label (asm_out_file, "LLSDA",
 			     current_function_funcdef_no);
 

Modified: llvm-gcc-4.2/trunk/gcc/expmed.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/expmed.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/expmed.c (original)
+++ llvm-gcc-4.2/trunk/gcc/expmed.c Tue Sep  2 17:20:12 2008
@@ -40,7 +40,9 @@
 
 static void store_fixed_bit_field (rtx, unsigned HOST_WIDE_INT,
 				   unsigned HOST_WIDE_INT,
-				   unsigned HOST_WIDE_INT, rtx);
+				   /* APPLE LOCAL begin 6020402 */
+				   unsigned HOST_WIDE_INT, rtx, tree);
+				   /* APPLE LOCAL end 6020402 */
 static void store_split_bit_field (rtx, unsigned HOST_WIDE_INT,
 				   unsigned HOST_WIDE_INT, rtx);
 static rtx extract_fixed_bit_field (enum machine_mode, rtx,
@@ -54,6 +56,12 @@
 static void do_cmp_and_jump (rtx, rtx, enum rtx_code, enum machine_mode, rtx);
 static rtx expand_smod_pow2 (enum machine_mode, rtx, HOST_WIDE_INT);
 static rtx expand_sdiv_pow2 (enum machine_mode, rtx, HOST_WIDE_INT);
+/* APPLE LOCAL begin 6020402 */
+static enum machine_mode
+widest_mode_including_no_volatile_fields (tree, unsigned HOST_WIDE_INT,
+					  unsigned HOST_WIDE_INT,
+					  unsigned HOST_WIDE_INT);
+/* APPLE LOCAL end 6020402 */
 
 /* Test whether a value is zero of a power of two.  */
 #define EXACT_POWER_OF_2_OR_ZERO_P(x) (((x) & ((x) - 1)) == 0)
@@ -332,7 +340,11 @@
    containing BITSIZE bits starting at bit BITNUM.
    FIELDMODE is the machine-mode of the FIELD_DECL node for this field.
    ALIGN is the alignment that STR_RTX is known to have.
-   TOTAL_SIZE is the size of the structure in bytes, or -1 if varying.  */
+APPLE LOCAL begin 6020402
+   TOTAL_SIZE is the size of the structure in bytes, or -1 if varying.
+   STRUCT_TYPE is the type of the struct containing the bitfield, or NULL_TREE
+   if the struct type is not available.
+APPLE LOCAL end 6020402 */
 
 /* ??? Note that there are two different ideas here for how
    to determine the size to count bits within, for a register.
@@ -345,7 +357,9 @@
 rtx
 store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
 		 unsigned HOST_WIDE_INT bitnum, enum machine_mode fieldmode,
-		 rtx value)
+		 /* APPLE LOCAL begin 6020402 */
+		 rtx value, tree struct_type)
+		 /* APPLE LOCAL end 6020402 */
 {
   unsigned int unit
     = (MEM_P (str_rtx)) ? BITS_PER_UNIT : BITS_PER_WORD;
@@ -582,7 +596,10 @@
 	  store_bit_field (op0, MIN (BITS_PER_WORD,
 				     bitsize - i * BITS_PER_WORD),
 			   bitnum + bit_offset, word_mode,
-			   operand_subword_force (value, wordnum, fieldmode));
+			   /* APPLE LOCAL begin 6020402 */
+			   operand_subword_force (value, wordnum, fieldmode),
+			   struct_type);
+			   /* APPLE LOCAL end 6020402 */
 	}
       return value;
     }
@@ -695,7 +712,9 @@
 	      (GET_MODE_CLASS (fieldmode) != MODE_INT
 		&& GET_MODE_CLASS (fieldmode) != MODE_PARTIAL_INT)
 	      ? GET_MODE (orig_value) : fieldmode,
-	    orig_value);
+	      /* APPLE LOCAL begin 6020402 */
+	      orig_value, struct_type);
+	      /* APPLE LOCAL end 6020402 */
 	  /* APPLE LOCAL end do not use float fieldmode */
 	  emit_move_insn (op0, tempreg);
 	  return value;
@@ -775,16 +794,133 @@
       else
 	{
 	  delete_insns_since (last);
-	  store_fixed_bit_field (op0, offset, bitsize, bitpos, value);
+	  /* APPLE LOCAL begin 6020402 */
+	  store_fixed_bit_field (op0, offset, bitsize, bitpos, value,
+				 struct_type);
+	  /* APPLE LOCAL end 6020402 */
 	}
     }
   else
     insv_loses:
     /* Insv is not available; store using shifts and boolean ops.  */
-    store_fixed_bit_field (op0, offset, bitsize, bitpos, value);
+    /* APPLE LOCAL begin 6020402 */
+    store_fixed_bit_field (op0, offset, bitsize, bitpos, value, struct_type);
+    /* APPLE LOCAL end 6020402 */
   return value;
 }
 
+/* APPLE LOCAL begin 6020402 */
+/* Given a struct type and a bit field corresponding to OFFSET_BYTES, BITSIZE,
+   and BITPOS, returns the widest mode that can be used to store to the bit
+   field without also writing to a volatile region of the struct.  If no mode
+   is small enough to fit the bit field, then VOIDmode is returned.  It is
+   assumed that OFFSET_BYTES, BITSIZE, and BITPOS correspond to a field
+   defined explicitly in STRUCT_TYPE.
+
+   STRUCT_TYPE is the type of the struct containing the bit field.
+   OFFSET_BYTES is the offset of the target field in the struct in bytes.
+   BITPOS is the offset of the target field in the struct in bits, not
+   including the byte offset.
+   BITSIZE is the size of the bit field in bits.
+*/
+
+static enum machine_mode
+widest_mode_including_no_volatile_fields (tree struct_type,
+					  unsigned HOST_WIDE_INT offset_bytes,
+					  unsigned HOST_WIDE_INT bitpos,
+					  unsigned HOST_WIDE_INT bitsize)
+{
+  enum machine_mode minmode = VOIDmode, maxmode = VOIDmode, tmode;
+  unsigned target_low, target_high;
+
+  /* Find the narrowest integer mode that contains the bit field. */
+  for (minmode = GET_CLASS_NARROWEST_MODE (MODE_INT); minmode != VOIDmode;
+       minmode = GET_MODE_WIDER_MODE (minmode))
+    {
+      unsigned unit = GET_MODE_BITSIZE (minmode);
+      if ((bitpos % unit) + bitsize <= unit)
+	break;
+    }
+
+  if (minmode == VOIDmode)
+    return VOIDmode; /* No mode will fit a bitfield of this size. */
+
+  target_low = offset_bytes * 8 + bitpos;
+  target_high = target_low + bitsize;
+
+  maxmode = VOIDmode;
+
+  for (tmode = minmode;
+       tmode != VOIDmode
+	 && GET_MODE_BITSIZE (tmode) <= GET_MODE_BITSIZE (word_mode);
+       tmode = GET_MODE_WIDER_MODE (tmode))
+    {
+      tree field;
+      unsigned mode_bitsize = GET_MODE_BITSIZE (tmode);
+      unsigned mode_low = (target_low / mode_bitsize) * mode_bitsize;
+      unsigned mode_high = mode_low + mode_bitsize;
+
+      for (field = TYPE_FIELDS (struct_type); field;
+	   field = TREE_CHAIN (field))
+	{
+	  unsigned field_low, field_high;
+	  bool field_is_target_field, field_intersects_with_mode_range;
+
+	  /* Make sure all values that we need are present for this field. */
+	  if (TREE_CODE (field) != FIELD_DECL
+	      || DECL_FIELD_OFFSET (field) == NULL_TREE
+	      || DECL_FIELD_BIT_OFFSET (field) == NULL_TREE
+	      || TREE_TYPE (field) == NULL_TREE
+	      || TYPE_SIZE (TREE_TYPE (field)) == NULL_TREE)
+	    continue;
+
+	  if (TREE_CODE (DECL_FIELD_OFFSET (field)) != INTEGER_CST)
+	    return VOIDmode;
+
+	  field_low = 8 * TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field))
+	    + TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));
+
+	  if (DECL_SIZE (field) != NULL_TREE)
+	    field_high = field_low + TREE_INT_CST_LOW (DECL_SIZE (field));
+	  else
+	    {
+	      if (TREE_CODE (TYPE_SIZE (TYPE_SIZE (TREE_TYPE (field))))
+		  != INTEGER_CST)
+		return VOIDmode;
+
+	      field_high = field_low
+		+ TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (field)));
+	    }
+
+	  /* We assume that this will be true if the current field is the
+	     target field.  This may not be the case if the field is
+	     split up, for instance. */
+	  field_is_target_field =
+	    field_low == target_low && field_high == target_high;
+
+	  /* The current field and the current mode intersect if either the
+	     field low or the field high is in the mode range, or if the
+	     field completely contains the mode range. */
+	  field_intersects_with_mode_range =
+	    (field_high > mode_low && field_high <= mode_high)
+	    || (field_low >= mode_low && field_low < mode_high)
+	    || (field_high >= mode_high && field_low <= mode_low);
+
+	  if (!field_is_target_field
+	      && TYPE_VOLATILE (TREE_TYPE (field))
+	      && field_intersects_with_mode_range)
+	    /* The current field is volatile and within the mode of the
+	       target field.  Return the max mode allowed up to this point. */
+	    return maxmode;
+	}
+
+      maxmode = tmode;
+    }
+
+  return maxmode;
+}
+/* APPLE LOCAL end 6020402 */
+
 /* Use shifts and boolean operations to store VALUE
    into a bit field of width BITSIZE
    in a memory location specified by OP0 except offset by OFFSET bytes.
@@ -797,7 +933,10 @@
 static void
 store_fixed_bit_field (rtx op0, unsigned HOST_WIDE_INT offset,
 		       unsigned HOST_WIDE_INT bitsize,
-		       unsigned HOST_WIDE_INT bitpos, rtx value)
+		       /* APPLE LOCAL begin 6020402 */
+		       unsigned HOST_WIDE_INT bitpos, rtx value,
+		       tree struct_type)
+		       /* APPLE LOCAL end 6020402 */
 {
   enum machine_mode mode;
   unsigned int total_bits = BITS_PER_WORD;
@@ -829,12 +968,24 @@
 	 a word, we won't be doing the extraction the normal way.
 	 We don't want a mode bigger than the destination.  */
 
-      mode = GET_MODE (op0);
-      if (GET_MODE_BITSIZE (mode) == 0
-	  || GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (word_mode))
-	mode = word_mode;
+      /* APPLE LOCAL begin 6020402 */
+      enum machine_mode maxmode = GET_MODE (op0);
+
+      /* Find the largest mode that doesn't interfere with volatile fields in
+       * the struct. */
+      if (struct_type != NULL_TREE && TREE_CODE (struct_type) == RECORD_TYPE)
+	maxmode = widest_mode_including_no_volatile_fields (struct_type,
+							    offset,
+							    bitpos, bitsize);
+
+      if (GET_MODE_BITSIZE (maxmode) == 0
+	  || GET_MODE_BITSIZE (maxmode) > GET_MODE_BITSIZE (word_mode))
+	maxmode = word_mode;
+      /* APPLE LOCAL end 6020402 */
       mode = get_best_mode (bitsize, bitpos + offset * BITS_PER_UNIT,
-			    MEM_ALIGN (op0), mode, MEM_VOLATILE_P (op0));
+			    /* APPLE LOCAL begin 6020402 */
+			    MEM_ALIGN (op0), maxmode, MEM_VOLATILE_P (op0));
+			    /* APPLE LOCAL end 6020402 */
 
       if (mode == VOIDmode)
 	{
@@ -1069,7 +1220,9 @@
       /* OFFSET is in UNITs, and UNIT is in bits.
          store_fixed_bit_field wants offset in bytes.  */
       store_fixed_bit_field (word, offset * unit / BITS_PER_UNIT, thissize,
-			     thispos, part);
+			     /* APPLE LOCAL begin 6020402 */
+			     thispos, part, NULL_TREE);
+			     /* APPLE LOCAL end 6020402 */
       bitsdone += thissize;
     }
 }

Modified: llvm-gcc-4.2/trunk/gcc/expr.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/expr.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/expr.c (original)
+++ llvm-gcc-4.2/trunk/gcc/expr.c Tue Sep  2 17:20:12 2008
@@ -2055,7 +2055,9 @@
 	emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);
       else
 	store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
-			 mode, tmps[i]);
+			 /* APPLE LOCAL begin 6020402 */
+			 mode, tmps[i], NULL_TREE);
+			 /* APPLE LOCAL end 6020402 */
     }
 
   /* Copy from the pseudo into the (probable) hard reg.  */
@@ -2139,7 +2141,10 @@
       store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, word_mode,
 		       extract_bit_field (src, bitsize,
 					  xbitpos % BITS_PER_WORD, 1,
-					  NULL_RTX, word_mode, word_mode));
+		       /* APPLE LOCAL begin 6020402 */
+					  NULL_RTX, word_mode, word_mode),
+		       NULL_TREE);
+		       /* APPLE LOCAL end 6020402 */
     }
 
   return tgtblk;
@@ -2783,7 +2788,10 @@
 	gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD);
     }
 
-  store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, imode, val);
+  /* APPLE LOCAL begin 6020402 */
+  store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, imode, val,
+		   NULL_TREE);
+  /* APPLE LOCAL end 6020402 */
 }
 
 /* Extract one of the components of the complex value CPLX.  Extract the
@@ -5633,7 +5641,9 @@
 	}
 
       /* Store the value in the bitfield.  */
-      store_bit_field (target, bitsize, bitpos, mode, temp);
+      /* APPLE LOCAL begin 6020402 */
+      store_bit_field (target, bitsize, bitpos, mode, temp, type);
+      /* APPLE LOCAL end 6020402 */
 
       return const0_rtx;
     }

Modified: llvm-gcc-4.2/trunk/gcc/expr.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/expr.h?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/expr.h (original)
+++ llvm-gcc-4.2/trunk/gcc/expr.h Tue Sep  2 17:20:12 2008
@@ -733,7 +733,10 @@
 mode_for_extraction (enum extraction_pattern, int);
 
 extern rtx store_bit_field (rtx, unsigned HOST_WIDE_INT,
-			    unsigned HOST_WIDE_INT, enum machine_mode, rtx);
+			    /* APPLE LOCAL begin 6020402 */
+			    unsigned HOST_WIDE_INT, enum machine_mode, rtx,
+			    tree);
+			    /* APPLE LOCAL end 6020402 */
 extern rtx extract_bit_field (rtx, unsigned HOST_WIDE_INT,
 			      unsigned HOST_WIDE_INT, int, rtx,
 			      enum machine_mode, enum machine_mode);

Modified: llvm-gcc-4.2/trunk/gcc/final.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/final.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/final.c (original)
+++ llvm-gcc-4.2/trunk/gcc/final.c Tue Sep  2 17:20:12 2008
@@ -1944,7 +1944,12 @@
     case BARRIER:
 #if defined (DWARF2_UNWIND_INFO)
       if (dwarf2out_do_frame ())
-	dwarf2out_frame_debug (insn, false);
+	/* APPLE LOCAL begin async unwind info 5949350 */
+	{
+	  dwarf2out_frame_debug_noncall (epilogue_contains (insn));
+	  dwarf2out_frame_debug (insn, false);
+	}
+	/* APPLE LOCAL end async unwind info 5949350 */
 #endif
       break;
 
@@ -2529,6 +2534,10 @@
 #if defined (DWARF2_UNWIND_INFO)
 	if (CALL_P (insn) && dwarf2out_do_frame ())
 	  dwarf2out_frame_debug (insn, false);
+	/* APPLE LOCAL begin async unwind info 5949350 */
+	else if (dwarf2out_do_frame ())
+	  dwarf2out_frame_debug_noncall (epilogue_contains (insn));
+	/* APPLE LOCAL end async unwind info 5949350 */
 #endif
 
 	/* Find the proper template for this insn.  */

Modified: llvm-gcc-4.2/trunk/gcc/fold-const.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/fold-const.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/fold-const.c (original)
+++ llvm-gcc-4.2/trunk/gcc/fold-const.c Tue Sep  2 17:20:12 2008
@@ -992,7 +992,8 @@
 	}
     }
   else if (issue_strict_overflow_warning (wc))
-    warning (OPT_Wstrict_overflow, gmsgid);
+    /* APPLE LOCAL default to Wformat-security 5764921 */
+    warning (OPT_Wstrict_overflow, "%s", gmsgid);
 }
 
 /* Return true if the built-in mathematical function specified by CODE
@@ -10609,7 +10610,13 @@
 	  && ! DECL_WEAK (TREE_OPERAND (arg1, 0))
 	  && ! lookup_attribute ("alias",
 				 DECL_ATTRIBUTES (TREE_OPERAND (arg1, 0)))
-	  && ! DECL_EXTERNAL (TREE_OPERAND (arg1, 0)))
+	  /* APPLE LOCAL begin folding of anon union 6120295 */
+	  && ! DECL_EXTERNAL (TREE_OPERAND (arg1, 0))
+	  && ! (TREE_CODE (TREE_OPERAND (arg0, 0)) == VAR_DECL
+		&& DECL_HAS_VALUE_EXPR_P (TREE_OPERAND (arg0, 0))
+		&& TREE_CODE (TREE_OPERAND (arg0, 0)) == VAR_DECL
+		&& DECL_HAS_VALUE_EXPR_P (TREE_OPERAND (arg0, 0))))
+	  /* APPLE LOCAL end folding of anon union 6120295 */
 	{
 	  /* We know that we're looking at the address of two
 	     non-weak, unaliased, static _DECL nodes.

Modified: llvm-gcc-4.2/trunk/gcc/function.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/function.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/function.c (original)
+++ llvm-gcc-4.2/trunk/gcc/function.c Tue Sep  2 17:20:12 2008
@@ -4731,6 +4731,16 @@
   return 0;
 }
 
+/* APPLE LOCAL begin async unwind info 5949350 */
+int
+epilogue_contains (rtx insn)
+{
+  if (contains (insn, &epilogue))
+    return 1;
+  return 0;
+}
+/* APPLE LOCAL end async unwind info 5949350 */
+
 int
 prologue_epilogue_contains (rtx insn)
 {

Modified: llvm-gcc-4.2/trunk/gcc/gcov-io.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gcov-io.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/gcov-io.c (original)
+++ llvm-gcc-4.2/trunk/gcc/gcov-io.c Tue Sep  2 17:20:12 2008
@@ -132,9 +132,11 @@
     }
   if (!gcov_var.file)
     return 0;
-#endif
+  /* APPLE LOCAL begin fread is way slow 6178552 */
 
   setbuf (gcov_var.file, (char *)0);
+#endif
+  /* APPLE LOCAL end fread is way slow 6178552 */
   
   return 1;
 }

Modified: llvm-gcc-4.2/trunk/gcc/global.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/global.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/global.c (original)
+++ llvm-gcc-4.2/trunk/gcc/global.c Tue Sep  2 17:20:12 2008
@@ -2312,6 +2312,8 @@
      then give the other a preference.  */
 
   if (dest_regno < FIRST_PSEUDO_REGISTER && src_regno >= FIRST_PSEUDO_REGISTER
+      /* APPLE LOCAL 6090616 avoid regno underflow */
+      && (offset <= 0 || dest_regno >= (unsigned)offset)
       && reg_allocno[src_regno] >= 0)
     {
       dest_regno -= offset;
@@ -2331,6 +2333,8 @@
     }
 
   if (src_regno < FIRST_PSEUDO_REGISTER && dest_regno >= FIRST_PSEUDO_REGISTER
+      /* APPLE LOCAL 6090616 avoid regno underflow */
+      && (offset >= 0 || src_regno >= (unsigned)-offset)
       && reg_allocno[dest_regno] >= 0)
     {
       src_regno += offset;

Modified: llvm-gcc-4.2/trunk/gcc/ifcvt.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ifcvt.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ifcvt.c (original)
+++ llvm-gcc-4.2/trunk/gcc/ifcvt.c Tue Sep  2 17:20:12 2008
@@ -826,7 +826,9 @@
 		}
 
 	      gcc_assert (start < (MEM_P (op) ? BITS_PER_UNIT : BITS_PER_WORD));
-	      store_bit_field (op, size, start, GET_MODE (x), y);
+	      /* APPLE LOCAL begin 6020402 */
+	      store_bit_field (op, size, start, GET_MODE (x), y, NULL_TREE);
+	      /* APPLE LOCAL end 6020402 */
 	      return;
 	    }
 
@@ -880,7 +882,10 @@
   inner = XEXP (outer, 0);
   outmode = GET_MODE (outer);
   bitpos = SUBREG_BYTE (outer) * BITS_PER_UNIT;
-  store_bit_field (inner, GET_MODE_BITSIZE (outmode), bitpos, outmode, y);
+  /* APPLE LOCAL begin 6020402 */
+  store_bit_field (inner, GET_MODE_BITSIZE (outmode), bitpos, outmode, y,
+		   NULL_TREE);
+  /* APPLE LOCAL end 6020402 */
 }
 
 /* Return sequence of instructions generated by if conversion.  This

Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Sep  2 17:20:12 2008
@@ -82,7 +82,7 @@
 #endif
 /* LLVM LOCAL end */
 
-#define OBJC_VOID_AT_END  void_list_node
+#define OBJC_VOID_AT_END	void_list_node
 
 /* APPLE LOCAL radar 4506893 */
 static bool in_objc_property_setter_name_context = false;
@@ -104,15 +104,15 @@
    if method names contain underscores. -- rms.  */
 #ifndef OBJC_GEN_METHOD_LABEL
 #define OBJC_GEN_METHOD_LABEL(BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME, NUM) \
-  do {                                      \
-    char *temp;                             \
-    sprintf ((BUF), "_%s_%s_%s_%s",         \
-             ((IS_INST) ? "i" : "c"),       \
-             (CLASS_NAME),                  \
-             ((CAT_NAME)? (CAT_NAME) : ""), \
-             (SEL_NAME));                   \
-    for (temp = (BUF); *temp; temp++)       \
-      if (*temp == ':') *temp = '_';        \
+  do {					    \
+    char *temp;				    \
+    sprintf ((BUF), "_%s_%s_%s_%s",	    \
+	     ((IS_INST) ? "i" : "c"),	    \
+	     (CLASS_NAME),		    \
+	     ((CAT_NAME)? (CAT_NAME) : ""), \
+	     (SEL_NAME));		    \
+    for (temp = (BUF); *temp; temp++)	    \
+      if (*temp == ':') *temp = '_';	    \
   } while (0)
 #endif
 /* APPLE LOCAL begin radar 4862848 */
@@ -175,8 +175,8 @@
 #define NEW_PROTOCOL_VERSION 3
 
 /* (Decide if these can ever be validly changed.) */
-#define OBJC_ENCODE_INLINE_DEFS         0
-#define OBJC_ENCODE_DONT_INLINE_DEFS    1
+#define OBJC_ENCODE_INLINE_DEFS 	0
+#define OBJC_ENCODE_DONT_INLINE_DEFS	1
 
 /*** Private Interface (procedures) ***/
 
@@ -1174,7 +1174,7 @@
 static bool
 managed_objc_object_pointer (tree type)
 {
-  return type && type != error_mark_node && POINTER_TYPE_P (type) 
+  return type && type != error_mark_node && POINTER_TYPE_P (type)
 	 && (objc_is_object_id (TREE_TYPE (type)) || TYPED_OBJECT (TREE_TYPE (type)));
 }
 /* APPLE LOCAL end radar 5168496 */
@@ -2260,6 +2260,20 @@
 }
 /* APPLE LOCAL end radar 5082000 */
 
+/* APPLE LOCAL begin radar 6133042 */
+/* This routine checks block pointers and either returns
+   1 for GCable, or -1 if they are tagged as __weak. */
+static int
+block_pointer_strong_value (tree type)
+{
+  gcc_assert (type && TREE_CODE (type) == BLOCK_POINTER_TYPE);
+  type = TREE_TYPE (TREE_TYPE (type));
+  while (POINTER_TYPE_P (type))
+     type = TREE_TYPE (type);
+  return (objc_is_strong_p (type) >= 0 ? 1 : -1);
+}
+/* APPLE LOCAL end radar 6133042 */
+
 static void
 objc_build_aggregate_ivar_layout (tree aggr_type, tree field_decl,
 				  unsigned int base_byte_pos,
@@ -2399,7 +2413,13 @@
 	    break;
 	  }
 	/* APPLE LOCAL end objc gc 5547128 */
-
+	/* APPLE LOCAL begin radar 6133042 */
+        if (TREE_CODE (type) == BLOCK_POINTER_TYPE)
+          {
+            strong = block_pointer_strong_value (type);
+            break;
+          }
+	/* APPLE LOCAL end radar 6133042 */
         type = TREE_TYPE (type);
       }
     while (!strong && type);
@@ -3090,6 +3110,25 @@
   if (attributes)
     warning (0, "method attribute may be specified on method declarations only");
   /* APPLE LOCAL end radar 4529765 */
+  /* APPLE LOCAL begin radar 5424416 */
+  if (TREE_TYPE (decl) && TREE_CODE (TREE_TYPE (decl)) == TREE_LIST)
+  {
+    tree type = TREE_VALUE (TREE_TYPE (decl));
+    if (type)
+    {
+      if (TREE_CODE (type) == FUNCTION_TYPE)
+        {
+          error ("%qs declared as method returning a function", 
+                 IDENTIFIER_POINTER (DECL_NAME (decl)));
+	}
+      else if (TREE_CODE (type) == ARRAY_TYPE)
+	{
+          error ("%qs declared as method returning an array", 
+                 IDENTIFIER_POINTER (DECL_NAME (decl)));
+	}
+    }
+  }
+  /* APPLE LOCAL end radar 5424416 */
   /* APPLE LOCAL radar 3803157 - objc attribute */
   objc_decl_method_attributes (&decl, attributes, 0);
   objc_add_method (objc_implementation_context,
@@ -3450,7 +3489,8 @@
       strcat (errbuf, " the \'");
       strcat (errbuf, IDENTIFIER_POINTER (PROTOCOL_NAME (proto)));
       strcat (errbuf, "\' protocol");
-      warning (0, errbuf);
+      /* APPLE LOCAL default to Wformat-security 5764921 */
+      warning (0, "%s", errbuf);
     }
 
   return false;
@@ -3532,6 +3572,16 @@
 }
 /* APPLE LOCAL end 4154928 */
 
+/* APPLE LOCAL begin radar 5595325 */
+/* This routine checks that TYPE has __attribute__((NSObject)) */
+static bool
+objc_nsobject_attribute_type (tree type)
+{
+  return POINTER_TYPE_P (type) && 
+  lookup_attribute ("NSObject", TYPE_ATTRIBUTES (type));
+}
+/* APPLE LOCAL end radar 5595325 */
+
 /* Determine if it is permissible to assign (if ARGNO is greater than -3)
    an instance of RTYP to an instance of LTYP or to compare the two
    (if ARGNO is equal to -3), per ObjC type system rules.  Before
@@ -3565,10 +3615,18 @@
   tree lcls, rcls, lproto, rproto;
   bool pointers_compatible;
 
+  /* APPLE LOCAL begin radar 5595325 */
+  tree orig_ltyp, orig_rtyp;
+  /* APPLE LOCAL end radar 5595325 */
+
   /* We must be dealing with pointer types */
   if (!POINTER_TYPE_P (ltyp) || !POINTER_TYPE_P (rtyp))
     return false;
 
+  /* APPLE LOCAL begin radar 5595325 */
+  orig_ltyp = ltyp;
+  orig_rtyp = rtyp;
+  /* APPLE LOCAL end radar 5595325 */
   do
     {
       ltyp = TREE_TYPE (ltyp);  /* Remove indirections.  */
@@ -3607,12 +3665,22 @@
     return false;
 
   if (!objc_is_object_id (ltyp) && !objc_is_class_id (ltyp)
-      && !TYPE_HAS_OBJC_INFO (ltyp))
-    return false;
+  /* APPLE LOCAL begin radar 5595325 */
+      && !TYPE_HAS_OBJC_INFO (ltyp)) {
+    /* Allow NSObject pointers to match 'id' */
+    return (objc_nsobject_attribute_type (orig_ltyp) && objc_is_object_id (rtyp)) 
+           ? true : false;
+  }
+  /* APPLE LOCAL end radar 5595325 */
 
   if (!objc_is_object_id (rtyp) && !objc_is_class_id (rtyp)
-      && !TYPE_HAS_OBJC_INFO (rtyp))
-    return false;
+  /* APPLE LOCAL begin radar 5595325 */
+      && !TYPE_HAS_OBJC_INFO (rtyp)) {
+    /* Allow NSObject pointers to match 'id' */
+    return (objc_nsobject_attribute_type (orig_rtyp) && objc_is_object_id (ltyp)) 
+           ? true : false;
+  }
+  /* APPLE LOCAL end radar 5595325 */
 
   /* APPLE LOCAL begin 4175534 */
   /* Past this point, we are committed to returning 'true' to the caller
@@ -6543,6 +6611,10 @@
 objc_is_object_ptr (tree type)
 {
   tree ret;
+  /* APPLE LOCAL begin radar 5595325 */
+  if (objc_nsobject_attribute_type (type))
+    return TREE_TYPE (type);
+  /* APPLE LOCAL end radar 5595325 */
 
   type = TYPE_MAIN_VARIANT (type);
   if (!POINTER_TYPE_P (type))
@@ -6619,10 +6691,7 @@
          '__weak' */
       if (TREE_CODE (type) == BLOCK_POINTER_TYPE)
         {
-          type = TREE_TYPE (TREE_TYPE (type));
-          while (POINTER_TYPE_P (type))
-            type = TREE_TYPE (type);
-          strong = (objc_is_strong_p (type) >= 0 ? 1 : -1);
+	  strong = block_pointer_strong_value (type);
           break;
         }
       /* APPLE LOCAL end radar 5882266, 5832193 */
@@ -7944,7 +8013,14 @@
   if (flag_objc_sjlj_exceptions)
     {
       /* LLVM LOCAL begin */    
+#ifdef ENABLE_LLVM
       OBJC_FLAG_SJLJ_EXCEPTIONS;
+#else
+      if (darwin_macosx_version_min 
+	  && strverscmp (darwin_macosx_version_min, "10.3") < 0)
+	warning (0, "Mac OS X version 10.3 or later is needed instead of %s for objc/obj-c++ exceptions",
+	         darwin_macosx_version_min);
+#endif
       /* LLVM LOCAL end */
     }
   /* APPLE LOCAL end radar 4590191 */
@@ -12855,7 +12931,7 @@
    for these two arguments. This is to make rest of the "format" attribute
    processing done in the middle-end to work seemlessly. */
 
-static tree
+static void
 objc_delta_format_args (tree format)
 {
   tree format_num_expr, first_arg_num_expr;
@@ -12872,9 +12948,11 @@
   if (first_arg_num_expr && TREE_CODE (first_arg_num_expr) == INTEGER_CST)
     {
       val = TREE_INT_CST_LOW (first_arg_num_expr);
-      TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))) = build_int_cst (NULL_TREE, val+2);
+      /* APPLE LOCAL begin radar 6157135 */
+      if (val != 0)
+        TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))) = build_int_cst (NULL_TREE, val+2);
+      /* APPLE LOCAL end radar 6157135 */
     }
-  return format;
 }
 
 /* This routine recognizes objc legal attributes. In case of "format" 
@@ -12885,14 +12963,12 @@
 {
   tree chain;
   bool res = false;
-  if (!attributes)
-    return res;
   for (chain = attributes; chain; chain = TREE_CHAIN (chain))
     {
       if (is_attribute_p ("format", TREE_PURPOSE (chain)))
 	{
-	  chain = objc_delta_format_args (chain);
-	  return true;
+	  objc_delta_format_args (chain);
+	  res = true;
 	}
       else if (is_attribute_p ("sentinel", TREE_PURPOSE (chain)))
 	res = true;	
@@ -13421,10 +13497,14 @@
 	/* APPLE LOCAL end radar 3533972 */
 #endif
 	  /* APPLE LOCAL end decay function/array receivers */
-	  warning (0, "invalid receiver type %qs",
-		   gen_type_name (orig_rtype));
-	  /* After issuing the "invalid receiver" warning, perform method
-	     lookup as if we were messaging 'id'.  */
+          /* APPLE LOCAL begin radar 5595325 */
+          /* Do not issue this warning on random NSObject objects. */
+          if (!objc_nsobject_attribute_type (orig_rtype))
+            warning (0, "invalid receiver type %qs",
+                     gen_type_name (orig_rtype));
+            /* After issuing the "invalid receiver" warning, perform method
+              lookup as if we were messaging 'id'.  */
+           /* APPLE LOCAL end radar 5595325 */
 	  rtype = rprotos = NULL_TREE;
 	}
     }
@@ -15077,6 +15157,24 @@
 }
 /* APPLE LOCAL end radar 4449535 */
 
+/* APPLE LOCAL begin radar 5453108 */
+/* This routine checks to see if there is a setter/getter method declared in current
+   class. If so, it returns 'true' so caller does not issue a warning. This is 
+   the case of a method declared in class's protocol which matches class's getter/settter.
+*/
+static bool
+property_method_in_class (tree meth, bool inst_method, tree interface)
+{
+  tree list, property_method;
+  if (!interface || !inst_method)
+    return false;
+  list = CLASS_NST_METHODS (interface);
+
+  property_method = lookup_method (list, meth);
+  return (property_method && 
+	  METHOD_PROPERTY_CONTEXT (property_method) != NULL); 
+}
+/* APPLE LOCAL end radar 5453108 */
 /* Make sure all entries in CHAIN are also in LIST.  */
 
 static int
@@ -15093,13 +15191,15 @@
       /* APPLE LOCAL end radar 4359757 */
 	{
 	  /* APPLE LOCAL begin C* property metadata (Radar 4498373) */
-	  if (chain != NULL && METHOD_PROPERTY_CONTEXT (chain) != NULL_TREE)
+	  /* APPLE LOCAL begin radar 5453108 */
+	  if (chain != NULL && (METHOD_PROPERTY_CONTEXT (chain) != NULL_TREE ||
+				property_method_in_class (chain, mtype == (int)'-', interface)))
+	  /* APPLE LOCAL end radar 5453108 */
 	    {
 	      /* Case of instance method in interface not found in its implementation.
 		 This is OK in case of instance method setter/getter declaration synthesized 
 		 via property declaration in the interface. Happens for dynamic properties. */
 	      gcc_assert (mtype == (int)'-');
-	      gcc_assert (TREE_CODE (METHOD_PROPERTY_CONTEXT (chain)) == PROPERTY_DECL);
 	      chain = TREE_CHAIN (chain);
 	      continue;
 	    }
@@ -16041,7 +16141,10 @@
   input_location = DECL_SOURCE_LOCATION (property);
   /* APPLE LOCAL end radar 5839812 - location for synthesized methods  */
 
-  objc_lookup_property_ivar (class, property);
+  /* APPLE LOCAL begin radar 5435299 */
+  if (!flag_new_property_ivar_synthesis)
+    objc_lookup_property_ivar (class, property);
+  /* APPLE LOCAL end radar 5435299 */
 
   /* Find declaration of the property in the interface. There must be one. */
   /* APPLE LOCAL radar 5040740 - radar 5207415 */
@@ -16172,7 +16275,10 @@
                      objc_implementation_context),setter_ident))
     return;
 
-  objc_lookup_property_ivar (class, property);
+  /* APPLE LOCAL begin radar 5435299 */
+  if (!flag_new_property_ivar_synthesis)
+    objc_lookup_property_ivar (class, property);
+  /* APPLE LOCAL end radar 5435299 */
 
   /* Find declaration of the property in the interface. There must be one. */
   /* APPLE LOCAL radar 5040740 */
@@ -16428,7 +16534,7 @@
 {
   tree record = CLASS_STATIC_TEMPLATE (class);
   tree type = TREE_TYPE (property);
-  tree field_decl, field;
+  tree field_decl, field, nf;
   /* APPLE LOCAL begin radar 6029624 */
 #ifdef OBJCPLUS
   if (TREE_CODE (type) == REFERENCE_TYPE)
@@ -16439,14 +16545,27 @@
                                   ivar_name ? ivar_name 
 					    : objc_build_property_ivar_name (property));
   DECL_CONTEXT (field_decl) = record;
+  /* APPLE LOCAL begin radar 5435299 */
+  /* With -fnew-property-ivar_synthesis, synthesized 'ivar' is always private. */
   (void) add_instance_variable (class,
-                                1, field_decl);
+                                !flag_new_property_ivar_synthesis ? 1 : 2, field_decl);
+  /* APPLE LOCAL end radar 5435299 */
   if (objc_is_strong_p (type) == -1)
     {
       tree attribute = tree_cons (NULL_TREE, get_identifier ("weak"), NULL_TREE);
       attribute = tree_cons (get_identifier ("objc_gc"), attribute, NULL_TREE);
       decl_attributes (&field_decl, attribute, 0);
     }
+  /* APPLE LOCAL begin radar 5435299 */
+  nf = copy_node (field_decl);
+  if (flag_new_property_ivar_synthesis)
+    {
+      /* New field added to struct must not have ivar specific access info.
+         This confuses c++'s side of its own access field checking. */
+      TREE_PUBLIC (nf) = IVAR_PUBLIC_OR_PROTECTED (nf) = 1;
+      TREE_PRIVATE (nf) = TREE_PROTECTED (nf) = 0;
+    }
+  /* APPLE LOCAL end radar 5435299 */
   /* Unfortunately, CLASS_IVARS is completed when interface is completed.
      Must add the new ivar by hand to its list here. */
 
@@ -16459,14 +16578,12 @@
   if (field && TREE_CHAIN (field)
       && TREE_CODE (TREE_CHAIN (field)) != FIELD_DECL)
     {
-      tree nf = copy_node (field_decl);
       TREE_CHAIN (nf) = TREE_CHAIN (field);
       TREE_CHAIN (field) = nf;
     }
   else
 #endif /* OBJCPLUS */
-  CLASS_IVARS (class) = chainon (CLASS_IVARS (class),
-                                 copy_node (field_decl));
+  CLASS_IVARS (class) = chainon (CLASS_IVARS (class), nf);
   gcc_assert (record);
   /* Must also add this ivar to the end of list of fields for this class. */
   field = TYPE_FIELDS (record);
@@ -16478,6 +16595,10 @@
   /* Ugh, must recalculate struct layout since an ivar was added. */
   TYPE_SIZE (record) = 0;
   layout_type (record);
+  /* APPLE LOCAL begin radar 5435299 */
+  if (flag_new_property_ivar_synthesis)
+    objc_ivar_chain = CLASS_RAW_IVARS (class);
+  /* APPLE LOCAL end radar 5435299 */
 }
 
 /* This routine looks up PROPERTY's 'ivar' in the CLASS. If one not found, it inserts one
@@ -18867,7 +18988,7 @@
       if (flag_objc_abi != 2)
 #endif
       /* LLVM LOCAL end - radar 5702446 */
-        ASM_DECLARE_CLASS_REFERENCE (asm_out_file, string);
+      ASM_DECLARE_CLASS_REFERENCE (asm_out_file, string);
       return;
     }
   else
@@ -19300,6 +19421,10 @@
   if (!POINTER_TYPE_P (typ))
     return false;
 
+  /* APPLE LOCAL begin radar 5595325 */
+  if (objc_nsobject_attribute_type (typ))
+    return true;
+  /* APPLE LOCAL end radar 5595325 */
   do
     typ = TREE_TYPE (typ);  /* Remove indirections.  */
   while (POINTER_TYPE_P (typ));
@@ -19649,6 +19774,36 @@
 
 /* APPLE LOCAL end radar 5040740 */
 
+/* APPLE LOCAL begin radar 5435299 */
+/* lookup_property_impl_in_list - Look for an existing property
+  @synthesize/@dynamic in current implementation.
+*/
+static tree
+lookup_property_impl_in_list (tree chain, tree property)
+{
+  tree x;
+  for (x = IMPL_PROPERTY_DECL (chain); x; x = TREE_CHAIN (x))
+    if (PROPERTY_NAME (x) == property)
+      return x;
+  return NULL_TREE;
+}
+
+/* lookup_ivar_in_property_list - Searches current property list looking for
+   one which uses the given ivar_name. If found, it returns this property.
+*/
+
+static tree
+lookup_ivar_in_property_list (tree chain, tree ivar_name)
+{
+  tree x;
+  for (x = IMPL_PROPERTY_DECL (chain); x; x = TREE_CHAIN (x))
+    if (PROPERTY_IVAR_NAME (x) == ivar_name)
+      return x;
+  return NULL_TREE;
+}
+
+/* APPLE LOCAL end radar 5435299 */
+
 /* This routine declares a new property implementation. Triggered by a @synthesize or
    @dynamic declaration. */
 void objc_declare_property_impl (int impl_code, tree tree_list)
@@ -19723,10 +19878,16 @@
 		     property name must be used. */
 		  if (!ivar_name)
 		    ivar_name = property_name;
+	   	  /* APPLE LOCAL radar 5435299 */
+		  PROPERTY_IVAR_NAME (property_decl) = ivar_name;
 		  ivar_decl = nested_ivar_lookup (class, ivar_name);
+		  /* APPLE LOCAL begin radar 5847641 */
+	          if (flag_objc_abi <= 1 && TREE_PURPOSE (chain) && !ivar_decl)
+		    warning (0, "ivar name %qs specified on the synthesized property %qs not found",
+                    	     IDENTIFIER_POINTER (ivar_name), IDENTIFIER_POINTER (property_name)) ;
+		  /* APPLE LOCAL end radar 5847641 */
 		  if (ivar_decl)
 		    {
-		      /* APPLE LOCAL begin radar 5389292 */
 		    /* Check for semnatic correctness of the existing ivar. */
 		      tree ivar_type = DECL_BIT_FIELD_TYPE (ivar_decl) 
 					 ? DECL_BIT_FIELD_TYPE (ivar_decl) 
@@ -19734,6 +19895,21 @@
                       /* APPLE LOCAL begin radar 6029624 */
                       tree property_type = TREE_TYPE (property_decl);
 		      bool comparison_result;
+                      /* APPLE LOCAL begin radar 5435299 */
+                      if (flag_new_property_ivar_synthesis && flag_objc_abi == 2 && 
+			  !TREE_PURPOSE (chain)) {
+                        /* In ObjC2 abi, it is illegal when a @synthesize with no named ivar
+                           does not have a matching ivar in its class but some superclass ivar
+                           already has the desired name */
+                        tree record = CLASS_STATIC_TEMPLATE (class);
+                        if (record && record != DECL_CONTEXT (ivar_decl))
+                          error ("property %qs attempting to use ivar %qs in super class %qs",
+                                 IDENTIFIER_POINTER (property_name),
+                                 IDENTIFIER_POINTER (ivar_name),
+                                 IDENTIFIER_POINTER (OBJC_TYPE_NAME (record)));
+                      }
+                      /* APPLE LOCAL end radar 5435299 */
+		      /* APPLE LOCAL begin radar 5389292 */
 #ifdef OBJCPLUS
                       if (TREE_CODE (property_type) == REFERENCE_TYPE)
 			{
@@ -19774,9 +19950,24 @@
 			    }
 			}
 		    }
-				
-		  PROPERTY_IVAR_NAME (property_decl) = ivar_name;
+                  /* APPLE LOCAL begin radar 5435299 */
+                  else if (flag_new_property_ivar_synthesis)
+                         objc_lookup_property_ivar (class, property_decl);
+                  if (flag_new_property_ivar_synthesis &&
+		      (x = lookup_ivar_in_property_list (objc_implementation_context,
+                                                         ivar_name)))
+                    error ("synthesized properties %qs and %qs both claim ivar %qs",
+                           IDENTIFIER_POINTER (property_name),
+                           IDENTIFIER_POINTER (DECL_NAME (x)),
+                           IDENTIFIER_POINTER (ivar_name));
+                  /* APPLE LOCAL end radar 5435299 */
 		}
+              /* APPLE LOCAL begin radar 5435299 */
+              if (flag_new_property_ivar_synthesis &&
+		  lookup_property_impl_in_list (objc_implementation_context, property_name))
+                error ("property %qs is already implemented",
+                       IDENTIFIER_POINTER (property_name));
+              /* APPLE LOCAL end radar 5435299 */
 	     /* Add the property to the list of properties for current implementation. */
              TREE_CHAIN (property_decl) = IMPL_PROPERTY_DECL (objc_implementation_context);
              IMPL_PROPERTY_DECL (objc_implementation_context) = property_decl;

Modified: llvm-gcc-4.2/trunk/gcc/rtl.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/rtl.h?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/rtl.h (original)
+++ llvm-gcc-4.2/trunk/gcc/rtl.h Tue Sep  2 17:20:12 2008
@@ -2143,6 +2143,8 @@
 /* In function.c */
 extern void reposition_prologue_and_epilogue_notes (rtx);
 extern void thread_prologue_and_epilogue_insns (rtx);
+    /* APPLE LOCAL async unwind info 5949350 */
+extern int epilogue_contains (rtx);
 extern int prologue_epilogue_contains (rtx);
 extern int sibcall_epilogue_contains (rtx);
 extern void mark_temp_addr_taken (rtx);

Modified: llvm-gcc-4.2/trunk/gcc/stmt.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/stmt.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/stmt.c (original)
+++ llvm-gcc-4.2/trunk/gcc/stmt.c Tue Sep  2 17:20:12 2008
@@ -1727,7 +1727,10 @@
 	  store_bit_field (dst, bitsize, xbitpos % BITS_PER_WORD, word_mode,
 			   extract_bit_field (src, bitsize,
 					      bitpos % BITS_PER_WORD, 1,
-					      NULL_RTX, word_mode, word_mode));
+			   /* APPLE LOCAL begin 6020402 */
+					      NULL_RTX, word_mode, word_mode),
+			   NULL_TREE);
+			   /* APPLE LOCAL end 6020402 */
 	}
 
       tmpmode = GET_MODE (result_rtl);

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5596043.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/5596043.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5596043.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5596043.C Tue Sep  2 17:20:12 2008
@@ -1,6 +1,6 @@
 /* APPLE LOCAL file radar 5591491 */
 /* { dg-options "-O2" } */
-/* { dg-do run { target powerpc**-*-darwin* } } */
+/* { dg-do compile { target powerpc**-*-darwin* } } */
 
 struct T {
   volatile unsigned int word;

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-2.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-2.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-2.C Tue Sep  2 17:20:12 2008
@@ -1,6 +1,7 @@
 /* APPLE LOCAL file 5932809 */
 /* { dg-options "-fblocks" } */
 /* { dg-do run } */
+void _Block_byref_release(void*src){}
 
 #include <stdio.h>
 

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-3.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-3.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-3.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-3.C Tue Sep  2 17:20:12 2008
@@ -1,6 +1,7 @@
 /* APPLE LOCAL file 5932809 */
 /* { dg-options "-fblocks" } */
 /* { dg-do run } */
+void _Block_byref_release(void*src){}
 
 #include <stdio.h>
 

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/kext-stackprotect-1.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-1.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-1.C Tue Sep  2 17:20:12 2008
@@ -1,6 +1,8 @@
 /* APPLE LOCAL file stack-protector default 5095227 */
 /* { dg-do compile { target powerpc*-*-darwin* } } */
 /* { dg-options "-fapple-kext -mmacosx-version-min=10.6" } */
+/* { dg-skip-if "" { *-*-darwin* } { "-fstack-protector" } { "" } } */
+/* { dg-skip-if "" { *-*-darwin* } { "-fstack-protector-all" } { "" } } */
 extern void f2(char *);
 void f1(void)
 {

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/kext-stackprotect-2.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-2.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/kext-stackprotect-2.C Tue Sep  2 17:20:12 2008
@@ -1,11 +1,13 @@
 /* APPLE LOCAL file stack-protector default 5095227 */
 /* { dg-do compile { target i?86*-*-darwin* } } */
-/* { dg-options "-fapple-kext" } */
+/* { dg-options "-fapple-kext -mmacosx-version-min=10.6" } */
+/* { dg-skip-if "" { *-*-darwin* } { "-fstack-protector" } { "" } } */
+/* { dg-skip-if "" { *-*-darwin* } { "-fstack-protector-all" } { "" } } */
 extern void f2(char *);
 void f1(void)
 {
   char array[256];
   f2(array);
 }
-/* { dg-final { scan-assembler-not "__stack_chk_guard" } } */
-/* { dg-final { scan-assembler-not "__stack_chk_fail" } } */
+/* { dg-final { scan-assembler "__stack_chk_guard" } } */
+/* { dg-final { scan-assembler "__stack_chk_fail" } } */

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/inline-limit-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.dg/inline-limit-1.C?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/inline-limit-1.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/inline-limit-1.C Tue Sep  2 17:20:12 2008
@@ -11,22 +11,25 @@
    but this testcase is expected to require revision every time the
    GCC inlining heuristics change.  */
 
-extern void bulk (int);	/* CALLs are assumed to generate 10 'estimated insns'.  */
+/* CALLs with three int arguments and no return type are assumed to generate 5
+   'estimated insns'. */
+extern void bulk (int, int, int);
 
 /* Inlining limits for inline and non-inline functions are currently
-   identical for C++.  Empirically, a body with one will be inlined,
-   and a body with two calls will not.  */
+   identical for C++.  Empirically, a body with few instructions will be
+   inlined, and a body with several calls will not.  */
 
 void
 calleex1 (void)
 {
-  bulk (1); bulk (2);
+  bulk (1,1,1); bulk (2,1,1); bulk (3,1,1); bulk (4,1,1);
+  bulk (5,1,1); bulk (6,1,1);
 }
 
-void inline
+void
 inlinex1 (void)
 {
-  bulk (1);
+  bulk (1,4,2);
 }
 
 int

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c Tue Sep  2 17:20:12 2008
@@ -4,7 +4,8 @@
 extern int inside_main;
 
 int
-sprintf (char *buf, const char *fmt, ...)
+/* APPLE LOCAL radar 6112293 */
+(sprintf) (char *buf, const char *fmt, ...)
 {
   va_list ap;
   int r;

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/cpp/trad/include.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/cpp/trad/include.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/cpp/trad/include.c (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/cpp/trad/include.c Tue Sep  2 17:20:12 2008
@@ -5,5 +5,7 @@
 /* { dg-do preprocess } */
 
 #define __STDC__ 1	/* Stop complaints about non-ISO compilers.  */
-#define stdio 1
-#include <stdio.h>		/* { dg-bogus "o such file or directory" } */
+/* APPLE LOCAL begin Radar 6112293 */
+#define errno 1
+#include <errno.h>		/* { dg-bogus "o such file or directory" } */
+/* APPLE LOCAL end Radar 6112293 */

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/20020616-1.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/20020616-1.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/20020616-1.c (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/20020616-1.c Tue Sep  2 17:20:12 2008
@@ -1,5 +1,7 @@
 /* PR opt/6722 */
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* APPLE LOCAL 5951276 */
+/* { dg-skip-if "<rdar://problem/5951276>" { i?86-apple-darwin* } } */
 /* { dg-options "-O2" } */
 
 register int k asm("%ebx");

Added: llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/6128170.m
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/6128170.m?rev=55675&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/6128170.m (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/6128170.m Tue Sep  2 17:20:12 2008
@@ -0,0 +1,15 @@
+/* APPLE LOCAL file 6128170 */
+/* { dg-do compile { target i?86*-*-darwin* x86_64-*-darwin* } } */
+/* { dg-options { "-m64" } } */
+/* { dg-final { scan-assembler "GCC_except_table.*:\nLLSDA" } } */
+/* { dg-final { scan-assembler-not "GCC_except_table.*:\n\t.align" } } */
+#include <Foundation/Foundation.h>
+void test()
+{
+  @try {
+    [NSObject alloc];
+  }
+  @catch (NSException* ex) {
+    [NSObject alloc];
+  }
+}

Modified: llvm-gcc-4.2/trunk/gcc/tree.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.h (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.h Tue Sep  2 17:20:12 2008
@@ -3070,7 +3070,9 @@
  /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
  unsigned copyable_byref_local_var : 1;
  unsigned copyable_byref_local_nonpod : 1;
- /* 6 unused bits. */
+ /* APPLE LOCAL radar 6172148 */
+ unsigned block_synthesized_function : 1;
+ /* 5 unused bits. */
  /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
  /* APPLE LOCAL end radar 5732232 - blocks */
 };
@@ -3123,6 +3125,8 @@
 #define BLOCK_DECL_BYREF(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_byref)
 #define BLOCK_DECL_COPIED(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_copied)
 /* APPLE LOCAL end radar 5732232 - blocks */
+/* APPLE LOCAL radar 6172148 */
+#define BLOCK_SYNTHESIZED_FUNC(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.block_synthesized_function)
 /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
 #define COPYABLE_BYREF_LOCAL_VAR(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_var)
 #define COPYABLE_BYREF_LOCAL_NONPOD(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_nonpod)
@@ -4850,6 +4854,6 @@
 /* APPLE LOCAL end CW asm blocks */
 
 /* APPLE LOCAL radar 6113240 */
-extern tree invoke_impl_ptr_type;
+extern GTY(()) tree invoke_impl_ptr_type;
 
 #endif  /* GCC_TREE_H  */

Modified: llvm-gcc-4.2/trunk/gcc/varasm.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/varasm.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/varasm.c (original)
+++ llvm-gcc-4.2/trunk/gcc/varasm.c Tue Sep  2 17:20:12 2008
@@ -4243,6 +4243,8 @@
     case ENUMERAL_TYPE:
     case POINTER_TYPE:
     case REFERENCE_TYPE:
+    /* APPLE LOCAL radar 5822844 */
+    case BLOCK_POINTER_TYPE:
     case OFFSET_TYPE:
       if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
 					   EXPAND_INITIALIZER),

Modified: llvm-gcc-4.2/trunk/gcc/version.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/version.c?rev=55675&r1=55674&r2=55675&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/version.c (original)
+++ llvm-gcc-4.2/trunk/gcc/version.c Tue Sep  2 17:20:12 2008
@@ -11,12 +11,12 @@
 /* APPLE LOCAL begin Apple version */
 #ifdef ENABLE_LLVM
 #ifdef LLVM_VERSION_INFO
-#define VERSUFFIX " (Based on Apple Inc. build 5617) (LLVM build " LLVM_VERSION_INFO ")"
+#define VERSUFFIX " (Based on Apple Inc. build 5620) (LLVM build " LLVM_VERSION_INFO ")"
 #else
-#define VERSUFFIX " (Based on Apple Inc. build 5617) (LLVM build)"
+#define VERSUFFIX " (Based on Apple Inc. build 5620) (LLVM build)"
 #endif
 #else
-#define VERSUFFIX " (Based on Apple Inc. build 5617)"
+#define VERSUFFIX " (Based on Apple Inc. build 5620)"
 #endif
 /* APPLE LOCAL end Apple version */
 





More information about the llvm-commits mailing list