[llvm-commits] [llvm-gcc-4.2] r97931 - in /llvm-gcc-4.2/trunk/gcc: c-typeck.c cp/semantics.c testsuite/g++.apple/block-dynamic-array.C testsuite/gcc.apple/block-dynamic-array.c

Stuart Hastings stuart at apple.com
Sun Mar 7 18:56:25 PST 2010


Author: stuart
Date: Sun Mar  7 20:56:25 2010
New Revision: 97931

URL: http://llvm.org/viewvc/llvm-project?rev=97931&view=rev
Log:
Diagnose illegal array refs from inside a block, instead of faulting.  Radar 7721728.  Patch by Fariborz Jahanian\!

Modified:
    llvm-gcc-4.2/trunk/gcc/c-typeck.c
    llvm-gcc-4.2/trunk/gcc/cp/semantics.c
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dynamic-array.C
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-dynamic-array.c

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=97931&r1=97930&r2=97931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-typeck.c Sun Mar  7 20:56:25 2010
@@ -2219,10 +2219,15 @@
 	    {
 	      /* 'byref' globals are never copied-in. So, do not add
 		 them to the copied-in list. */
-	      if (!in_block_global_byref_list (decl))
+	      if (!in_block_global_byref_list (decl)) {
+		/* APPLE LOCAL begin radar 7721728 */
+                if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+       		  error ("cannot access copied-in variable of array type inside block");
+		/* APPLE LOCAL end radar 7721728 */
 		/* build a new decl node. set its type to 'const' type
 		   of the old decl. */
 		decl = build_block_ref_decl (id, decl);
+              }
 	      /* APPLE LOCAL end radar 5803600 (C++ ci) */
 	      /* APPLE LOCAL end radar 5803005 (C++ ci) */
 	    }

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=97931&r1=97930&r2=97931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/semantics.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/semantics.c Sun Mar  7 20:56:25 2010
@@ -2521,10 +2521,15 @@
     {
       /* 'byref' globals are never copied-in. So, do not add
        them to the copied-in list. */
-      if (!in_block_global_byref_list (decl))
+      if (!in_block_global_byref_list (decl)) {
+	/* APPLE LOCAL begin radar 7721728 */
+        if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+          error ("cannot access copied-in variable of array type inside block");
+	/* APPLE LOCAL end radar 7721728 */
       /* build a new decl node. set its type to 'const' type
         of the old decl. */
         decl = build_block_ref_decl (name, decl);
+      }
     }
   }
   return decl;

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dynamic-array.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-dynamic-array.C?rev=97931&r1=97930&r2=97931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dynamic-array.C (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dynamic-array.C Sun Mar  7 20:56:25 2010
@@ -1,6 +1,8 @@
 /* APPLE LOCAL file radar 6212722 */
+/* APPLE LOCAL radar 7721728 */
+/* This is now error */
 /* Test for use of array (dynamic or static) as copied in object in a block. */
-/* { dg-do run { target *-*-darwin[1-2][0-9]* } } */
+/* { dg-do compile { target *-*-darwin[1-2][0-9]* } } */
 /* { dg-options "-mmacosx-version-min=10.6 -ObjC++ -framework Foundation" { target *-*-darwin* } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "-m64" } { "" } } */
 
@@ -30,7 +32,7 @@
 		NSLog (@"c = %d", c);
 		for (i = 0; i < c; ++i)
 		{
-			NSLog (@"array[%d] = %d", i, array[i]);
+			NSLog (@"array[%d] = %d", i, array[i]);	/* { dg-error "cannot access copied-in variable of array type inside block" } */
 		}
 	
 	};
@@ -62,7 +64,7 @@
 		NSLog (@"c = %d", c);
 		for (i = 0; i < c; ++i)
 		{
-			NSLog (@"array[%d] = %d", i, array[i]);
+			NSLog (@"array[%d] = %d", i, array[i]);	/* { dg-error "cannot access copied-in variable of array type inside block" } */
 		}
 	
 	};

Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-dynamic-array.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-dynamic-array.c?rev=97931&r1=97930&r2=97931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-dynamic-array.c (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-dynamic-array.c Sun Mar  7 20:56:25 2010
@@ -1,6 +1,8 @@
 /* APPLE LOCAL file radar 6212722 */
+/* APPLE LOCAL radar 7721728 */
+/* This is now error */
 /* Test for use of array (dynamic or static) as copied in object in a block. */
-/* { dg-do run { target *-*-darwin[1-2][0-9]* } } */
+/* { dg-do compile { target *-*-darwin[1-2][0-9]* } } */
 /* { dg-options "-mmacosx-version-min=10.6 -ObjC -framework Foundation" { target *-*-darwin* } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "-m64" } { "" } } */
 
@@ -30,7 +32,7 @@
 		NSLog (@"c = %d", c);
 		for (i = 0; i < c; ++i)
 		{
-			NSLog (@"array[%d] = %d", i, array[i]);
+			NSLog (@"array[%d] = %d", i, array[i]);	/* { dg-error "cannot access copied-in variable of array type inside block" } */
 		}
 	
 	};
@@ -62,7 +64,7 @@
 		NSLog (@"c = %d", c);
 		for (i = 0; i < c; ++i)
 		{
-			NSLog (@"array[%d] = %d", i, array[i]);
+			NSLog (@"array[%d] = %d", i, array[i]);	/* { dg-error "cannot access copied-in variable of array type inside block" } */
 		}
 	
 	};





More information about the llvm-commits mailing list