-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[clang][bytecode] Reject dependent RequiresExprs #155230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesFixes #152899 Full diff: https://github.com/llvm/llvm-project/pull/155230.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index e3235d34e230e..a98c0acb4f660 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3879,6 +3879,8 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitRequiresExpr(const RequiresExpr *E) {
assert(classifyPrim(E->getType()) == PT_Bool);
+ if (E->isValueDependent())
+ return false;
if (DiscardResult)
return true;
return this->emitConstBool(E->isSatisfied(), E);
diff --git a/clang/test/AST/ByteCode/cxx2a.cpp b/clang/test/AST/ByteCode/cxx2a.cpp
index 744c99eaa1e68..533173d84792f 100644
--- a/clang/test/AST/ByteCode/cxx2a.cpp
+++ b/clang/test/AST/ByteCode/cxx2a.cpp
@@ -239,3 +239,17 @@ namespace GH150705 {
constexpr const A& a = b;
constexpr auto x = (a.*q)(); // both-error {{constant expression}}
}
+
+namespace DependentRequiresExpr {
+ template <class T,
+ bool = []() -> bool { // both-error {{not a constant expression}}
+ if (requires { T::type; })
+ return true;
+ return false;
+ }()>
+ struct p {
+ using type = void;
+ };
+
+ template <class T> using P = p<T>::type; // both-note {{while checking a default template argument}}
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know which clause causes clang to choose to reject this, looks like we are the only one: https://godbolt.org/z/KhfeP5W6d
No clue. The |
CC @zygoloid is clang correct to reject the example in this code? |
I don't see why that would be invalid. When forming |
Looks like the problem is not a |
CC @cor3ntin |
Fixes #152899