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
```

Attachment: BlockLanguageSpec.rst.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to