diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-08-30 00:44:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-08-30 00:44:08 +0000 |
commit | b1efc9b410eaa946a46bd20eb989aea126889916 (patch) | |
tree | ef85127acfb93942a90cea4f9ead253f23d6c2cb /clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp | |
parent | d5ba54549d144ae3d9e5978c3a26dace9ab783cc (diff) | |
download | bcm5719-llvm-b1efc9b410eaa946a46bd20eb989aea126889916.tar.gz bcm5719-llvm-b1efc9b410eaa946a46bd20eb989aea126889916.zip |
Give a better error if auto deduction fails due to inconsistent element types in a braced initializer list.
llvm-svn: 312085
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 9b8fadd2f52..78ebc048b26 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -136,9 +136,15 @@ void auto_deduction() { auto l3 {1}; static_assert(same_type<decltype(l), std::initializer_list<int>>::value, ""); static_assert(same_type<decltype(l3), int>::value, ""); - auto bl = {1, 2.0}; // expected-error {{cannot deduce}} + auto bl = {1, 2.0}; // expected-error {{deduced conflicting types ('int' vs 'double') for initializer list element type}} + + void f1(int), f1(float), f2(int), f3(float); + auto fil = {f1, f2}; + auto ffl = {f1, f3}; + auto fl = {f1, f2, f3}; // expected-error {{deduced conflicting types ('void (*)(int)' vs 'void (*)(float)') for initializer list element type}} for (int i : {1, 2, 3, 4}) {} + for (int j : {1.0, 2.0, 3.0f, 4.0}) {} // expected-error {{deduced conflicting types ('double' vs 'float') for initializer list element type}} } void dangle() { |