// XFAIL: *
// RUN: %amp_device -c -D__KALMAR_ACCELERATOR__=1 -S -emit-llvm %s -o -|%cppfilt|%FileCheck %s
// RUN: %amp_device -c -D__KALMAR_ACCELERATOR__=1 %s -o %t.device.o
// RUN: %gtest_amp %s %t.device.o -o %t && %t
#ifndef __KALMAR_ACCELERATOR__
#include <gtest/gtest.h>
#endif
class base{
 public:
  __attribute__((annotate("deserialize"))) /* For compiler */
  base(int a_,float b_) [[hc]] :a(a_), b(b_) {}
  int a;
  float b;
};
class baz {
 public:
#if 0 // This declaration is supposed to be generated
  __attribute__((annotate("deserialize"))) /* For compiler */
  baz(base&, int foo) [[hc]];
#endif
  void cho(void) [[hc]] {};

  base &B; // No reference type is considered amp-compatible
  int bar;
};

#ifdef __KALMAR_ACCELERATOR__
int kerker(void) [[cpu, hc]] {
  base b(1234, 0.0f);
  // Will pass if deserializer declaration and definition are generated
  baz bl(b, 1);
  return bl.B.a;
}
#else
extern int kerker(void) [[cpu, hc]];
TEST(GPUCodeGen, ConstructorWithRef) {
  EXPECT_EQ(kerker(), 1234);
}
#endif
// The definition should be generated by clang
// CHECK: define {{.*}}void @baz::baz(base&, int)(
