Skip to content

Commit

Permalink
Add tests for #66562
Browse files Browse the repository at this point in the history
Fixes #66562
  • Loading branch information
cor3ntin committed Sep 16, 2023
1 parent 12e04c8 commit 0ed8935
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions clang/test/SemaCXX/cxx2a-consteval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ consteval int f1(int i) {
return i;
}

consteval constexpr int f2(int i) {
consteval constexpr int f2(int i) {
//expected-error@-1 {{cannot combine}}
return i;
}
Expand Down Expand Up @@ -195,7 +195,7 @@ auto ptr = ret1(0);
struct A {
consteval int f(int) {
// expected-note@-1+ {{declared here}}
return 0;
return 0;
}
};

Expand Down Expand Up @@ -239,7 +239,7 @@ constexpr int f_c(int i) {
int t = f(i);
// expected-error@-1 {{is not a constant expression}}
// expected-note@-2 {{function parameter}}
return f(0);
return f(0);
}

consteval int f_eval(int i) {
Expand Down Expand Up @@ -675,7 +675,7 @@ Bar<derp> a; // expected-note {{in instantiation of member function 'issue_55601

struct constantDerp {
// Can be used in a constant expression.
consteval constantDerp(int) {}
consteval constantDerp(int) {}
consteval operator int() const { return 5; }
};
Bar<constantDerp> b;
Expand Down Expand Up @@ -1162,3 +1162,17 @@ struct C {
};

}

namespace GH66562 {

namespace ns
{
consteval int foo(int x) { return 1; } // expected-note {{declared here}}
}

template <class A>
struct T {
static constexpr auto xx = ns::foo(A{}); // expected-error {{cannot take address of consteval function 'foo' outside of an immediate invocation}}
};

}

0 comments on commit 0ed8935

Please sign in to comment.