Skip to content

Commit

Permalink
[AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is pr…
Browse files Browse the repository at this point in the history
…eserved.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D85716
  • Loading branch information
hokein committed Aug 21, 2020
1 parent a4c3ed4 commit 4665901
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
// Otherwise, the result of the cast is unused.
if (CE->getCastKind() == CK_ConstructorConversion)
return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
if (CE->getCastKind() == CK_Dependent)
return false;

WarnE = this;
if (const CXXFunctionalCastExpr *CXXCE =
Expand Down
11 changes: 11 additions & 0 deletions clang/test/SemaCXX/recovery-expr-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,14 @@ namespace test5 {
template<typename...Ts> U<Ts...>& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
double &s1 = f(); // expected-error {{no matching function}}
}

namespace test6 {
struct T {
T() = delete; // expected-note {{has been explicitly marked deleted here}}
};

void func() {
// verify that no -Wunused-value diagnostic.
(T(T())); // expected-error {{call to deleted constructor}}
}
}

0 comments on commit 4665901

Please sign in to comment.