blob: a6375f824a671b213d918c05fea0968719d3e5e7 [file] [log] [blame]
Bill Wendling08212632012-03-16 21:45:12 +00001// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
2// <rdar://problem/11043589>
3
4struct Length {
5 Length(double v) {
6 m_floatValue = static_cast<float>(v);
7 }
8
9 bool operator==(const Length& o) const {
10 return getFloatValue() == o.getFloatValue();
11 }
12 bool operator!=(const Length& o) const { return !(*this == o); }
13private:
14 float getFloatValue() const {
15 return m_floatValue;
16 }
17 float m_floatValue;
18};
19
20
21struct Foo {
22 static Length inchLength(double inch);
23 static bool getPageSizeFromName(const Length &A) {
24 static const Length legalWidth = inchLength(8.5);
25 if (A != legalWidth) return true;
26 return false;
27 }
28};
29
30// CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4
Bill Wendling2eb27292012-03-16 23:37:23 +000031// CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 1
Bill Wendling08212632012-03-16 21:45:12 +000032
33bool bar(Length &b) {
34 Foo f;
35 return f.getPageSizeFromName(b);
36}