From 0e60cd78cc3c071870bba865663d09c09f184544 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 4 Apr 2012 05:10:53 +0000 Subject: When performing template argument deduction for an initializer list, be sure to perform the argument type adjustments in [temp.deduct.call]p2, e.g., array decay. And, when performing these deductions in the context of 'auto', make sure that we're deducing the P' in std::initializer_list rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. llvm-svn: 153998 --- .../SemaCXX/cxx0x-initializer-stdinitializerlist.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp') diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 0e0e8f254b0..3437849f931 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -150,3 +150,19 @@ namespace PR12119 { g({il, {2, 3}}); } } + +namespace Decay { + template + void f(std::initializer_list) { + T x = 1; // expected-error{{cannot initialize a variable of type 'const char *' with an rvalue of type 'int'}} + } + + void g() { + f({"A", "BB", "CCC"}); // expected-note{{in instantiation of function template specialization 'Decay::f' requested here}} + + auto x = { "A", "BB", "CCC" }; + std::initializer_list *il = &x; + + for( auto s : {"A", "BB", "CCC", "DDD"}) { } + } +} -- cgit v1.2.3