Author: Haojian Wu
Date: 2020-08-21T15:48:59+02:00
New Revision: 466590192b4202ceb294eb82f881193d013dc90c

URL: 
https://github.com/llvm/llvm-project/commit/466590192b4202ceb294eb82f881193d013dc90c
DIFF: 
https://github.com/llvm/llvm-project/commit/466590192b4202ceb294eb82f881193d013dc90c.diff

LOG: [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is 
preserved.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D85716

Added: 
    

Modified: 
    clang/lib/AST/Expr.cpp
    clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e3e5e9dbdc62..8efd6837c541 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -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 =

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
index 2ce47f2f8efc..7fad61e53df8 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -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}}
+}
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to