]> granicus.if.org Git - clang/commitdiff
Fix overload resolution for the initialization of a multi-dimensional
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 9 Dec 2012 06:48:56 +0000 (06:48 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 9 Dec 2012 06:48:56 +0000 (06:48 +0000)
array from a braced-init-list. There seems to be a core wording wart
here (it suggests we should be testing whether the elements of the init
list are implicitly convertible to the array element type, not whether
there is an implicit conversion sequence) but our prior behavior appears
to be a bug, not a deliberate effort to implement the standard as written.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169690 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/cxx0x-initializer-aggregates.cpp
test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

index 57e74d06b95e563c2dd33698c2e0fcf962a53a93..cfbd33c0d341ebcf4a8614f366305afb0fd91349 100644 (file)
@@ -4377,7 +4377,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
   bool toStdInitializerList = false;
   QualType X;
   if (ToType->isArrayType())
-    X = S.Context.getBaseElementType(ToType);
+    X = S.Context.getAsArrayType(ToType)->getElementType();
   else
     toStdInitializerList = S.isStdInitializerList(ToType, &X);
   if (!X.isNull()) {
index c83058a5e19602936b92de0250fb81f84a58fe04..7d1fa7e3ec2f242c3ae377fcbb5b50ba2035d172 100644 (file)
@@ -115,4 +115,13 @@ namespace sub_constructor {
   Aggr invalid { {} , {&ok1} , {0,0} }; // expected-error {{no matching constructor for initialization}}
   NoDefaultConstructor2 array_ok[] = { {0,0} , {0,1} };
   NoDefaultConstructor2 array_error[] = { {0,0} , {0} }; // expected-error {{no matching constructor for initialization}}
-}
\ No newline at end of file
+}
+
+namespace multidimensional_array {
+  void g(const int (&)[2][2]) {}
+  void g(const int (&)[2][2][2]) = delete;
+
+  void h() {
+    g({{1,2},{3,4}});
+  }
+}
index 0962253b988ccf0ee098042ea4fec845a36992a8..4fd419dc748e232a16a7f18c67c764647c92d158 100644 (file)
@@ -191,3 +191,11 @@ namespace rdar11948732 {
 namespace PR14272 {
   auto x { { 0, 0 } }; // expected-error {{cannot deduce actual type for variable 'x' with type 'auto' from initializer list}}
 }
+
+namespace initlist_of_array {
+  void f(std::initializer_list<int[2]>) {}
+  void f(std::initializer_list<int[2][2]>) = delete;
+  void h() {
+    f({{1,2},{3,4}});
+  }
+}