xref: /llvm-project/clang/test/CodeGenHIP/printf-aggregate.cpp (revision 01a6cd471f019cfeda057c3b1b6fc6213575217c)
1 // REQUIRES: amdgpu-registered-target
2 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -fcuda-is-device \
3 // RUN:    -verify -emit-llvm-only %s
4 
5 #define __device__ __attribute__((device))
6 extern "C" __device__ int printf(const char *format, ...);
7 
8 // Check that we don't crash when asked to printf a non-scalar arg.
9 struct Struct {
10   int x;
11   int y;
12 };
13 
PrintfNonScalar(const char * fmt)14 __device__ void PrintfNonScalar(const char *fmt) {
15   printf(fmt, 1);
16   // Ignore the warning about the %d not matching the struct argument
17   // expected-warning@+2 {{}}
18   // expected-error@+1 {{cannot compile this non-scalar arg to printf}}
19   printf("%d", Struct());
20 }
21