summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-10-20 01:38:33 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-10-20 01:38:33 +0000
commit5a1104bd3a6ebee8cec6199c704e2403b0eee2b9 (patch)
tree658427c4239d6abbf369803da6fec654c547bdb3 /clang/test
parent3017a06c8f2c8f2c33b16548754a38c1ba3bd300 (diff)
downloadbcm5719-llvm-5a1104bd3a6ebee8cec6199c704e2403b0eee2b9.tar.gz
bcm5719-llvm-5a1104bd3a6ebee8cec6199c704e2403b0eee2b9.zip
DR1472: A reference isn't odr-used if it has preceding initialization,
initialized by a reference constant expression. Our odr-use modeling still needs work here: we don't yet implement the 'set of potential results of an expression' DR. llvm-svn: 166361
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenCXX/const-init-cxx11.cpp6
-rw-r--r--clang/test/CodeGenCXX/for-range.cpp2
-rw-r--r--clang/test/CodeGenCXX/lambda-expressions.cpp9
-rw-r--r--clang/test/SemaCXX/lambda-expressions.cpp13
4 files changed, 19 insertions, 11 deletions
diff --git a/clang/test/CodeGenCXX/const-init-cxx11.cpp b/clang/test/CodeGenCXX/const-init-cxx11.cpp
index db1bb412606..833adba8bae 100644
--- a/clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -432,11 +432,7 @@ namespace InitFromConst {
// CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
consume<const S&>(s);
- // FIXME CHECK-NOT: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
- // There's no lvalue-to-rvalue conversion here, so 'r' is odr-used, and
- // we're permitted to emit a load of it. This seems likely to be a defect
- // in the standard. If we start emitting a direct reference to 's', update
- // this test.
+ // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
consume<const S&>(r);
// CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
diff --git a/clang/test/CodeGenCXX/for-range.cpp b/clang/test/CodeGenCXX/for-range.cpp
index 929e33ca968..926fe445a5b 100644
--- a/clang/test/CodeGenCXX/for-range.cpp
+++ b/clang/test/CodeGenCXX/for-range.cpp
@@ -40,7 +40,7 @@ void for_array() {
// CHECK-NOT: 5begin
// CHECK-NOT: 3end
// CHECK: getelementptr {{.*}}, i32 0
- // CHECK: getelementptr {{.*}}, i64 5
+ // CHECK: getelementptr {{.*}}, i64 1, i64 0
// CHECK: br label %[[COND:.*]]
// CHECK: [[COND]]:
diff --git a/clang/test/CodeGenCXX/lambda-expressions.cpp b/clang/test/CodeGenCXX/lambda-expressions.cpp
index e872cc494bc..cee4f172a00 100644
--- a/clang/test/CodeGenCXX/lambda-expressions.cpp
+++ b/clang/test/CodeGenCXX/lambda-expressions.cpp
@@ -71,6 +71,15 @@ void f() {
int (*fp)(int, int) = [](int x, int y){ return x + y; };
}
+static int k;
+int g() {
+ int &r = k;
+ // CHECK: define internal i32 @"_ZZ1gvENK3$_6clEv"(
+ // CHECK-NOT: }
+ // CHECK: load i32* @_ZL1k,
+ return [] { return r; } ();
+};
+
// CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii"
// CHECK: store i32
// CHECK-NEXT: store i32
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
index babe743c65d..0630aedf772 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -83,12 +83,15 @@ namespace ImplicitCapture {
const int h = a; // expected-note {{declared}}
[]() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
- // The exemption for variables which can appear in constant expressions
- // applies only to objects (and not to references).
- // FIXME: This might be a bug in the standard.
- static int i;
- constexpr int &ref_i = i; // expected-note {{declared}}
+ // References can appear in constant expressions if they are initialized by
+ // reference constant expressions.
+ int i;
+ int &ref_i = i; // expected-note {{declared}}
[] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+
+ static int j;
+ int &ref_j = j;
+ [] { return ref_j; }; // ok
}
}
OpenPOWER on IntegriCloud