aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-05-05 21:17:10 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-05-05 21:17:10 +0000
commitb476a14e9b35ef2448b42b033e1f0cceaa3f2778 (patch)
tree0a6004bb4d1ab08ea9f63f829ed3c4f25f37e70c /test
parent62ed889272d7e9da8e367d8682fdcdeeec0d83b5 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp10
-rw-r--r--test/SemaCXX/constant-expression-cxx1y.cpp5
2 files changed, 11 insertions, 4 deletions
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 9361642326..e12011d19c 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -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;
diff --git a/test/SemaCXX/constant-expression-cxx1y.cpp b/test/SemaCXX/constant-expression-cxx1y.cpp
index 543c7cffdb..62739ee8c1 100644
--- a/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -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 {