37 lines · c
1// RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm -frandomize-layout-seed=1234567890abcdef < %s | FileCheck %s2// PR603493 4// Clang will add a forward declaration of "struct bar" and "enum qux" to the5// structures. This shouldn't prevent these structures from being randomized.6// So the 'f' element shouldn't be at the start of the structure anymore.7 8struct foo {9 struct bar *(*f)(void);10 struct bar *(*g)(void);11 struct bar *(*h)(void);12 struct bar *(*i)(void);13 struct bar *(*j)(void);14 struct bar *(*k)(void);15};16 17// CHECK-LABEL: define {{.*}}@t1(18// CHECK-NOT: getelementptr inbounds %struct.foo, ptr %3, i32 0, i32 019struct bar *t1(struct foo *z) {20 return z->f();21}22 23struct baz {24 enum qux *(*f)(void);25 enum qux *(*g)(void);26 enum qux *(*h)(void);27 enum qux *(*i)(void);28 enum qux *(*j)(void);29 enum qux *(*k)(void);30};31 32// CHECK-LABEL: define {{.*}}@t2(33// CHECK-NOT: getelementptr inbounds %struct.baz, ptr %3, i32 0, i32 034enum qux *t2(struct baz *z) {35 return z->f();36}37