diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-03 17:47:53 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-03 17:47:53 +0000 |
commit | dd5eb9df0cd248bc20fdca01f007f7119633a7d7 (patch) | |
tree | c356b1607c20723349636ca119cae1a3dd635681 /clang/test/SemaCXX/instantiate-blocks.cpp | |
parent | 71ba18c1e08ea0a323974be32bebffeaa60808da (diff) | |
download | bcm5719-llvm-dd5eb9df0cd248bc20fdca01f007f7119633a7d7.tar.gz bcm5719-llvm-dd5eb9df0cd248bc20fdca01f007f7119633a7d7.zip |
If block literal return type is not specified, return type of the block is
inferred from return types. All the return statements have to agree about the type.
// rdar://10466373
llvm-svn: 145774
Diffstat (limited to 'clang/test/SemaCXX/instantiate-blocks.cpp')
-rw-r--r-- | clang/test/SemaCXX/instantiate-blocks.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/instantiate-blocks.cpp b/clang/test/SemaCXX/instantiate-blocks.cpp index a4001a75fa5..799951a0aea 100644 --- a/clang/test/SemaCXX/instantiate-blocks.cpp +++ b/clang/test/SemaCXX/instantiate-blocks.cpp @@ -12,8 +12,21 @@ template <typename T, typename T1> void foo(T t, T1 r) return block_arg+arg; }; } +// rdar://10466373 +template <typename T, typename T1> void noret(T t, T1 r) +{ + (void) ^{ + if (1) + return t; + else if (2) + return r; // expected-error {{return type 'const double' must match previous return type 'float' when block literal has unspecified explicit return type}} + }; +} + int main(void) { foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}} + + noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}} } |