xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
2*f4a2713aSLionel Sambuc // <rdar://problem/11043589>
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc struct Length {
LengthLength5*f4a2713aSLionel Sambuc   Length(double v) {
6*f4a2713aSLionel Sambuc     m_floatValue = static_cast<float>(v);
7*f4a2713aSLionel Sambuc   }
8*f4a2713aSLionel Sambuc 
operator ==Length9*f4a2713aSLionel Sambuc   bool operator==(const Length& o) const {
10*f4a2713aSLionel Sambuc     return getFloatValue() == o.getFloatValue();
11*f4a2713aSLionel Sambuc   }
operator !=Length12*f4a2713aSLionel Sambuc   bool operator!=(const Length& o) const { return !(*this == o); }
13*f4a2713aSLionel Sambuc private:
getFloatValueLength14*f4a2713aSLionel Sambuc   float getFloatValue() const {
15*f4a2713aSLionel Sambuc     return m_floatValue;
16*f4a2713aSLionel Sambuc   }
17*f4a2713aSLionel Sambuc   float m_floatValue;
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc struct Foo {
22*f4a2713aSLionel Sambuc   static Length inchLength(double inch);
getPageSizeFromNameFoo23*f4a2713aSLionel Sambuc   static bool getPageSizeFromName(const Length &A) {
24*f4a2713aSLionel Sambuc     static const Length legalWidth = inchLength(8.5);
25*f4a2713aSLionel Sambuc     if (A != legalWidth) return true;
26*f4a2713aSLionel Sambuc     return false;
27*f4a2713aSLionel Sambuc   }
28*f4a2713aSLionel Sambuc };
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4
31*f4a2713aSLionel Sambuc // CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 1
32*f4a2713aSLionel Sambuc 
bar(Length & b)33*f4a2713aSLionel Sambuc bool bar(Length &b) {
34*f4a2713aSLionel Sambuc   Foo f;
35*f4a2713aSLionel Sambuc   return f.getPageSizeFromName(b);
36*f4a2713aSLionel Sambuc }
37