Skip to content

Commit 069b294

Browse files
Erich Keanetru
authored andcommitted
Fix one of the regressions found in revert of concept sugaring
It seems that the sugaring patches had some pretty significant interdependencies, and at least one issue exists that requires part of the concept-sugaring patch. I don't believe this to have anything to do with the increased compile-times that were seen, so hopefully this will fix our problems without further regressions. See https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122 for discussion. Differential Revision: https://reviews.llvm.org/D142500 (cherry picked from commit 228462f)
1 parent c7f38c3 commit 069b294

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,13 +1483,14 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
14831483
// Otherwise, if the type contains a placeholder type, it is replaced by the
14841484
// type determined by placeholder type deduction.
14851485
DeducedType *Deduced = Ty->getContainedDeducedType();
1486-
if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) {
1486+
if (Deduced && !Deduced->isDeduced() &&
1487+
isa<DeducedTemplateSpecializationType>(Deduced)) {
14871488
Ty = DeduceTemplateSpecializationFromInitializer(TInfo, Entity,
14881489
Kind, Exprs);
14891490
if (Ty.isNull())
14901491
return ExprError();
14911492
Entity = InitializedEntity::InitializeTemporary(TInfo, Ty);
1492-
} else if (Deduced) {
1493+
} else if (Deduced && !Deduced->isDeduced()) {
14931494
MultiExprArg Inits = Exprs;
14941495
if (ListInitialization) {
14951496
auto *ILE = cast<InitListExpr>(Exprs[0]);
@@ -2016,7 +2017,8 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
20162017

20172018
// C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for.
20182019
auto *Deduced = AllocType->getContainedDeducedType();
2019-
if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) {
2020+
if (Deduced && !Deduced->isDeduced() &&
2021+
isa<DeducedTemplateSpecializationType>(Deduced)) {
20202022
if (ArraySize)
20212023
return ExprError(
20222024
Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(),
@@ -2030,7 +2032,7 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
20302032
AllocTypeInfo, Entity, Kind, Exprs);
20312033
if (AllocType.isNull())
20322034
return ExprError();
2033-
} else if (Deduced) {
2035+
} else if (Deduced && !Deduced->isDeduced()) {
20342036
MultiExprArg Inits = Exprs;
20352037
bool Braced = (initStyle == CXXNewExpr::ListInit);
20362038
if (Braced) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -verify %s
2+
// expected-no-diagnostics
3+
4+
5+
struct StringPiece {
6+
template <typename T,
7+
typename = decltype(T())>
8+
StringPiece(T str) {}
9+
};
10+
11+
void f(StringPiece utf8) {}
12+
13+
struct S {
14+
};
15+
16+
void G() {
17+
const auto s = S{};
18+
StringPiece U{s};
19+
}
20+

0 commit comments

Comments
 (0)