brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 7a1f673 Raw
33 lines · c
1// RUN: %clang_cc1 -verify=c2x -std=c2x %s2// RUN: %clang_cc1 -verify=c11 -std=c11 %s3// RUN: %clang_cc1 -verify=gnu11 -std=gnu11 %s4// RUN: %clang_cc1 -verify=pedantic -pedantic -std=gnu11 -Wno-comment %s5// RUN: %clang_cc1 -verify=compat -std=c2x -Wpre-c2x-compat %s6 7// c2x-no-diagnostics8 9// Exercise the various circumstances under which we will diagnose use of10// typeof and typeof_unqual as either an extension or as a compatability11// warning. Note that GCC exposes 'typeof' as a non-conforming extension in12// standards before C23, and Clang has followed suit. Neither compiler exposes13// 'typeof_unqual' as a non-conforming extension.14 15// Show what happens with the underscored version of the keywords, which are16// 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}} \24                     pedantic-warning {{extension used}} \25                     compat-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}} \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