[cfe-commits] r163871 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/cxx0x-initializer-constructor.cpp

Douglas Gregor dgregor at apple.com
Thu Sep 13 21:20:37 PDT 2012


Author: dgregor
Date: Thu Sep 13 23:20:37 2012
New Revision: 163871

URL: http://llvm.org/viewvc/llvm-project?rev=163871&view=rev
Log:
As we do with base and member initializers in a dependent class, delay
type checking for non-static data member initializers in a dependent
class, because our ASTs lose too much information to when
type-checking an initializer. Fixes <rdar://problem/11974632>,
although the result is still rather unsatisfactory.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=163871&r1=163870&r2=163871&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 13 23:20:37 2012
@@ -1702,7 +1702,11 @@
   }
 
   ExprResult Init = InitExpr;
-  if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
+  if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent() &&
+      !FD->getDeclContext()->isDependentContext()) {
+    // Note: We don't type-check when we're in a dependent context, because
+    // the initialization-substitution code does not properly handle direct
+    // list initialization. We have the same hackaround for ctor-initializers.
     if (isa<InitListExpr>(InitExpr) && isStdInitializerList(FD->getType(), 0)) {
       Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
         << /*at end of ctor*/1 << InitExpr->getSourceRange();

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp?rev=163871&r1=163870&r2=163871&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp Thu Sep 13 23:20:37 2012
@@ -304,3 +304,19 @@
   };
   B b {}; // calls default constructor
 }
+
+
+// <rdar://problem/11974632>
+namespace rdar11974632 {
+  struct X {
+    X(const X&) = delete;
+    X(int);
+  };
+
+  template<typename T>
+  struct Y { 
+    X x{1};
+  };
+
+  Y<int> yi;
+}





More information about the cfe-commits mailing list