[llvm-branch-commits] [llvm-gcc-branch] r98913 - in /llvm-gcc-4.2/branches/Apple/Morbo: ./ gcc/ChangeLog.apple gcc/c-common.c gcc/c-common.h gcc/c-typeck.c gcc/cp/semantics.c gcc/testsuite/ChangeLog.apple gcc/testsuite/g++.apple/block-dynamic-array.C gcc/testsuite/gcc.apple/block-dynamic-array.c
Stuart Hastings
stuart at apple.com
Thu Mar 18 17:50:41 PDT 2010
Author: stuart
Date: Thu Mar 18 19:50:41 2010
New Revision: 98913
URL: http://llvm.org/viewvc/llvm-project?rev=98913&view=rev
Log:
Diagnose misused __block variables. Radar 7760213. Patch by Fariborz Jahanian!
Modified:
llvm-gcc-4.2/branches/Apple/Morbo/ (props changed)
llvm-gcc-4.2/branches/Apple/Morbo/gcc/ChangeLog.apple
llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.c
llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.h
llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-typeck.c
llvm-gcc-4.2/branches/Apple/Morbo/gcc/cp/semantics.c
llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/ChangeLog.apple
llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/g++.apple/block-dynamic-array.C
llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/gcc.apple/block-dynamic-array.c
Propchange: llvm-gcc-4.2/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 18 19:50:41 2010
@@ -1 +1 @@
-/llvm-gcc-4.2/trunk:98728
+/llvm-gcc-4.2/trunk:98728,98841,98893
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/ChangeLog.apple?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/ChangeLog.apple (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/ChangeLog.apple Thu Mar 18 19:50:41 2010
@@ -1,3 +1,11 @@
+2010-03-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7760213
+ * c-common.h (HasByrefArray): New decl.
+ * c-common.c (HasByrefArray): New definition.
+ * c-typeck.c (build_external_ref): Diagnose access of
+ __block array.
+
2010-01-07 Jim Grosbach <grosbach at apple.com>
Radar 7519550
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.c?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.c (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.c Thu Mar 18 19:50:41 2010
@@ -9355,4 +9355,20 @@
return build_function_call (build_block_object_dispose_decl (), func_params);
}
/* APPLE LOCAL end radar 5847976 */
+/* APPLE LOCAL begin radar 7760213 */
+int HasByrefArray(tree byrefType)
+{
+ tree s1;
+ /* Check for possibility of an error condition. */
+ if (TREE_CODE(byrefType) != RECORD_TYPE)
+ return 0;
+
+ for (s1 = TYPE_FIELDS (byrefType); s1; s1 = TREE_CHAIN (s1))
+ {
+ if (TREE_CODE(TREE_TYPE(s1)) == ARRAY_TYPE)
+ return 1;
+ }
+ return 0;
+}
+/* APPLE LOCAL end radar 7760213 */
#include "gt-c-common.h"
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.h?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.h (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-common.h Thu Mar 18 19:50:41 2010
@@ -1242,6 +1242,9 @@
/* APPLE LOCAL radar 6353006 */
extern tree c_build_generic_block_struct_type (void);
+/* APPLE LOCAL radar 7760213 */
+extern int HasByrefArray(tree);
+
/* In c-omp.c */
extern tree c_finish_omp_master (tree);
extern tree c_finish_omp_critical (tree, tree);
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-typeck.c?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/c-typeck.c Thu Mar 18 19:50:41 2010
@@ -2146,6 +2146,7 @@
"array indexing");
}
}
+
/* Build an external reference to identifier ID. FUN indicates
whether this will be used for a function call. LOC is the source
@@ -2209,9 +2210,14 @@
{
/* APPLE LOCAL begin radar 5803600 (C++ ci) */
/* byref globals are directly accessed. */
- if (!gdecl)
+ /* APPLE LOCAL begin radar 7760213 */
+ if (!gdecl) {
+ if (HasByrefArray(TREE_TYPE (decl)))
+ error ("cannot access __block variable of array type inside block");
/* build a decl for the byref variable. */
decl = build_block_byref_decl (id, decl, decl);
+ }
+ /* APPLE LOCAL end radar 7760213 */
else
add_block_global_byref_list (decl);
}
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/cp/semantics.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/cp/semantics.c?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/cp/semantics.c (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/cp/semantics.c Thu Mar 18 19:50:41 2010
@@ -2511,9 +2511,14 @@
|| (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
{
/* byref globals are directly accessed. */
- if (!gdecl)
+ /* APPLE LOCAL begin radar 7760213 */
+ if (!gdecl) {
+ if (HasByrefArray(TREE_TYPE (decl)))
+ error ("cannot access __block variable of array type inside block");
/* build a decl for the byref variable. */
decl = build_block_byref_decl (name, decl, decl);
+ }
+ /* APPLE LOCAL end radar 7760213 */
else
add_block_global_byref_list (decl);
}
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/ChangeLog.apple?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/ChangeLog.apple (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/ChangeLog.apple Thu Mar 18 19:50:41 2010
@@ -3,6 +3,12 @@
Radar 6671703
* objc.dg/arm-scalar-atomic-copyStruct.m: New.
+2010-03-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7760213
+ * gcc.apple/block-dynamic-array.c: Modified.
+ * g++.apple/block-dynamic-array.C: Modified.
+
2009-11-03 Stuart Hastings <stuart at apple.com>
Radar 6951876
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/g++.apple/block-dynamic-array.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/g%2B%2B.apple/block-dynamic-array.C?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/g++.apple/block-dynamic-array.C (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/g++.apple/block-dynamic-array.C Thu Mar 18 19:50:41 2010
@@ -75,3 +75,12 @@
[pool drain];
return 0 + res;
}
+
+int test()
+{
+__block int arr[100];
+
+ ^ {
+ (void)arr[2]; /* { dg-error "cannot access __block variable of array type inside block" } */
+ };
+}
Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/gcc.apple/block-dynamic-array.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/gcc.apple/block-dynamic-array.c?rev=98913&r1=98912&r2=98913&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/gcc.apple/block-dynamic-array.c (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/testsuite/gcc.apple/block-dynamic-array.c Thu Mar 18 19:50:41 2010
@@ -75,3 +75,12 @@
[pool drain];
return 0 + res;
}
+
+int test()
+{
+__block int arr[100];
+
+ ^ {
+ (void)arr[2]; /* { dg-error "cannot access __block variable of array type inside block" } */
+ };
+}
More information about the llvm-branch-commits
mailing list