Skip to content
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

Requires expressions are not allowed to be used as bool expressions #58107

Open
steve02081504 opened this issue Oct 2, 2022 · 3 comments
Open
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@steve02081504
Copy link

demo code: https://godbolt.org/z/6o6K9GnnY

#define was_not_an_ill_form(...) (bool(requires { __VA_ARGS__; }))
template<class T>
T declval();

struct A {};
template<class T>
constexpr bool is_func = was_not_an_ill_form(declval<T>()());

int	main() {
	static_assert(!is_func<A>);
}

work in gcc: https://godbolt.org/z/ddEYahYox

@shafik
Copy link
Collaborator

shafik commented Oct 2, 2022

Removing the outer parens makes it well-formed in both clang and gcc but not sure if this should be valid with the parens or not: https://godbolt.org/z/rshn8zaEd

CC @erichkeane this diagnostic (err_requires_clause_inside_parens) comes from code you were looking at recently

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Oct 2, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 2, 2022

@llvm/issue-subscribers-clang-frontend

@erichkeane
Copy link
Collaborator

Hmm, that looks like a parse error, I don't see why that would be considered a trailing requires clause. I haven't looked into the parsing code in a while, but I'll put this on my list of things to look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

5 participants