Implement #error statement in preprocessor.
This commit is contained in:
parent
7a7bfd4529
commit
7de9e684a6
42
cc_macro.c
42
cc_macro.c
|
@ -420,6 +420,44 @@ void handle_define()
|
|||
|
||||
}
|
||||
|
||||
void handle_error()
|
||||
{
|
||||
/* don't use #error statements from non-included blocks */
|
||||
int conditional_error = TRUE;
|
||||
if(NULL != conditional_inclusion_top)
|
||||
{
|
||||
if(FALSE == conditional_inclusion_top->include)
|
||||
{
|
||||
conditional_error = FALSE;
|
||||
}
|
||||
}
|
||||
eat_current_token();
|
||||
/* provided it isn't in a non-included block */
|
||||
if(conditional_error)
|
||||
{
|
||||
line_error_token(macro_token);
|
||||
fputs(" error: #error ", stderr);
|
||||
while (TRUE)
|
||||
{
|
||||
if ('\n' == macro_token->s[0]) break;
|
||||
fputs(macro_token->s, stderr);
|
||||
macro_token = macro_token->next;
|
||||
fputs(" ", stderr);
|
||||
}
|
||||
fputs("\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (TRUE)
|
||||
{
|
||||
/* discard the error */
|
||||
if ('\n' == macro_token->s[0])
|
||||
{
|
||||
return;
|
||||
}
|
||||
eat_current_token();
|
||||
}
|
||||
}
|
||||
|
||||
void macro_directive()
|
||||
{
|
||||
struct conditional_inclusion *t;
|
||||
|
@ -532,6 +570,10 @@ void macro_directive()
|
|||
{
|
||||
handle_define();
|
||||
}
|
||||
else if(match("#error", macro_token->s))
|
||||
{
|
||||
handle_error();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!match("#include", macro_token->s))
|
||||
|
|
|
@ -212,9 +212,9 @@ eb1f6aab09a1a4966f9f49a518d8aa03ca97aa7c46e443871d758a306671a85e test/results/t
|
|||
a2cbfd5f76d3be8049c6737e3fa02f191caf29b6885db006fa23f86e6eacc186 test/results/test0106-knight-posix-binary
|
||||
d75e450e2fcdf19df63f9d6a3fe5e032933e57b33f6f06b39a8ed2f3dc759f17 test/results/test0106-riscv64-binary
|
||||
473cc504d6cba9eaf648abcf15c83a317ff3f4a7f08f5e8936e3b35b2cc4fbc6 test/results/test0106-x86-binary
|
||||
4788501ea76eb118df6f7283b10c17208eb1dccfe815c9cdd7fd507401d68890 test/results/test1000-aarch64-binary
|
||||
9a5d03495ea6280a3a062bce4d67401d2cbece26027c6b5de5cf44e1423d6774 test/results/test1000-amd64-binary
|
||||
e44aea1acca281ae79bad7e53220af38c34b0f3773a4aaa3a63fcd7532d76b20 test/results/test1000-armv7l-binary
|
||||
9e00a11729f5e300f75d89c8a05b04f1ce69269a8ca9990aa505a18b59751314 test/results/test1000-knight-posix-binary
|
||||
e4239c5b8b712522004f2f85f9c84d300cbd8752a24a03a521c8b55a6f2bfd0b test/results/test1000-riscv64-binary
|
||||
44e7fe235a083c26c3a51b8e98c95fb6feacb64e3d23a6b213a1320013f998df test/results/test1000-x86-binary
|
||||
297a5c3bc4954277ed4d76abc9fa992f8915a3d563a413a7e5a9e99a1eadd342 test/results/test1000-aarch64-binary
|
||||
12fdd86a4700c86286143ffce86f4ebfcda8f503c67d3dffcc3e456529331e75 test/results/test1000-amd64-binary
|
||||
8b232893d1527ecd0c025e3901a58759593722711529a4ef683a021bb8d307c5 test/results/test1000-armv7l-binary
|
||||
88ffc3bbda28dca344ad79a13b2207db966a60b8d8143844f54bac4943bfe4eb test/results/test1000-knight-posix-binary
|
||||
8c600229104e32e1158bf8eafa6aa23cc7d43e6f162124915499fab8e1f3f7b5 test/results/test1000-riscv64-binary
|
||||
8845773d2b25015808748a39c275442313230d4f8986116e80b071e3550583db test/results/test1000-x86-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
6f9f414baebe52c30f700a50876d04aeeabccaa17f6d1f95799501dc58017938 test/test1000/proof
|
||||
f23cb1ecd1ba2e695c3624a8f6ee9fd723247055169c9e50acdc67652a0c2c47 test/test1000/proof
|
||||
|
|
Loading…
Reference in New Issue