llvm-project
31 строка · 1.5 Кб
1// RUN: %clang_cc1 -verify=c2x -std=c2x %s
2// RUN: %clang_cc1 -verify=c11 -std=c11 %s
3// RUN: %clang_cc1 -verify=gnu11 -std=gnu11 %s
4// RUN: %clang_cc1 -verify=pedantic -pedantic -std=gnu11 -Wno-comment %s
5// RUN: %clang_cc1 -verify=compat -std=c2x -Wpre-c2x-compat %s
6
7// c2x-no-diagnostics
8
9// Exercise the various circumstances under which we will diagnose use of
10// typeof and typeof_unqual as either an extension or as a compatability
11// warning. Note that GCC exposes 'typeof' as a non-conforming extension in
12// standards before C23, and Clang has followed suit. Neither compiler exposes
13// 'typeof_unqual' as a non-conforming extension.
14
15// Show what happens with the underscored version of the keywords, which are
16// conforming extensions.
17__typeof__(int) i = 12;
18__typeof(int) _i = 12;
19__typeof_unqual__(int) u = 12;
20__typeof_unqual(int) _u = 12;
21
22// Show what happens with a regular 'typeof' use.
23typeof(i) j = 12; // c11-error {{expected function body after function declarator}} \
24pedantic-warning {{extension used}} \
25compat-warning {{'typeof' is incompatible with C standards before C23}}
26
27// Same for 'typeof_unqual'.
28typeof_unqual(j) k = 12; // c11-error {{expected function body after function declarator}} \
29gnu11-error {{expected function body after function declarator}} \
30pedantic-error {{expected function body after function declarator}} \
31compat-warning {{'typeof_unqual' is incompatible with C standards before C23}}
32
33