-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang]Avoid diagnose invalid consteval call for invalid function decl (
- Loading branch information
1 parent
aa5158c
commit 19d1da5
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s | ||
|
||
struct S { | ||
int e; | ||
}; | ||
|
||
template<class T> | ||
consteval int get_format() { | ||
return nullptr; // expected-error{{cannot initialize return object of type 'int' with an rvalue of type 'std::nullptr_t'}} | ||
} | ||
|
||
template<class T> | ||
constexpr S f(T) noexcept { | ||
return get_format<T>(); // expected-error{{no viable conversion from returned value of type 'int' to function return type 'S'}} | ||
} | ||
|
||
constexpr S x = f(0); // expected-error{{constexpr variable 'x' must be initialized by a constant expression}} | ||
// expected-note@-1{{in instantiation of function template specialization 'f<int>' requested here}} | ||
// expected-note@3{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'S &&' for 1st argument}} | ||
// expected-note@3{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const S &' for 1st argument}} |