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. 23 typeof(i) j = 12; // c11-error {{expected function body after function declarator}} \ 24 pedantic-warning {{extension used}} \ 25 compat-warning {{'typeof' is incompatible with C standards before C23}} 26 27 // Same for 'typeof_unqual'. 28 typeof_unqual(j) k = 12; // c11-error {{expected function body after function declarator}} \ 29 gnu11-error {{expected function body after function declarator}} \ 30 pedantic-error {{expected function body after function declarator}} \ 31 compat-warning {{'typeof_unqual' is incompatible with C standards before C23}} 32 33