Skip to content

[Clang] [NFC] Fix unintended -Wreturn-type warnings everywhere in the test suite #123464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/test/ARCMT/autoreleases.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ id test2(A* val) {
return val;
}

id test3(void) {
void test3(void) {
id a = [[A alloc] init];
[a autorelease];
}
2 changes: 1 addition & 1 deletion clang/test/ARCMT/autoreleases.m.result
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ id test2(A* val) {
return val;
}

id test3(void) {
void test3(void) {
id a = [[A alloc] init];
}
2 changes: 1 addition & 1 deletion clang/test/ARCMT/retains.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @implementation Foo

@synthesize bar;

-(id)something {}
-(id)something { return (id)0; }

-(id)test:(id)obj {
id x = self.bar;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/ARCMT/retains.m.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ id IhaveSideEffect(void);

@synthesize bar;

-(id)something {}
-(id)something { return (id)0; }

-(id)test:(id)obj {
id x = self.bar;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct S {
int f(this S&);
};

int main() {
void main() {
S s;
int x = s.f();
// CHECK: CallExpr 0x{{[^ ]*}} <col:11, col:15> 'int
Expand Down
16 changes: 8 additions & 8 deletions clang/test/AST/ast-dump-special-member-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,25 @@ struct TrivialCopyAssignment {
struct NontrivialCopyAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct NontrivialCopyAssignment definition
// CHECK: CopyAssignment {{.*}}non_trivial{{.*}}
NontrivialCopyAssignment& operator=(const NontrivialCopyAssignment&) {}
NontrivialCopyAssignment& operator=(const NontrivialCopyAssignment&) { return *this; }
};

struct CopyAssignmentHasConstParam {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct CopyAssignmentHasConstParam definition
// CHECK: CopyAssignment {{.*}}has_const_param{{.*}}
CopyAssignmentHasConstParam& operator=(const CopyAssignmentHasConstParam&) {}
CopyAssignmentHasConstParam& operator=(const CopyAssignmentHasConstParam&) { return *this; }
};

struct CopyAssignmentDoesNotHaveConstParam {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct CopyAssignmentDoesNotHaveConstParam definition
// CHECK-NOT: CopyAssignment {{.*}} has_const_param{{.*}}
CopyAssignmentDoesNotHaveConstParam& operator=(CopyAssignmentDoesNotHaveConstParam&) {}
CopyAssignmentDoesNotHaveConstParam& operator=(CopyAssignmentDoesNotHaveConstParam&) { return *this; }
};

struct UserDeclaredCopyAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct UserDeclaredCopyAssignment definition
// CHECK: CopyAssignment {{.*}}user_declared{{.*}}
UserDeclaredCopyAssignment& operator=(const UserDeclaredCopyAssignment&) {}
UserDeclaredCopyAssignment& operator=(const UserDeclaredCopyAssignment&) { return *this; }
};

struct NonUserDeclaredCopyAssignment {
Expand All @@ -288,7 +288,7 @@ struct NeedsImplicitCopyAssignment {
struct DoesNotNeedImplicitCopyAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct DoesNotNeedImplicitCopyAssignment definition
// CHECK-NOT: CopyAssignment {{.*}}needs_implicit{{.*}}
DoesNotNeedImplicitCopyAssignment& operator=(const DoesNotNeedImplicitCopyAssignment&) {}
DoesNotNeedImplicitCopyAssignment& operator=(const DoesNotNeedImplicitCopyAssignment&) { return *this; }
};

struct DeclaresCopyAssignment {
Expand Down Expand Up @@ -352,13 +352,13 @@ struct TrivialMoveAssignment {
struct NontrivialMoveAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct NontrivialMoveAssignment definition
// CHECK: MoveAssignment {{.*}}non_trivial{{.*}}
NontrivialMoveAssignment& operator=(NontrivialMoveAssignment&&) {}
NontrivialMoveAssignment& operator=(NontrivialMoveAssignment&&) { return *this; }
};

struct UserDeclaredMoveAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct UserDeclaredMoveAssignment definition
// CHECK: MoveAssignment {{.*}}user_declared{{.*}}
UserDeclaredMoveAssignment& operator=(UserDeclaredMoveAssignment&&) {}
UserDeclaredMoveAssignment& operator=(UserDeclaredMoveAssignment&&) { return *this; }
};

struct NonUserDeclaredMoveAssignment {
Expand All @@ -375,7 +375,7 @@ struct NeedsImplicitMoveAssignment {
struct DoesNotNeedImplicitMoveAssignment {
// CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct DoesNotNeedImplicitMoveAssignment definition
// CHECK-NOT: MoveAssignment {{.*}}needs_implicit{{.*}}
DoesNotNeedImplicitMoveAssignment& operator=(DoesNotNeedImplicitMoveAssignment&&) {}
DoesNotNeedImplicitMoveAssignment& operator=(DoesNotNeedImplicitMoveAssignment&&) { return *this; }
};

struct MoveAssignmentNeedsOverloadResolution : virtual DeletedDestructor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6151,7 +6151,7 @@
<key>type</key><string>Argument with &apos;nonnull&apos; attribute passed null</string>
<key>check_name</key><string>core.NonNullParamChecker</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>c0b359a043c633f1b8d1581f68743361</string>
<key>issue_hash_content_of_line_in_context</key><string>4c580a2a9cf15947fa485a0a9e625306</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>RDar13295437</string>
<key>issue_hash_function_offset</key><string>3</string>
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/const-method-call.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
// RUN: %clang_analyze_cc1 -Wno-error=return-type -analyzer-checker=core,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s

void clang_analyzer_eval(bool);

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/inline-unique-reports.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -Wno-error=implicit-int -o %t > /dev/null 2>&1
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -Wno-error=implicit-int -Wno-error=return-type -o %t > /dev/null 2>&1
// RUN: %normalize_plist <%t | diff -ub %S/Inputs/expected-plists/inline-unique-reports.c.plist -

static inline bug(int *p) {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,8 +1914,8 @@ variable 'buf', which is not memory allocated by 'malloc()' [unix.Malloc]}}

(*crash_a)(); // expected-warning{{type specifier missing}}
// A CallEvent without a corresponding FunctionDecl.
crash_b() { crash_a(); } // no-crash
// expected-warning@-1{{type specifier missing}} expected-warning@-1{{non-void}}
crash_b() { crash_a(); return 0; } // no-crash
// expected-warning@-1{{type specifier missing}}

long *global_a;
void realloc_crash(void) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin8 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.1 2>&1
// RUN: %clang_analyze_cc1 -Wno-error=return-type -triple i386-apple-darwin8 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.1 2>&1
// RUN: FileCheck -input-file=%t.1 -check-prefix=CHECK-darwin8 %s
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.2 2>&1
// RUN: %clang_analyze_cc1 -Wno-error=return-type -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.2 2>&1
// RUN: FileCheck -input-file=%t.2 -check-prefix=CHECK-darwin9 %s
// RUN: %clang_analyze_cc1 -triple thumbv6-apple-ios4.0 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.3 2>&1
// RUN: %clang_analyze_cc1 -Wno-error=return-type -triple thumbv6-apple-ios4.0 -analyzer-checker=core,alpha.core -Wno-objc-root-class %s > %t.3 2>&1
// RUN: FileCheck -input-file=%t.3 -check-prefix=CHECK-darwin9 %s

@interface MyClass {}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/novoidtypecrash.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 -std=c89 -Wno-int-conversion -analyzer-checker=core %s
// RUN: %clang_analyze_cc1 -Wno-error=return-type -std=c89 -Wno-int-conversion -analyzer-checker=core %s
x;
y(void **z) { // no-crash
*z = x;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-output.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (void)test {

struct RDar13295437_S { int *i; };

int RDar13295437(void) {
void RDar13295437(void) {
struct RDar13295437_S s = {0};
struct RDar13295437_S *sp = &s;
RDar13295437_f(sp->i);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-stats-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// REQUIRES: asserts
// RUN: FileCheck --input-file=%t.plist %s

int foo(void) {}
void foo(void) {}


// CHECK: <key>diagnostics</key>
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/scopes-cfg-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ void test_switch_with_compound_with_default() {
// CHECK-NEXT: Succs (1): B4
// CHECK: [B0 (EXIT)]
// CHECK-NEXT: Preds (1): B1
int test_switch_with_compound_without_default() {
void test_switch_with_compound_without_default() {
char c = '1';
switch (int i = getX()) {
case 0:
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/structured_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
void clang_analyzer_eval(bool);

struct s { int a; };
int foo() {
void foo() {
auto [a] = s{1};
clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
} // expected-warning{{non-void function does not return a value}}
}

struct s2 {
int &x;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CXX/drs/cwg605.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ template <class T>
static T f(T t) {}

template <>
int f(int t) {}
int f(int t) { return 0; }

void g(int a) {
f(a);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 -std=c++11 %s -Winvalid-noreturn -verify
// RUN: %clang_cc1 -Werror=return-type -std=c++11 %s -Winvalid-noreturn -verify

// An attribute-specifier-seq in a lambda-declarator appertains to the
// type of the corresponding function call operator.
void test_attributes() {
auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-warning{{on-void lambda does not return a value in all control paths}}
auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-error{{non-void lambda does not return a value in all control paths}}

// FIXME: GCC accepts the [[gnu::noreturn]] attribute here.
auto nrl2 = []() [[gnu::noreturn]] { return; }; // expected-warning{{attribute 'noreturn' ignored}}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
// RUN: %clang_cc1 -Werror=return-type -fsyntax-only -std=c++11 %s -verify

// Check that analysis-based warnings work in lambda bodies.
void analysis_based_warnings() {
(void)[]() -> int { }; // expected-warning{{non-void lambda does not return a value}}
(void)[]() -> int { }; // expected-error{{non-void lambda does not return a value}}
}

// Check that we get the right types of captured variables (the
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2003-06-26-CFECrash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct Globals {

extern Uz_Globs G;

int extract_or_test_files(void) {
void extract_or_test_files(void) {
G.pInfo = G.info;
}

2 changes: 1 addition & 1 deletion clang/test/CodeGen/2003-08-18-SigSetJmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ typedef int sigjmp_buf[_JBLEN + 1];
int sigsetjmp(sigjmp_buf env, int savemask);
void bar(void);
sigjmp_buf B;
int foo(void) {
void foo(void) {
sigsetjmp(B, 1);
bar();
}
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2003-08-23-LocalUnionTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

union foo { int X; };

int test(union foo* F) {
void test(union foo* F) {
{
union foo { float X; } A;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2003-10-29-AsmRename.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int Func64(struct bar* B) {
}


int test(void) {
void test(void) {
Func(0); /* should be renamed to call Func64 */
Func64(0);
}
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2003-11-20-ComplexDivision.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -emit-llvm %s -o /dev/null

int test(void) {
void test(void) {
__complex__ double C;
double D;
C / D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

struct S { };

int xxxx(int a) {
void xxxx(int a) {
struct S comps[a];
comps[0];
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ void bar(void) {
int func(void);
foo(func);
}
static int func(char** A, char ** B) {}
static int func(char** A, char ** B) { return 0; }
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// PR481
// RUN: %clang_cc1 %s -Wno-implicit-function-declaration -emit-llvm -o /dev/null

int flags(int a, int b, ...) {
void flags(int a, int b, ...) {
__builtin_va_list args;
__builtin_va_start(args,a); // not the last named arg
foo(args);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | \
// RUN: %clang_cc1 -Wno-error=return-type -std=c99 %s -emit-llvm -o - | \
// RUN: opt -O3 -disable-output
// PR580

Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGen/2007-01-06-KNR-Proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ int svc_register (void (*dispatch) (int));
int svc_register (dispatch)
void (*dispatch) ();
{
return 0;
}

2 changes: 1 addition & 1 deletion clang/test/CodeGen/2008-05-06-CFECrash.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -emit-llvm -O2 %s -o /dev/null
// RUN: %clang_cc1 -Wno-error=return-type -emit-llvm -O2 %s -o /dev/null
// PR2292.
__inline__ __attribute__ ((__pure__)) int g (void) {}
void f (int k) { k = g (); }
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ static void bar(void *db) {

char s[5] = "hi";

int foo(void) {
void foo(void) {
bar(0);
}
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2008-10-13-FrontendCrash.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -std=c89 -emit-llvm -o -
// PR2797

unsigned int
void
func_48 (signed char p_49)
{
signed char l_340;
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGen/2009-01-21-InvalidIterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ frame_hdr_cache[8];
_Unwind_Ptr
base_from_cb_data (struct unw_eh_callback_data *data)
{
return 0;
}

void
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/2009-05-04-EnumInreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ enum kobject_action {
struct kobject;

// CHECK: i32 inreg %action
int kobject_uevent(struct kobject *kobj, enum kobject_action action) {}
void kobject_uevent(struct kobject *kobj, enum kobject_action action) {}
1 change: 1 addition & 0 deletions clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ typedef __WCHAR_TYPE__ wchar_t;
signed short _iodbcdm_sqlerror(void)
{
wchar_t _sqlState[6] = { L"\0" };
return 0;
}
2 changes: 1 addition & 1 deletion clang/test/CodeGen/SystemZ/vec-abi-gnuattr-05.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef __attribute__((vector_size(16))) int v4i32;
v4i32 (*bar)(int);

static int foo() {
(*bar)(0)[0];
return (*bar)(0)[0];
}

int fun() { return foo(); }
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CodeGen/X86/avx512fp16-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ struct fsd {

struct fsd pr52011(void) {
// CHECK: define{{.*}} { float, double } @
struct fsd x;
return x;
}

struct hsd {
Expand All @@ -216,6 +218,8 @@ struct hsd {

struct hsd pr52011_2(void) {
// CHECK: define{{.*}} { half, double } @
struct hsd x;
return x;
}

struct hsf {
Expand All @@ -226,6 +230,8 @@ struct hsf {

struct hsf pr52011_3(void) {
// CHECK: define{{.*}} <4 x half> @
struct hsf x;
return x;
}

struct fds {
Expand All @@ -237,4 +243,6 @@ struct fds {
struct fds pr52011_4(void) {
// CHECK-C: define{{.*}} { float, double } @pr52011_4
// CHECK-CPP: define{{.*}} void @_Z9pr52011_4v({{.*}} sret
struct fds x;
return x;
}
Loading
Loading