Fix mistake in Language Specification for Blocks
Dmitri Gribenko
gribozavr at gmail.com
Mon Feb 16 14:40:27 PST 2015
+ John
On Mon, Feb 16, 2015 at 4:34 AM, Peter Cawley <corsix at corsix.org> wrote:
> The Language Specification for Blocks, as published at
> http://clang.llvm.org/docs/BlockLanguageSpec.html, currently claims
> that `^ int ((*)(float x))(char) { return functionPointer; }` is valid
> syntax, and is equivalent to other valid syntax. I doubt that this was
> ever the case, and it certainly isn't the case currently:
>
> ```
> [littlegate /Users/corsix]$ cat test.cpp
> int main() {
> int (*functionPointer)(char) = 0;
> auto b = ^ int ((*)(float x))(char) { return functionPointer; };
> }
> [littlegate /Users/corsix]$ clang -std=c++11 test.cpp
> test.cpp:3:22: error: function cannot return function type 'int (char)'
> auto b = ^ int ((*)(float x))(char) { return functionPointer; };
> ^
> test.cpp:3:48: error: cannot initialize return object of type 'int
> (*)(float)' with an lvalue of type 'int (*const)(char)': type mismatch
> at 1st parameter ('float' vs 'char')
> auto b = ^ int ((*)(float x))(char) { return functionPointer; };
> ^~~~~~~~~~~~~~~
> 2 errors generated.
> ```
>
> The attached patch changes the documentation to what I think was
> meant, which seems to compile cleanly:
>
> ```
> [littlegate /Users/corsix]$ cat test.cpp
> int main() {
> int (*functionPointer)(char) = 0;
> auto b = ^ int (*(float x))(char) { return functionPointer; };
> }
> [littlegate /Users/corsix]$ clang -std=c++11 test.cpp && echo No Errors
> No Errors
> ```
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-commits
mailing list