Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: add more tests for ret...



details:   https://anonhg.NetBSD.org/src/rev/8a47bfe78786
branches:  trunk
changeset: 374261:8a47bfe78786
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 15 12:47:32 2023 +0000

description:
tests/lint: add more tests for returning local objects

diffstat:

 tests/usr.bin/xlint/lint1/msg_302.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (24 lines):

diff -r f60fb37b64ea -r 8a47bfe78786 tests/usr.bin/xlint/lint1/msg_302.c
--- a/tests/usr.bin/xlint/lint1/msg_302.c       Sat Apr 15 12:39:44 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_302.c       Sat Apr 15 12:47:32 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_302.c,v 1.5 2023/04/15 10:53:59 rillig Exp $       */
+/*     $NetBSD: msg_302.c,v 1.6 2023/04/15 12:47:32 rillig Exp $       */
 # 3 "msg_302.c"
 
 // Test for message: '%s' returns pointer to automatic object [302]
@@ -42,6 +42,14 @@ return_local_array(int x)
        case 5:
                /* XXX: lint doesn't track this indirection, but Clang-tidy does. */
                return indirect;
+       case 6:
+               /* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+               return (local);
+       case 7:
+               /* C99 6.5.2.5p6 */
+               /* Neither GCC 10 nor Clang 15 warn about this case. */
+               /* expect+1: warning: 'return_local_array' returns pointer to automatic object [302] */
+               return (char[]){"local string"};
        default:
                return "OK";
        }



Home | Main Index | Thread Index | Old Index