Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Sema/SemaStmt.cpp | ||
---|---|---|
353 ↗ | (On Diff #284621) | This seems like a very specific patch to a special case of a potentially more general problem... |
clang/test/SemaCXX/recovery-expr-type.cpp | ||
88 | (nit: I think this is -Wunused but not -Wunused-variable) | |
88 | what makes you think this is firing on the *inner* expression? The diagnostic location is that of the outer expression. I think the existing logic is pretty close to correct (and the diagnostic is actually correct here, albeit through luck), and if we want to change it, the right fix belongs somewhere else. The warning doesn't fire for just Derived(); - isUnusedResultAWarning returns false for RecoveryExpr. Nor does it fire for (Derived()); - isUnusedResultAWarning looks inside the paren expr and gets the same result for the contents. For the case in this test, we hit the CXXFunctionalCastExpr/CStyleExprCast case of isUnusedResultAWarning. It says:
But this is a bit misleading: given Foo(2+2) the "operand" isn't 2+2, but rather a CXXConstructExpr. And isUnusedResultAWarning returns true for this case (usually). Back to the case at hand: we diverge because the cast type is Dependent instead of ConstructorConversion. |
address review comment:
a dependent-kind cast expr should not be warned about the unused result.
clang/test/SemaCXX/recovery-expr-type.cpp | ||
---|---|---|
88 | oh, my bad. I misunderstood this part of code -- I missed the critical function isUnusedResultAWarning, I saw it when reading this part of code, but I skipped it because the function name made me think "this is a trivial function that just detects whether the -Wunused flag is on". I think you analysis is right here. Thanks!
hmm, I was confused by the ~annotation of the diagnostic. (Derived(Derived())); ^ ~~~~~~~ |
clang/test/SemaCXX/recovery-expr-type.cpp | ||
---|---|---|
80 | nit: can the testcase be simplified? |
nit: can the testcase be simplified?
Isn't struct T { T() = delete; }; enough (with no inheritance)