From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2477F3857B9E for ; Sat, 2 Jul 2022 23:38:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2477F3857B9E Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-vv_MEwFkNrOUBRydo57rgA-1; Sat, 02 Jul 2022 19:38:16 -0400 X-MC-Unique: vv_MEwFkNrOUBRydo57rgA-1 Received: by mail-qt1-f198.google.com with SMTP id f28-20020ac8015c000000b003183eca483bso3493366qtg.2 for ; Sat, 02 Jul 2022 16:38:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=2zswsakgDG0/MzGscvISr7hF4lclsjyO3xvxdXjDcms=; b=1q8HS45/TwBTQeTccwezcc+pJ90lxi8MBdn1e9V6m7cl2daSYad82HA1+u0cn5WQio cobRRerAetUeyIycX4bsDcTjGBCdtTZKn7aKf7kosN0dmXMXEq1FER/vOwu65c9TlGkP VVYiGaQww4nGf4S+/WQDeWI8LNBablWTqLV4ZVsJ7nb+iE7tJ5+HwOJQ9txKdLgE9MAV EcVf8VOGXEDqp2DVRhxCAPmqYOGQAI116+STCMe7ypx8qJjd8lW7tq6LYas92DgBwxhc kDbkNneS+7HPuodJ8+31dEGmhOGJEfIL5Am7QJut7wQbfdUnyD+8VAS0lO5E26Q//AUy 0PdA== X-Gm-Message-State: AJIora8mhqq7PaDTNyEeIjrUU6WD5KlQtfbBALM4330YZwAYEDUeOn5D uvOaRU9Zth9I9NgSup9wQekTjecwnApU3jH6A2XfSMXZF846HI6t3pMXIR7wiB60kGG95WyNbzh RyqEJ+2H8ov3ySkMWlwsaig== X-Received: by 2002:a05:620a:d83:b0:6a7:a68c:6118 with SMTP id q3-20020a05620a0d8300b006a7a68c6118mr15302166qkl.337.1656805095572; Sat, 02 Jul 2022 16:38:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVlNAsPRV0/Y/OuvtUUSucr5GetOHT0kjSIWJkPWPVMfJOv3Jjtu/mvkQO1OO1VvxO4EFbgg== X-Received: by 2002:a05:620a:d83:b0:6a7:a68c:6118 with SMTP id q3-20020a05620a0d8300b006a7a68c6118mr15302160qkl.337.1656805095131; Sat, 02 Jul 2022 16:38:15 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id t14-20020a05620a004e00b006a6d20386f6sm19335905qkt.42.2022.07.02.16.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jul 2022 16:38:14 -0700 (PDT) Message-ID: <8c3d7ec0d17128ca1fd9e18cb82ba6e773d6c378.camel@redhat.com> Subject: Re: [PATCH] analyzer: Use fixed-width types in allocation size tests From: David Malcolm To: Tim Lange , skpgkp2@gmail.com Cc: gcc-regression@gcc.gnu.org, gcc-patches@gcc.gnu.org Date: Sat, 02 Jul 2022 19:38:13 -0400 In-Reply-To: <20220702232011.51345-1-mail@tim-lange.me> References: <20220702211052.501C42864754@gskx-2.sc.intel.com> <20220702232011.51345-1-mail@tim-lange.me> User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-regression@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-regression mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jul 2022 23:38:21 -0000 On Sun, 2022-07-03 at 01:20 +0200, Tim Lange wrote: > Hi, > > thanks for the mail! Embarrassingly, I did not account for the > different > sizes types may have on different systems. I've switched all > testcases > to the fixed-width types of stdint.h. > > Does this patch need an approval? Arguably falls under the "obvious" rule. That said, the patch looks good to me, though given that the sizes are now fixed the \\d+ regexps could be made more precise, if you like; I think it's good either way. Dave > > - Tim > > The patch changes the types inside the tests for the allocation size > checker to fixed-width types of stdint.h to account for different > architectures with different type widths. > > 2022-07-03  Tim Lange  > > gcc/testsuite/ChangeLog: > >         * gcc.dg/analyzer/allocation-size-1.c: Use fixed-length > types. >         * gcc.dg/analyzer/allocation-size-2.c: Likewise. >         * gcc.dg/analyzer/allocation-size-3.c: Likewise. >         * gcc.dg/analyzer/allocation-size-4.c: Likewise. >         * gcc.dg/analyzer/allocation-size-5.c: Likewise. > > --- >  .../gcc.dg/analyzer/allocation-size-1.c       | 53 +++++++------- >  .../gcc.dg/analyzer/allocation-size-2.c       | 73 ++++++++++------- > -- >  .../gcc.dg/analyzer/allocation-size-3.c       | 19 ++--- >  .../gcc.dg/analyzer/allocation-size-4.c       | 13 ++-- >  .../gcc.dg/analyzer/allocation-size-5.c       | 23 +++--- >  5 files changed, 93 insertions(+), 88 deletions(-) > > diff --git a/gcc/testsuite/gcc.dg/analyzer/allocation-size-1.c > b/gcc/testsuite/gcc.dg/analyzer/allocation-size-1.c > index 4fc2bf75d6c..e6d021a128f 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/allocation-size-1.c > +++ b/gcc/testsuite/gcc.dg/analyzer/allocation-size-1.c > @@ -1,79 +1,80 @@ >  #include >  #include > +#include >   >  /* Tests with constant buffer sizes.  */ >   >  void test_1 (void) >  { > -  short *ptr = malloc (21 * sizeof (short)); > +  int16_t *ptr = malloc (21 * sizeof (int16_t)); >    free (ptr); >  } >   >  void test_2 (void) >  { > -  int *ptr = malloc (21 * sizeof (short)); /* { dg-line malloc2 } */ > +  int32_t *ptr = malloc (21 * sizeof (int16_t)); /* { dg-line > malloc2 } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc2 } > */ >    /* { dg-message "\\d+ bytes" "note" { target *-*-* } malloc2 } */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } malloc2 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc2 } */ >  } >   >  void test_3 (void) >  { > -  void *ptr = malloc (21 * sizeof (short)); > -  short *sptr = (short *)ptr; > +  void *ptr = malloc (21 * sizeof (int16_t)); > +  int16_t *sptr = (int16_t *)ptr; >    free (sptr); >  } >   >  void test_4 (void) >  { > -  void *ptr = malloc (21 * sizeof (short)); /* { dg-message "\\d+ > bytes" } */ > -  int *iptr = (int *)ptr; /* { dg-line assign4 } */ > +  void *ptr = malloc (21 * sizeof (int16_t)); /* { dg-message "\\d+ > bytes" } */ > +  int32_t *iptr = (int32_t *)ptr; /* { dg-line assign4 } */ >    free (iptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign4 } > */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } assign4 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign4 } */ >  } >   >  void test_5 (void) >  { > -  int user_input; > +  int32_t user_input; >    scanf("%i", &user_input); > -  int n; > +  int32_t n; >    if (user_input == 0) > -    n = 21 * sizeof (short); > +    n = 21 * sizeof (int16_t); >    else > -    n = 42 * sizeof (short); > +    n = 42 * sizeof (int16_t); >    void *ptr = malloc (n); > -  short *sptr = (short *)ptr; > +  int16_t *sptr = (int16_t *)ptr; >    free (sptr); >  } >   >  void test_6 (void) >  { > -  int user_input; > +  int32_t user_input; >    scanf("%i", &user_input); > -  int n; > +  int32_t n; >    if (user_input == 0) > -    n = 21 * sizeof (short); > +    n = 21 * sizeof (int16_t); >    else > -    n = 42 * sizeof (short); > +    n = 42 * sizeof (int16_t); >    void *ptr = malloc (n); /* { dg-message "" "note" } */ >                            /* ^^^ on widening_svalues no expr is > returned >                                   by get_representative_tree at the > moment.  */ > -  int *iptr = (int *)ptr; /* { dg-line assign6 } */ > +  int32_t *iptr = (int32_t *)ptr; /* { dg-line assign6 } */ >    free (iptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign6 } > */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } assign6 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign6 } */ >  } >   >  void test_7 (void) >  { > -  int user_input; > +  int32_t user_input; >    scanf("%i", &user_input); > -  int n; > +  int32_t n; >    if (user_input == 0) >      n = 1; >    else if (user_input == 2) > @@ -82,18 +83,18 @@ void test_7 (void) >      n = 7; >    /* n is an unknown_svalue at this point.  */ >    void *ptr = malloc (n); > -  int *iptr = (int *)ptr; > +  int32_t *iptr = (int32_t *)ptr; >    free (iptr); >  } >   > -void *create_buffer (int n) > +void *create_buffer (int32_t n) >  { >    return malloc(n); >  } >   >  void test_8 (void) >  { > -  int *buf = create_buffer(4 * sizeof (int)); > +  int32_t *buf = create_buffer(4 * sizeof (int)); >    free (buf); >  } >   > @@ -105,11 +106,11 @@ void test_9 (void) >       impl_region_model_context::warn. To ensure that the indentation >       in the diagnostic is right, the warning has to be emitted on an > EN >       that is after the return edge.  */ > -  int *buf = create_buffer(42); /* { dg-warning "" "" { xfail *-*-* > } } */ > +  int32_t *buf = create_buffer(42); /* { dg-warning "" "" { xfail *- > *-* } } */ >    free (buf); >  } >   > -void test_10 (int n) > +void test_10 (int32_t n) >  { >    char *ptr = malloc (7 * n); >    free (ptr); > diff --git a/gcc/testsuite/gcc.dg/analyzer/allocation-size-2.c > b/gcc/testsuite/gcc.dg/analyzer/allocation-size-2.c > index 37bbbac87c5..69ca07561a6 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/allocation-size-2.c > +++ b/gcc/testsuite/gcc.dg/analyzer/allocation-size-2.c > @@ -1,60 +1,61 @@ >  #include >  #include > +#include >   >  /* Tests with symbolic buffer sizes.  */ >   > -void test_1 (int n) > +void test_1 (int32_t n) >  { > -  short *ptr = malloc (n * sizeof (short)); > +  int16_t *ptr = malloc (n * sizeof (int16_t)); >    free (ptr); >  } >   > -void test_2 (int n) > +void test_2 (int32_t n) >  { > -  int *ptr = malloc (n * sizeof (short)); /* { dg-line malloc2 } */ > +  int32_t *ptr = malloc (n * sizeof (int16_t)); /* { dg-line malloc2 > } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc2 } > */ >    /* { dg-message "'\[a-z0-9\\*\\(\\)\\s\]*' bytes" "note" { target > *-*-* } malloc2 } */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } malloc2 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc2 } */ >  } >   > -void test_3 (int n) > +void test_3 (int32_t n) >  { > -  void *ptr = malloc (n * sizeof (short)); > -  short *sptr = (short *)ptr; > +  void *ptr = malloc (n * sizeof (int16_t)); > +  int16_t *sptr = (int16_t *)ptr; >    free (sptr); >  } >   > -void test_4 (int n) > +void test_4 (int32_t n) >  { > -  void *ptr = malloc (n * sizeof (short)); /* { dg-message "'\[a-z0- > 9\\*\\(\\)\\s\]*'" "note" } */ > -  int *iptr = (int *)ptr; /* { dg-line assign4 } */ > +  void *ptr = malloc (n * sizeof (int16_t)); /* { dg-message "'\[a- > z0-9\\*\\(\\)\\s\]*'" "note" } */ > +  int32_t *iptr = (int32_t *)ptr; /* { dg-line assign4 } */ >    free (iptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign4 } > */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } assign4 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign4 } */ >  } >   >  void test_5 (void) >  { > -  int user_input; > +  int32_t user_input; >    scanf("%i", &user_input); > -  int n; > +  int32_t n; >    if (user_input == 0) > -    n = 3 * user_input * sizeof (short); > +    n = 3 * user_input * sizeof (int16_t); >    else > -    n = 5 * user_input * sizeof (short); > +    n = 5 * user_input * sizeof (int16_t); >    void *ptr = malloc (n); > -  short *sptr = (short *)ptr; > +  int16_t *sptr = (int16_t *)ptr; >    free (sptr); >  } >   >  void test_6 (void) >  { > -  int user_input; > +  int32_t user_input; >    scanf("%i", &user_input); > -  int n; > +  int32_t n; >    if (user_input == 0) >      n = user_input; >    else if (user_input == 2) > @@ -63,22 +64,22 @@ void test_6 (void) >      n = user_input * 5; >    /* n is an unknown_svalue at this point.  */ >    void *ptr = malloc (n); > -  int *iptr = (int *)ptr; > +  int32_t *iptr = (int32_t *)ptr; >    free (iptr); >  } >   > -void *create_buffer(int n) > +void *create_buffer(int32_t n) >  { >    return malloc(n); >  } >   > -void test_7(int n) > +void test_7(int32_t n) >  { > -  int *buf = create_buffer(n * sizeof (int)); > +  int32_t *buf = create_buffer(n * sizeof (int32_t)); >    free (buf); >  } >   > -void test_8(int n) > +void test_8(int32_t n) >  { >    /* FIXME: At the moment, region_model::set_value (lhs, > ) >       is called at the src_node of the return edge. This edge has no > stmts > @@ -86,33 +87,33 @@ void test_8(int n) >       impl_region_model_context::warn. To ensure that the indentation >       in the diagnostic is right, the warning has to be emitted on an > EN >       that is after the return edge.  */ > -  int *buf = create_buffer(n * sizeof(short)); /* { dg-warning "" "" > { xfail *-*-* } } */ > +  int32_t *buf = create_buffer(n * sizeof(int16_t)); /* { dg-warning > "" "" { xfail *-*-* } } */ >    free (buf); >  } >   >  void test_9 (void) >  { > -  int n; > +  int32_t n; >    scanf("%i", &n); >    /* n is a conjured_svalue.  */ >    void *ptr = malloc (n); /* { dg-message "'n' bytes" "note" } */ > -  int *iptr = (int *)ptr; /* { dg-line assign9 } */ > +  int32_t *iptr = (int32_t *)ptr; /* { dg-line assign9 } */ >    free (iptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign9 } > */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } assign9 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign9 } */ >  } >   >  void test_11 (void) >  { > -  int n; > +  int32_t n; >    scanf("%i", &n); >    void *ptr = malloc (n); > -  if (n == sizeof (int)) > +  if (n == sizeof (int32_t)) >      { >        /* n is a conjured_svalue but guarded such that we >           know the value is a multiple of sizeof (*iptr).  */ > -      int *iptr = (int *)ptr; > +      int32_t *iptr = (int32_t *)ptr; >        free (iptr); >      } >    else > @@ -121,25 +122,25 @@ void test_11 (void) >   >  void test_12 (void) >  { > -  int n; > +  int32_t n; >    scanf("%i", &n); >    void *ptr = malloc (n); /* { dg-message "'n' bytes" } */ >    if (n == 5) >      { >        /* n is a conjured_svalue but guarded such that we >           know the value isn't a multiple of sizeof (*iptr).  */ > -      int *iptr = (int *)ptr; /* { dg-line assign12 } */ > +      int32_t *iptr = (int32_t *)ptr; /* { dg-line assign12 } */ >        free (iptr); >      } >    else >      free (ptr); >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign12 } > */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } assign12 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign12 } */ >  } >   >  void test_13 (void) >  { > -  int n; > +  int32_t n; >    scanf("%i", &n); >    void *ptr = malloc (n); >    if (n == n * n) > @@ -147,7 +148,7 @@ void test_13 (void) >        /* n is a conjured_svalue but guarded such that we don't have > an >           equivalence class for it. In such cases, we assume that the >           condition ensures that the value is okay.  */ > -      int *iptr = (int *)ptr; > +      int32_t *iptr = (int32_t *)ptr; >        free (iptr); >      } >    else > diff --git a/gcc/testsuite/gcc.dg/analyzer/allocation-size-3.c > b/gcc/testsuite/gcc.dg/analyzer/allocation-size-3.c > index fdc1c56b7ee..eb63fa75578 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/allocation-size-3.c > +++ b/gcc/testsuite/gcc.dg/analyzer/allocation-size-3.c > @@ -1,10 +1,11 @@ >  #include >  #include > +#include >   >  /* CWE-131 example 5 */ >  void test_1 (void) >  { > -  int *id_sequence = (int *) malloc (3); /* { dg-line malloc1 } */ > +  int32_t *id_sequence = (int32_t *) malloc (3); /* { dg-line > malloc1 } */ >    if (id_sequence == NULL) exit (1); >   >    id_sequence[0] = 13579; > @@ -15,31 +16,31 @@ void test_1 (void) >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc1 } > */ >    /* { dg-message "\\d+ bytes" "note" { target *-*-* } malloc1 } */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } malloc1 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc1 } */ >  } >   >  void test_2 (void) >  { > -  int *ptr = malloc (10 + sizeof(int)); /* { dg-line malloc2 } */ > +  int32_t *ptr = malloc (10 + sizeof(int32_t)); /* { dg-line malloc2 > } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc2 } > */ >    /* { dg-message "\\d+ bytes" "note" { target *-*-* } malloc2 } */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } malloc2 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc2 } */ >  } >   > -void test_3 (int n) > +void test_3 (int32_t n) >  { > -  int *ptr = malloc (n + sizeof (int)); /* { dg-line malloc3 } */ > +  int32_t *ptr = malloc (n + sizeof (int32_t)); /* { dg-line malloc3 > } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc3 } > */ >    /* { dg-message "'\[a-z0-9\\+\\(\\)\\s\]*' bytes" "note" { target > *-*-* } malloc3 } */ > -  /* { dg-message "'int \\*' here; 'sizeof \\(int\\)' is '\\d+'" > "note" { target *-*-* } malloc3 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc3 } */ >  } >   > -void test_4 (int n, int m) > +void test_4 (int32_t n, int32_t m) >  { > -  int *ptr = malloc ((n + m) * sizeof (int)); > +  int32_t *ptr = malloc ((n + m) * sizeof (int32_t)); >    free (ptr); >  } > diff --git a/gcc/testsuite/gcc.dg/analyzer/allocation-size-4.c > b/gcc/testsuite/gcc.dg/analyzer/allocation-size-4.c > index e475c1586a3..73cbcc5e509 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/allocation-size-4.c > +++ b/gcc/testsuite/gcc.dg/analyzer/allocation-size-4.c > @@ -1,18 +1,19 @@ >  #include > +#include >   >  /* Tests related to structs.  */ >   >  struct base { > -  int i; > +  int16_t i; >  }; >   >  struct sub { >    struct base b; > -  int j; > +  int16_t j; >  }; >   >  struct var_len { > -  int i; > +  int16_t i; >    char arr[]; >  }; >   > @@ -25,12 +26,12 @@ void test_1 (void) >   >  void test_2 (void) >  { > -  long *ptr = malloc (5 * sizeof (struct base));  /* { dg-line > malloc2 } */ > +  int32_t *ptr = malloc (5 * sizeof (struct base));  /* { dg-line > malloc2 } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc2 } > */ >    /* { dg-message "\\d+ bytes" "note" { target *-*-* } malloc2 } */ > -  /* { dg-message "'long (int)? \\*' here; 'sizeof \\(long > (int)?\\)' is '\\d+'" "note" { target *-*-* } malloc2 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } malloc2 } */ >  } >   >  void test_3 (void) > @@ -51,7 +52,7 @@ void test_5 (void) >  { >    /* For constant sizes, we warn if the buffer >       is too small to hold a single struct.  */ > -  struct base *ptr = malloc (2);  /* { dg-line malloc5 } */ > +  struct base *ptr = malloc (1);  /* { dg-line malloc5 } */ >    free (ptr); >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } malloc5 } > */ > diff --git a/gcc/testsuite/gcc.dg/analyzer/allocation-size-5.c > b/gcc/testsuite/gcc.dg/analyzer/allocation-size-5.c > index ae7e1074ebb..7769beec274 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/allocation-size-5.c > +++ b/gcc/testsuite/gcc.dg/analyzer/allocation-size-5.c > @@ -1,36 +1,37 @@ >  #include >  #include > +#include >   >  /* Tests related to statically allocated buffers.  */ >   >  typedef struct a { > -  short s; > +  int16_t s; >  } a; >   > -int *test_1 (void) > +int32_t *test_1 (void) >  { >    a A; /* { dg-message "\\d+ bytes" "note" } */ >    A.s = 1; > -  int *ptr = (int *) &A; /* { dg-line assign1 } */ > +  int32_t *ptr = (int32_t *) &A; /* { dg-line assign1 } */ >    return ptr; >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign1 } > */ > -  /* { dg-message "assigned to 'int \\*' here; 'sizeof \\(int\\)' is > '\\d+'" "note" { target *-*-* } assign1 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign1 } */ >  } >   > -int *test2 (void) > +int32_t *test2 (void) >  { > -  char arr[sizeof (int)]; > -  int *ptr = (int *)arr; > +  char arr[sizeof (int32_t)]; > +  int32_t *ptr = (int32_t *)arr; >    return ptr; >  } >   > -int *test3 (void) > +int32_t *test3 (void) >  { > -  char arr[sizeof (short)]; /* { dg-message "\\d+ bytes" "note" } */ > -  int *ptr = (int *)arr; /* { dg-line assign3 } */ > +  char arr[sizeof (int16_t)]; /* { dg-message "\\d+ bytes" "note" } > */ > +  int32_t *ptr = (int32_t *)arr; /* { dg-line assign3 } */ >    return ptr; >   >    /* { dg-warning "allocated buffer size is not a multiple of the > pointee's size \\\[CWE-131\\\]" "warning" { target *-*-* } assign3 } > */ > -  /* { dg-message "assigned to 'int \\*' here; 'sizeof \\(int\\)' is > '\\d+'" "note" { target *-*-* } assign3 } */ > +  /* { dg-message "'int32_t \\*' (\\\{aka 'int \\*'\\\})? here; > 'sizeof \\(int32_t (\\\{aka int\\\})\\)' is '\\d+'" "note" { target > *-*-* } assign3 } */ >  }