Files
TheRock/compiler/amd-llvm/clang/test/C/C23/n2927.c
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

97 lines
3.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// RUN: %clang_cc1 -verify -std=c2x %s
/* WG14 N2927: yes
* Not-so-magic: typeof
*/
// These examples originated in WG14 N2927 but were modified to test particular
// compiler behaviors. Each of these examples come from C2x 6.7.2.5.
// EXAMPLE 1
typeof(1 + 1) func();
int func();
// EXAMPLE 2
const _Atomic int purr = 0;
const int meow = 1;
const char *const mew[] = {
"aardvark",
"bluejay",
"catte",
};
extern typeof_unqual(purr) plain_purr;
extern int plain_purr;
extern typeof(_Atomic typeof(meow)) atomic_meow;
extern const _Atomic int atomic_meow;
extern typeof(mew) mew_array;
extern const char *const mew_array[3];
extern typeof_unqual(mew) mew2_array;
extern const char *mew2_array[3];
// EXAMPLE 3
void foo(int argc, char *argv[]) { // expected-note 2 {{declared here}}
_Static_assert(sizeof(typeof('p')) == sizeof(int));
_Static_assert(sizeof(typeof('p')) == sizeof('p'));
_Static_assert(sizeof(typeof((char)'p')) == sizeof(char));
_Static_assert(sizeof(typeof((char)'p')) == sizeof((char)'p'));
_Static_assert(sizeof(typeof("meow")) == sizeof(char[5]));
_Static_assert(sizeof(typeof("meow")) == sizeof("meow"));
_Static_assert(sizeof(typeof(argc)) == sizeof(int));
_Static_assert(sizeof(typeof(argc)) == sizeof(argc));
_Static_assert(sizeof(typeof(argv)) == sizeof(char**));
_Static_assert(sizeof(typeof(argv)) == sizeof(argv)); // expected-warning {{sizeof on array function parameter will return size of 'char **' instead of 'char *[]'}}
_Static_assert(sizeof(typeof_unqual('p')) == sizeof(int));
_Static_assert(sizeof(typeof_unqual('p')) == sizeof('p'));
_Static_assert(sizeof(typeof_unqual((char)'p')) == sizeof(char));
_Static_assert(sizeof(typeof_unqual((char)'p')) == sizeof((char)'p'));
_Static_assert(sizeof(typeof_unqual("meow")) == sizeof(char[5]));
_Static_assert(sizeof(typeof_unqual("meow")) == sizeof("meow"));
_Static_assert(sizeof(typeof_unqual(argc)) == sizeof(int));
_Static_assert(sizeof(typeof_unqual(argc)) == sizeof(argc));
_Static_assert(sizeof(typeof_unqual(argv)) == sizeof(char**));
_Static_assert(sizeof(typeof_unqual(argv)) == sizeof(argv)); // expected-warning {{sizeof on array function parameter will return size of 'char **' instead of 'char *[]'}}
}
// EXAMPLE 4
void bar(int argc) {
extern int val;
extern typeof(typeof_unqual(typeof(argc)))val;
}
// EXAMPLE 5 is tested by n2927_2.c because it is a codegen test.
// EXAMPLE 6
extern const char *y[4];
extern typeof(typeof(const char*)[4]) y;
// EXAMPLE 7
void f(int);
void g(double);
typeof(f(5)) g(double x); // g has type "void(double)"
extern void (*h)(double);
extern typeof(g)* h; // h has type "void(*)(double)"
extern typeof(true ? g : 0) h; // h has type "void(*)(double)"
void j(double *, double **);
void j(double A[5], typeof(A)* B); // j has type "void(double*, double**)"
extern typeof(double[]) D; // D has an incomplete type
extern double C[2];
extern typeof(D) C; // C has type "double[2]"
typeof(D) D = { 5, 8.9, 0.1, 99 }; // D is now completed to "double[4]"
extern double E[4];
extern typeof(D) E; // E has type "double[4]" from D’s completed type
// GH64713 -- this used to trigger an infinite loop when creating the function
// declaration for F from the function designator specified by typeof.
typeof(int(int)) F; // F has type "int(int)"