diff options
author | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
commit | 36c49e3f258dced101949edabd72e9bc3f1dedc4 (patch) | |
tree | 0bbe07708f7571f8b5291f6d7b96c102b7c99dee /www/compatibility.html | |
parent | fc84956ac8b7cd244ef30e7a4d4d38a58dec5904 (diff) | |
download | FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.zip FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.tar.gz |
Vendor import of clang r114020 (from the release_28 branch):
http://llvm.org/svn/llvm-project/cfe/branches/release_28@114020
Approved by: rpaulo (mentor)
Diffstat (limited to 'www/compatibility.html')
-rw-r--r-- | www/compatibility.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/www/compatibility.html b/www/compatibility.html index 0f8409b..cf0d96e 100644 --- a/www/compatibility.html +++ b/www/compatibility.html @@ -33,6 +33,7 @@ <ul> <li><a href="#inline">C99 inline functions</a></li> <li><a href="#lvalue-cast">Lvalue casts</a></li> + <li><a href="#blocks-in-protected-scope">Jumps to within <tt>__block</tt> variable scope</a></li> </ul> </li> <li><a href="#objective-c">Objective-C compatibility</a> @@ -58,6 +59,9 @@ <ul> <li><a href="#implicit-downcasts">Implicit downcasts</a></li> </ul> + <ul> + <li><a href="#Use of class as method name">Use of class as method name</a></li> + </ul> </li> </ul> @@ -132,6 +136,55 @@ example, one could use:</p> </pre> <!-- ======================================================================= --> +<h3 id="blocks-in-protected-scope">Jumps to within <tt>__block</tt> variable scope</h3> +<!-- ======================================================================= --> + +<p>Clang disallows jumps into the scope of a <tt>__block</tt> variable, similar +to the manner in which both GCC and Clang disallow jumps into the scope of +variables which have user defined constructors (in C++).</p> + +<p>Variables marked with <tt>__block</tt> require special runtime initialization +before they can be used. A jump into the scope of a <tt>__block</tt> variable +would bypass this initialization and therefore the variable cannot safely be +used.</p> + +<p>For example, consider the following code fragment:</p> + +<pre> +int f0(int c) { + if (c) + goto error; + + __block int x; + x = 1; + return x; + + error: + x = 0; + return x; +} +</pre> + +<p>GCC accepts this code, but it will crash at runtime along the error path, +because the runtime setup for the storage backing the <tt>x</tt> variable will +not have been initialized. Clang rejects this code with a hard error:</p> + +<pre> +t.c:3:5: error: goto into protected scope + goto error; + ^ +t.c:5:15: note: jump bypasses setup of __block variable + __block int x; + ^ +</pre> + +<p>Some instances of this construct may be safe if the variable is never used +after the jump target, however the protected scope checker does not check the +uses of the variable, only the scopes in which it is visible. You should rewrite +your code to put the <tt>__block</tt> variables in a scope which is only visible +where they are used.</p> + +<!-- ======================================================================= --> <h2 id="objective-c">Objective-C compatibility</h3> <!-- ======================================================================= --> @@ -604,6 +657,28 @@ explicit cast:</p> f((Derived *)base); </pre> +<!-- ======================================================================= --> +<h3 id="Use of class as method name">Use of class as method name</h3> +<!-- ======================================================================= --> + +<p>Use of 'class' name to declare a method is allowed in objective-c++ mode to +be compatible with GCC. However, use of property dot syntax notation to call +this method is not allowed in clang++, as [I class] is a suitable syntax that +will work. So, this test will fail in clang++. + +<pre> +@interface I { +int cls; +} ++ (int)class; +@end + +@implementation I +- (int) Meth { return I.class; } +@end +<pre> + + </div> </body> </html> |