CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
49 lines
2.4 KiB
C++
49 lines
2.4 KiB
C++
// RUN: %clang_cc1 -verify -Wclass-varargs -std=c++98 %s
|
|
// RUN: %clang_cc1 -verify -Wclass-varargs -std=c++11 %s
|
|
|
|
struct A {};
|
|
struct B { ~B(); };
|
|
class C { char *c_str(); };
|
|
struct D { char *c_str(); };
|
|
struct E { E(); };
|
|
struct F { F(); char *c_str(); };
|
|
|
|
void v(...);
|
|
void w(const char*, ...) __attribute__((format(printf, 1, 2)));
|
|
|
|
void test(A a, B b, C c, D d, E e, F f) {
|
|
v(a); // expected-warning-re {{passing object of class type 'A' through variadic function{{$}}}}
|
|
v(b); // expected-error-re {{cannot pass object of non-{{POD|trivial}} type 'B' through variadic function; call will abort at runtime}}
|
|
v(c); // expected-warning {{passing object of class type 'C' through variadic function; did you mean to call '.c_str()'?}}
|
|
v(d); // expected-warning {{passing object of class type 'D' through variadic function; did you mean to call '.c_str()'?}}
|
|
v(e);
|
|
v(f);
|
|
#if __cplusplus < 201103L
|
|
// expected-error@-3 {{cannot pass object of non-POD type 'E' through variadic function; call will abort at runtime}}
|
|
// expected-error@-3 {{cannot pass object of non-POD type 'F' through variadic function; call will abort at runtime}}
|
|
#else
|
|
// expected-warning-re@-6 {{passing object of class type 'E' through variadic function{{$}}}}
|
|
// expected-warning@-6 {{passing object of class type 'F' through variadic function; did you mean to call '.c_str()'?}}
|
|
#endif
|
|
|
|
v(d.c_str());
|
|
v(f.c_str());
|
|
v(0);
|
|
v('x');
|
|
|
|
w("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'A'}}
|
|
w("%s", b); // expected-error-re {{cannot pass non-{{POD|trivial}} object of type 'B' to variadic function; expected type from format string was 'char *'}}
|
|
w("%s", c); // expected-warning {{format specifies type 'char *' but the argument has type 'C'}}
|
|
w("%s", d); // expected-warning {{format specifies type 'char *' but the argument has type 'D'}}
|
|
w("%s", e);
|
|
w("%s", f);
|
|
#if __cplusplus < 201103L
|
|
// expected-error@-3 {{cannot pass non-POD object of type 'E' to variadic function; expected type from format string was 'char *'}}
|
|
// expected-error@-3 {{cannot pass non-POD object of type 'F' to variadic function; expected type from format string was 'char *'}}
|
|
// expected-note@-4 {{did you mean to call the c_str() method?}}
|
|
#else
|
|
// expected-warning@-7 {{format specifies type 'char *' but the argument has type 'E'}}
|
|
// expected-warning@-7 {{format specifies type 'char *' but the argument has type 'F'}}
|
|
#endif
|
|
}
|