summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-04-04 05:10:53 +0000
committerDouglas Gregor <dgregor@apple.com>2012-04-04 05:10:53 +0000
commit0e60cd78cc3c071870bba865663d09c09f184544 (patch)
treeb1c56857f4de66d4d8f85d1e26fd4bbeda287f44 /clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
parent34487838bfcb8b498fe91d6349c0f0acd397e8a9 (diff)
downloadbcm5719-llvm-0e60cd78cc3c071870bba865663d09c09f184544.tar.gz
bcm5719-llvm-0e60cd78cc3c071870bba865663d09c09f184544.zip
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<P'> rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. llvm-svn: 153998
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp16
1 files changed, 16 insertions, 0 deletions
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<typename T>
+ void f(std::initializer_list<T>) {
+ 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<const char *>' requested here}}
+
+ auto x = { "A", "BB", "CCC" };
+ std::initializer_list<const char *> *il = &x;
+
+ for( auto s : {"A", "BB", "CCC", "DDD"}) { }
+ }
+}
OpenPOWER on IntegriCloud