[PATCH] D142500: Fix one of the regressions found in revert of concept sugaring
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 25 06:01:56 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG228462f755f0: Fix one of the regressions found in revert of concept sugaring (authored by erichkeane).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142500/new/
https://reviews.llvm.org/D142500
Files:
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaTemplate/sugar-crashes.cpp
Index: clang/test/SemaTemplate/sugar-crashes.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaTemplate/sugar-crashes.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify %s
+// expected-no-diagnostics
+
+
+struct StringPiece {
+ template <typename T,
+ typename = decltype(T())>
+ StringPiece(T str) {}
+};
+
+void f(StringPiece utf8) {}
+
+struct S {
+};
+
+void G() {
+ const auto s = S{};
+ StringPiece U{s};
+}
+
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1483,13 +1483,14 @@
// Otherwise, if the type contains a placeholder type, it is replaced by the
// type determined by placeholder type deduction.
DeducedType *Deduced = Ty->getContainedDeducedType();
- if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) {
+ if (Deduced && !Deduced->isDeduced() &&
+ isa<DeducedTemplateSpecializationType>(Deduced)) {
Ty = DeduceTemplateSpecializationFromInitializer(TInfo, Entity,
Kind, Exprs);
if (Ty.isNull())
return ExprError();
Entity = InitializedEntity::InitializeTemporary(TInfo, Ty);
- } else if (Deduced) {
+ } else if (Deduced && !Deduced->isDeduced()) {
MultiExprArg Inits = Exprs;
if (ListInitialization) {
auto *ILE = cast<InitListExpr>(Exprs[0]);
@@ -2016,7 +2017,8 @@
// C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for.
auto *Deduced = AllocType->getContainedDeducedType();
- if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) {
+ if (Deduced && !Deduced->isDeduced() &&
+ isa<DeducedTemplateSpecializationType>(Deduced)) {
if (ArraySize)
return ExprError(
Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(),
@@ -2030,7 +2032,7 @@
AllocTypeInfo, Entity, Kind, Exprs);
if (AllocType.isNull())
return ExprError();
- } else if (Deduced) {
+ } else if (Deduced && !Deduced->isDeduced()) {
MultiExprArg Inits = Exprs;
bool Braced = (initStyle == CXXNewExpr::ListInit);
if (Braced) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142500.492080.patch
Type: text/x-patch
Size: 2255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230125/c912d47d/attachment.bin>
More information about the cfe-commits
mailing list