Skip to content
Snippets Groups Projects
Commit b476a14e authored by Richard Smith's avatar Richard Smith
Browse files

Factor out duplication between lvalue-to-rvalue conversions and variable

assignments in constant expressions. No significant functionality changes
(slight improvement to potential constant expression checking). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181170 91177308-0d34-0410-b5e6-96231b3b80d8
parent 62ed8892
No related branches found
No related tags found
Loading
This diff is collapsed.
......@@ -274,11 +274,13 @@ namespace std_example {
int a; // expected-error {{must be initialized}}
return a;
}
// FIXME: Once we support variable mutation, this can produce a
// constant expression.
constexpr int prev(int x) { // expected-error {{never produces a constant expression}}
return --x; // expected-note {{subexpression}}
constexpr int prev(int x) {
return --x;
}
#if 1 // FIXME: !defined CXX1Y
// expected-error@-4 {{never produces a constant expression}}
// expected-note@-4 {{subexpression}}
#endif
constexpr int g(int x, int n) {
int r = 1;
while (--n > 0) r *= x;
......
......@@ -232,6 +232,11 @@ namespace potential_const_expr {
int z = 0;
return 100 / (set(z), 0); // expected-note {{division by zero}}
}
int n; // expected-note {{declared here}}
constexpr int ref() { // expected-error {{never produces a constant expression}}
int &r = n;
return r; // expected-note {{read of non-const variable 'n'}}
}
}
namespace subobject {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment