Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11096,6 +11096,15 @@ } Init = Res.get(); + if (!Init->getType().isNull()) + if (auto *placeholderType = Init->getType()->getAsPlaceholderType()) + if (placeholderType->getKind() == BuiltinType::PseudoObject) { + Res = CheckPlaceholderExpr(Init).get(); + if (!Res.isUsable()) + return; + Init = Res.get(); + } + if (DeduceVariableDeclarationType(VDecl, DirectInit, Init)) return; } Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -6623,6 +6623,15 @@ ExprResult Sema::ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val) { + for (size_t I = 0, E = Val.size(); I != E; ++I) + if (auto *PlaceholderType = Val[I]->getType()->getAsPlaceholderType()) + if (PlaceholderType->getKind() == BuiltinType::PseudoObject) { + ExprResult Result = CheckPlaceholderExpr(Val[I]); + if (!Result.isUsable()) + return ExprError(); + Val[I] = Result.get(); + } + return ParenListExpr::Create(Context, L, Val, R); } Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -1826,6 +1826,15 @@ NumInits = List->getNumExprs(); } + for (unsigned I = 0, E = NumInits; I != E; ++I) + if (auto *PlaceholderType = Inits[I]->getType()->getAsPlaceholderType()) + if (PlaceholderType->getKind() == BuiltinType::PseudoObject) { + ExprResult Result = CheckPlaceholderExpr(Inits[I]); + if (!Result.isUsable()) + return ExprError(); + Inits[I] = Result.get(); + } + // C++11 [expr.new]p15: // A new-expression that creates an object of type T initializes that // object as follows: Index: test/SemaObjC/arc-repeated-weak.mm =================================================================== --- test/SemaObjC/arc-repeated-weak.mm +++ test/SemaObjC/arc-repeated-weak.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s -// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s @interface Test { @public @@ -467,6 +467,18 @@ __typeof__(NSBundle2.foo2.weakProp) t5; } +void testAuto() { + auto __weak wp = NSBundle2.foo2.weakProp; +} + +void testLambdaCaptureInit() { + [capture(NSBundle2.foo2.weakProp)] {} (); +} + +void testAutoNew() { + auto p = new auto(NSBundle2.foo2.weakProp); +} + // This used to crash in the constructor of WeakObjectProfileTy when a // DeclRefExpr was passed that didn't reference a VarDecl.