llvm-project/clang/test/CodeGen/2009-01-21-InvalidIterator.c
Sirraide 12f78e740c
[Clang] [NFC] Fix unintended -Wreturn-type warnings everywhere in the test suite (#123464)
In preparation of making `-Wreturn-type` default to an error (as there
is virtually no situation where you’d *want* to fall off the end of a
function that is supposed to return a value), this patch fixes tests
that have relied on this being only a warning, of which there seem 
to be 3 kinds:

1. Tests which for no apparent reason have a function that triggers the
warning.

I suspect that a lot of these were on accident (or from before the
warning was introduced), since a lot of people will open issues w/ their
problematic code in the `main` function (which is the one case where you
don’t need to return from a non-void function, after all...), which
someone will then copy, possibly into a namespace, possibly renaming it,
the end result of that being that you end up w/ something that
definitely is not `main` anymore, but which still is declared as
returning `int`, and which still has no return statement (another reason
why I think this might apply to a lot of these is because usually the
actual return type of such problematic functions is quite literally
`int`).
  
A lot of these are really old tests that don’t use `-verify`, which is
why no-one noticed or had to care about the extra warning that was
already being emitted by them until now.

2. Tests which test either `-Wreturn-type`, `[[noreturn]]`, or what
codegen and sanitisers do whenever you do fall off the end of a
function.

3. Tests where I struggle to figure out what is even being tested
(usually because they’re Objective-C tests, and I don’t know
Objective-C), whether falling off the end of a function matters in the
first place, and tests where actually spelling out an expression to
return would be rather cumbersome (e.g. matrix types currently don’t
support list initialisation, so I can’t write e.g. `return {}`).

For tests that fall into categories 2 and 3, I just added
`-Wno-error=return-type` to the `RUN` lines and called it a day. This
was especially necessary for the former since `-Wreturn-type` is an
analysis-based warning, meaning that it is currently impossible to test
for more than one occurrence of it in the same compilation if it
defaults to an error since the analysis pass is skipped for subsequent
functions as soon as an error is emitted.

I’ve also added `-Werror=return-type` to a few tests that I had already
updated as this patch was previously already making the warning an error
by default, but we’ve decided to split that into two patches instead.
2025-01-18 19:16:33 +01:00

76 lines
1.4 KiB
C

// RUN: %clang_cc1 %s -emit-llvm -debug-info-kind=limited -o /dev/null
typedef long unsigned int size_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
typedef uint16_t Elf64_Half;
typedef uint32_t Elf64_Word;
typedef uint64_t Elf64_Xword;
typedef uint64_t Elf64_Addr;
typedef uint64_t Elf64_Off;
typedef struct
{
Elf64_Word p_type;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Xword p_align;
}
Elf64_Phdr;
struct dl_phdr_info
{
const char *dlpi_name;
const Elf64_Phdr *dlpi_phdr;
Elf64_Half dlpi_phnum;
unsigned long long int dlpi_adds;
};
typedef unsigned _Unwind_Ptr;
struct object
{
union
{
const struct dwarf_fde *single;
struct dwarf_fde **array;
struct fde_vector *sort;
}
u;
union
{
struct
{
}
b;
}
s;
struct object *next;
};
typedef int sword;
typedef unsigned int uword;
struct dwarf_fde
{
uword length;
sword CIE_delta;
unsigned char pc_begin[];
};
typedef struct dwarf_fde fde;
struct unw_eh_callback_data
{
const fde *ret;
struct frame_hdr_cache_element *link;
}
frame_hdr_cache[8];
_Unwind_Ptr
base_from_cb_data (struct unw_eh_callback_data *data)
{
return 0;
}
void
_Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
{
const unsigned char *p;
const struct unw_eh_frame_hdr *hdr;
struct object ob;
}