xref: /llvm-project/clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
2 
3 struct Length {
LengthLength4   Length(double v) {
5     m_floatValue = static_cast<float>(v);
6   }
7 
operator ==Length8   bool operator==(const Length& o) const {
9     return getFloatValue() == o.getFloatValue();
10   }
operator !=Length11   bool operator!=(const Length& o) const { return !(*this == o); }
12 private:
getFloatValueLength13   float getFloatValue() const {
14     return m_floatValue;
15   }
16   float m_floatValue;
17 };
18 
19 
20 struct Foo {
21   static Length inchLength(double inch);
getPageSizeFromNameFoo22   static bool getPageSizeFromName(const Length &A) {
23     static const Length legalWidth = inchLength(8.5);
24     if (A != legalWidth) return true;
25     return false;
26   }
27 };
28 
29 // CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4
30 // CHECK: store float %{{.*}}, ptr @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, align 4
31 
bar(Length & b)32 bool bar(Length &b) {
33   Foo f;
34   return f.getPageSizeFromName(b);
35 }
36