[PATCH] D115228: [Clang] Do not check if we are in a discared context in non-immediate contexts
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 7 02:27:55 PST 2021
cor3ntin updated this revision to Diff 392319.
cor3ntin added a comment.
clang-format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115228/new/
https://reviews.llvm.org/D115228
Files:
clang/include/clang/Sema/Sema.h
clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
Index: clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
===================================================================
--- clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
+++ clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
@@ -159,4 +159,19 @@
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
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1324,12 +1324,15 @@
bool isImmediateFunctionContext() const {
return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
- InImmediateFunctionContext;
+ (Context == ExpressionEvaluationContext::DiscardedStatement &&
+ InImmediateFunctionContext);
}
bool isDiscardedStatementContext() const {
return Context == ExpressionEvaluationContext::DiscardedStatement ||
- InDiscardedStatement;
+ (Context ==
+ ExpressionEvaluationContext::ImmediateFunctionContext &&
+ InDiscardedStatement);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115228.392319.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211207/e0cdebb7/attachment.bin>
More information about the cfe-commits
mailing list