]> gcc.gnu.org Git - gcc.git/commit
c: improvements to address space diagnostics
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 1 Aug 2022 23:30:15 +0000 (19:30 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 1 Aug 2022 23:30:15 +0000 (19:30 -0400)
commite8bc6918b31e63fcaebe1e9dd64e0157d54f1b7a
tree8eff89565ceb891b5ece8594feae015e378d6722
parentffd12be1394a49b734c51d2fee60584c66ff2f05
c: improvements to address space diagnostics

This adds a clarifying "note" to address space mismatch diagnostics.
For example, it improves the diagnostic for
gcc.target/i386/addr-space-typeck-2.c from:

addr-space-typeck-2.c: In function 'test_bad_call':
addr-space-typeck-2.c:12:22: error: passing argument 2 of 'expects_seg_gs'
  from pointer to non-enclosed address space
   12 |   expects_seg_gs (0, ptr, 1);
      |                      ^~~

to:

addr-space-typeck-2.c: In function 'test_bad_call':
addr-space-typeck-2.c:12:22: error: passing argument 2 of 'expects_seg_gs'
  from pointer to non-enclosed address space
   12 |   expects_seg_gs (0, ptr, 1);
      |                      ^~~
addr-space-typeck-2.c:7:51: note: expected '__seg_gs void *' but argument
  is of type 'void *'
    7 | extern void expects_seg_gs (int i, void __seg_gs *param, int j);
      |                                    ~~~~~~~~~~~~~~~^~~~~

I took the liberty of adding the test coverage to i386 since we need
a specific target to test this on.

gcc/c/ChangeLog:
* c-typeck.cc (build_c_cast): Quote names of address spaces in
diagnostics.
(convert_for_assignment): Add a note to address space mismatch
diagnostics, specifying the expected and actual types.

gcc/testsuite/ChangeLog:
* gcc.target/i386/addr-space-typeck-1.c: New test.
* gcc.target/i386/addr-space-typeck-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/c/c-typeck.cc
gcc/testsuite/gcc.target/i386/addr-space-typeck-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/addr-space-typeck-2.c [new file with mode: 0644]
This page took 0.070087 seconds and 6 git commands to generate.