Skip to content

Commit 4665901

Browse files
committed
[AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.
Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D85716
1 parent a4c3ed4 commit 4665901

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/AST/Expr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
26582658
// Otherwise, the result of the cast is unused.
26592659
if (CE->getCastKind() == CK_ConstructorConversion)
26602660
return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2661+
if (CE->getCastKind() == CK_Dependent)
2662+
return false;
26612663

26622664
WarnE = this;
26632665
if (const CXXFunctionalCastExpr *CXXCE =

clang/test/SemaCXX/recovery-expr-type.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,14 @@ namespace test5 {
7575
template<typename...Ts> U<Ts...>& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
7676
double &s1 = f(); // expected-error {{no matching function}}
7777
}
78+
79+
namespace test6 {
80+
struct T {
81+
T() = delete; // expected-note {{has been explicitly marked deleted here}}
82+
};
83+
84+
void func() {
85+
// verify that no -Wunused-value diagnostic.
86+
(T(T())); // expected-error {{call to deleted constructor}}
87+
}
88+
}

0 commit comments

Comments
 (0)