| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! /bin/sh | | 1 | #! /bin/sh |
2 | # $NetBSD: t_errors.sh,v 1.22 2021/11/25 21:48:23 rillig Exp $ | | 2 | # $NetBSD: t_errors.sh,v 1.23 2022/02/13 11:07:48 rillig Exp $ |
3 | # | | 3 | # |
4 | # Copyright (c) 2021 The NetBSD Foundation, Inc. | | 4 | # Copyright (c) 2021 The NetBSD Foundation, Inc. |
5 | # All rights reserved. | | 5 | # All rights reserved. |
6 | # | | 6 | # |
7 | # Redistribution and use in source and binary forms, with or without | | 7 | # Redistribution and use in source and binary forms, with or without |
8 | # modification, are permitted provided that the following conditions | | 8 | # modification, are permitted provided that the following conditions |
9 | # are met: | | 9 | # are met: |
10 | # 1. Redistributions of source code must retain the above copyright | | 10 | # 1. Redistributions of source code must retain the above copyright |
11 | # notice, this list of conditions and the following disclaimer. | | 11 | # notice, this list of conditions and the following disclaimer. |
12 | # 2. Redistributions in binary form must reproduce the above copyright | | 12 | # 2. Redistributions in binary form must reproduce the above copyright |
13 | # notice, this list of conditions and the following disclaimer in the | | 13 | # notice, this list of conditions and the following disclaimer in the |
14 | # documentation and/or other materials provided with the distribution. | | 14 | # documentation and/or other materials provided with the distribution. |
15 | # | | 15 | # |
| @@ -485,26 +485,73 @@ f(void) | | | @@ -485,26 +485,73 @@ f(void) |
485 | { | | 485 | { |
486 | if (0) | | 486 | if (0) |
487 | /* | | 487 | /* |
488 | * 0123456789012345678901 | | 488 | * 0123456789012345678901 |
489 | */ ; | | 489 | */ ; |
490 | } | | 490 | } |
491 | EOF | | 491 | EOF |
492 | | | 492 | |
493 | atf_check -o 'file:expected.out' \ | | 493 | atf_check -o 'file:expected.out' \ |
494 | "$indent" -l34 code.c -st | | 494 | "$indent" -l34 code.c -st |
495 | } | | 495 | } |
496 | | | 496 | |
497 | | | 497 | |
| | | 498 | atf_test_case 'compound_literal' |
| | | 499 | compound_literal_body() |
| | | 500 | { |
| | | 501 | # Test handling of compound literals (C99 6.5.2.5), as well as casts. |
| | | 502 | |
| | | 503 | cat <<EOF > code.c |
| | | 504 | void |
| | | 505 | function(void) |
| | | 506 | { |
| | | 507 | origin = |
| | | 508 | ((int) |
| | | 509 | ((-1)* |
| | | 510 | (struct point){0,0} |
| | | 511 | ) |
| | | 512 | ); |
| | | 513 | } |
| | | 514 | EOF |
| | | 515 | |
| | | 516 | sed '/^#/d' <<EOF > expected.out |
| | | 517 | void |
| | | 518 | function(void) |
| | | 519 | { |
| | | 520 | origin = |
| | | 521 | ((int) |
| | | 522 | ((-1) * |
| | | 523 | (struct point){ |
| | | 524 | # FIXME: the '{' is part of the expression, not a separate block. |
| | | 525 | 0, 0 |
| | | 526 | # FIXME: the '}' is part of the expression, not a separate block. |
| | | 527 | } |
| | | 528 | # FIXME: the ')' must be aligned with the corresponding '('. |
| | | 529 | ) |
| | | 530 | ); |
| | | 531 | } |
| | | 532 | EOF |
| | | 533 | sed '/^#/d' <<EOF > expected.err |
| | | 534 | # FIXME: The parentheses _are_ balanced, the '}' does not end the block. |
| | | 535 | error: code.c:9: Unbalanced parentheses |
| | | 536 | warning: code.c:10: Extra ')' |
| | | 537 | # FIXME: There is no line 12 in the input file. |
| | | 538 | warning: code.c:12: Extra ')' |
| | | 539 | EOF |
| | | 540 | |
| | | 541 | atf_check -s 'exit:1' -o 'file:expected.out' -e 'file:expected.err' \ |
| | | 542 | "$indent" -nfc1 -ci12 code.c -st |
| | | 543 | } |
| | | 544 | |
498 | atf_init_test_cases() | | 545 | atf_init_test_cases() |
499 | { | | 546 | { |
500 | atf_add_test_case 'option_unknown' | | 547 | atf_add_test_case 'option_unknown' |
501 | atf_add_test_case 'option_bool_trailing_garbage' | | 548 | atf_add_test_case 'option_bool_trailing_garbage' |
502 | atf_add_test_case 'option_int_missing_argument' | | 549 | atf_add_test_case 'option_int_missing_argument' |
503 | atf_add_test_case 'option_profile_not_found' | | 550 | atf_add_test_case 'option_profile_not_found' |
504 | atf_add_test_case 'option_buffer_overflow' | | 551 | atf_add_test_case 'option_buffer_overflow' |
505 | atf_add_test_case 'option_typedefs_not_found' | | 552 | atf_add_test_case 'option_typedefs_not_found' |
506 | atf_add_test_case 'option_special_missing_param' | | 553 | atf_add_test_case 'option_special_missing_param' |
507 | atf_add_test_case 'option_tabsize_negative' | | 554 | atf_add_test_case 'option_tabsize_negative' |
508 | atf_add_test_case 'option_tabsize_zero' | | 555 | atf_add_test_case 'option_tabsize_zero' |
509 | atf_add_test_case 'option_tabsize_large' | | 556 | atf_add_test_case 'option_tabsize_large' |
510 | atf_add_test_case 'option_tabsize_very_large' | | 557 | atf_add_test_case 'option_tabsize_very_large' |
| @@ -522,14 +569,15 @@ atf_init_test_cases() | | | @@ -522,14 +569,15 @@ atf_init_test_cases() |
522 | atf_add_test_case 'argument_output_equals_input_file' | | 569 | atf_add_test_case 'argument_output_equals_input_file' |
523 | atf_add_test_case 'argument_output_enoent' | | 570 | atf_add_test_case 'argument_output_enoent' |
524 | atf_add_test_case 'argument_too_many' | | 571 | atf_add_test_case 'argument_too_many' |
525 | atf_add_test_case 'unexpected_end_of_file' | | 572 | atf_add_test_case 'unexpected_end_of_file' |
526 | atf_add_test_case 'unexpected_closing_brace_top_level' | | 573 | atf_add_test_case 'unexpected_closing_brace_top_level' |
527 | atf_add_test_case 'unexpected_closing_brace_decl' | | 574 | atf_add_test_case 'unexpected_closing_brace_decl' |
528 | atf_add_test_case 'preprocessing_overflow' | | 575 | atf_add_test_case 'preprocessing_overflow' |
529 | atf_add_test_case 'preprocessing_unrecognized' | | 576 | atf_add_test_case 'preprocessing_unrecognized' |
530 | atf_add_test_case 'unbalanced_parentheses_1' | | 577 | atf_add_test_case 'unbalanced_parentheses_1' |
531 | atf_add_test_case 'unbalanced_parentheses_2' | | 578 | atf_add_test_case 'unbalanced_parentheses_2' |
532 | atf_add_test_case 'unbalanced_parentheses_3' | | 579 | atf_add_test_case 'unbalanced_parentheses_3' |
533 | atf_add_test_case 'search_stmt_comment_segv' | | 580 | atf_add_test_case 'search_stmt_comment_segv' |
534 | atf_add_test_case 'search_stmt_fits_in_one_line' | | 581 | atf_add_test_case 'search_stmt_fits_in_one_line' |
| | | 582 | atf_add_test_case 'compound_literal' |
535 | } | | 583 | } |