forked from OSchip/llvm-project
Do not check if we are in a discared context in non-immediate contexts
This fixes in a regression introduced by 6eeda06c1
.
When deducing the return type of nested function calls, only the
return type of the outermost expression should be ignored.
Instead of assuming all contextes nested in a discared statements
are themselves discarded, only assume that in immediate contexts.
Similarly, only consider contextes immediately in an immediate or
discarded statement as being themselves immediate.
This commit is contained in:
parent
9779972311
commit
2334314550
|
@ -1324,12 +1324,15 @@ public:
|
|||
|
||||
bool isImmediateFunctionContext() const {
|
||||
return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
|
||||
InImmediateFunctionContext;
|
||||
(Context == ExpressionEvaluationContext::DiscardedStatement &&
|
||||
InImmediateFunctionContext);
|
||||
}
|
||||
|
||||
bool isDiscardedStatementContext() const {
|
||||
return Context == ExpressionEvaluationContext::DiscardedStatement ||
|
||||
InDiscardedStatement;
|
||||
(Context ==
|
||||
ExpressionEvaluationContext::ImmediateFunctionContext &&
|
||||
InDiscardedStatement);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -159,4 +159,19 @@ a: if constexpr(sizeof(n) == 4) // expected-error {{redefinition}} expected-not
|
|||
surprise: {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace deduced_return_type_in_discareded_statement {
|
||||
|
||||
template <typename T>
|
||||
auto a(const T &t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
void f() {
|
||||
if constexpr (false) {
|
||||
a(a(0));
|
||||
}
|
||||
}
|
||||
} // namespace deduced_return_type_in_discareded_statement
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue