-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
Conversation
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang-modules Author: None (Sirraide) ChangesThis makes
For tests that fall into categories 2 and 3, I just added Patch is 116.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/123464.diff 150 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9eeb872aa57d79..b017f51658a449 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -81,6 +81,9 @@ code bases.
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
and pointer overflow are well-defined.
+- The `-Wreturn-type` warning now defaults to an error. This behaviour can currently
+ be turned off by specifying `-Wno-error=return-type`.
+
C/C++ Language Potentially Breaking Changes
-------------------------------------------
@@ -310,7 +313,7 @@ C++23 Feature Support
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
-
+
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
C++20 Feature Support
@@ -715,7 +718,7 @@ Improvements to Clang's diagnostics
- Clang now diagnoses dangling references for C++20's parenthesized aggregate initialization (#101957).
-- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
+- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
defined a defaulted comparison operator (#GH116270).
.. code-block:: c++
@@ -934,7 +937,7 @@ Bug Fixes to C++ Support
- Fixed an assertion failure caused by invalid default argument substitutions in non-defining
friend declarations. (#GH113324)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
-- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
+- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
- Fixed a null pointer dereference issue when heuristically computing ``sizeof...(pack)`` expressions. (#GH81436)
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8be4f946dce1cc..c84177a9bc75cc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -707,10 +707,10 @@ def err_thread_unsupported : Error<
// FIXME: Combine fallout warnings to just one warning.
def warn_maybe_falloff_nonvoid_function : Warning<
"non-void function does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_function : Warning<
"non-void function does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_const_attr_with_pure_attr : Warning<
"'const' attribute imposes more restrictions; 'pure' attribute ignored">,
InGroup<IgnoredAttributes>;
@@ -724,10 +724,10 @@ def err_falloff_nonvoid_block : Error<
"non-void block does not return a value">;
def warn_maybe_falloff_nonvoid_coroutine : Warning<
"non-void coroutine does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_coroutine : Warning<
"non-void coroutine does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_suggest_noreturn_function : Warning<
"%select{function|method}0 %1 could be declared with attribute 'noreturn'">,
InGroup<MissingNoreturn>, DefaultIgnore;
@@ -8358,10 +8358,10 @@ let CategoryName = "Lambda Issue" in {
"lambda declared 'noreturn' should not return">;
def warn_maybe_falloff_nonvoid_lambda : Warning<
"non-void lambda does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_lambda : Warning<
"non-void lambda does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def err_access_lambda_capture : Error<
// The ERRORs represent other special members that aren't constructors, in
// hopes that someone will bother noticing and reporting if they appear
diff --git a/clang/test/ARCMT/autoreleases.m b/clang/test/ARCMT/autoreleases.m
index 4c268c09a715c6..7c046dc227a068 100644
--- a/clang/test/ARCMT/autoreleases.m
+++ b/clang/test/ARCMT/autoreleases.m
@@ -69,7 +69,7 @@ id test2(A* val) {
return val;
}
-id test3(void) {
+void test3(void) {
id a = [[A alloc] init];
[a autorelease];
}
diff --git a/clang/test/ARCMT/autoreleases.m.result b/clang/test/ARCMT/autoreleases.m.result
index b3aad804a45be6..29d00ea60deed8 100644
--- a/clang/test/ARCMT/autoreleases.m.result
+++ b/clang/test/ARCMT/autoreleases.m.result
@@ -64,6 +64,6 @@ id test2(A* val) {
return val;
}
-id test3(void) {
+void test3(void) {
id a = [[A alloc] init];
}
diff --git a/clang/test/ARCMT/retains.m b/clang/test/ARCMT/retains.m
index 43a94fc16cecf2..df1badf214b692 100644
--- a/clang/test/ARCMT/retains.m
+++ b/clang/test/ARCMT/retains.m
@@ -21,7 +21,7 @@ @implementation Foo
@synthesize bar;
--(id)something {}
+-(id)something { return (id)0; }
-(id)test:(id)obj {
id x = self.bar;
@@ -44,7 +44,7 @@ -(id)test:(id)obj {
[x release];
return [self retain];
}
-
+
- (id)test1 {
id x=0;
([x retain]);
diff --git a/clang/test/ARCMT/retains.m.result b/clang/test/ARCMT/retains.m.result
index 4e720d6bb4c112..211c4b50f53519 100644
--- a/clang/test/ARCMT/retains.m.result
+++ b/clang/test/ARCMT/retains.m.result
@@ -21,7 +21,7 @@ id IhaveSideEffect(void);
@synthesize bar;
--(id)something {}
+-(id)something { return (id)0; }
-(id)test:(id)obj {
id x = self.bar;
@@ -39,7 +39,7 @@ id IhaveSideEffect(void);
// do stuff with x;
return self;
}
-
+
- (id)test1 {
id x=0;
return (((x)));
diff --git a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
index 1b385e0fc33319..854d12b4cdba6e 100644
--- a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
+++ b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
@@ -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
diff --git a/clang/test/AST/ast-dump-special-member-functions.cpp b/clang/test/AST/ast-dump-special-member-functions.cpp
index b98c90f6760434..0fe2cee615c826 100644
--- a/clang/test/AST/ast-dump-special-member-functions.cpp
+++ b/clang/test/AST/ast-dump-special-member-functions.cpp
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
diff --git a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
index 32244329c434aa..8b8cc3239bd4bd 100644
--- a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
+++ b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
@@ -6151,7 +6151,7 @@
<key>type</key><string>Argument with 'nonnull' 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>
diff --git a/clang/test/Analysis/const-method-call.cpp b/clang/test/Analysis/const-method-call.cpp
index 7da7ca5554a23e..b37ce17447bdd2 100644
--- a/clang/test/Analysis/const-method-call.cpp
+++ b/clang/test/Analysis/const-method-call.cpp
@@ -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);
diff --git a/clang/test/Analysis/inline-unique-reports.c b/clang/test/Analysis/inline-unique-reports.c
index e58870ea74ab83..306e314a94e437 100644
--- a/clang/test/Analysis/inline-unique-reports.c
+++ b/clang/test/Analysis/inline-unique-reports.c
@@ -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) {
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index f2f8975b5f0e21..0dc667bc1ed505 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -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) {
diff --git a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
index bfc3cb92b639af..0dfeb298db7426 100644
--- a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
+++ b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -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 {}
@@ -25,53 +25,53 @@ - (void)voidM {}
@end
void createFoo(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
void *v = [obj voidPtrM]; // no-warning
int i = [obj intM]; // no-warning
}
void createFoo2(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
long double ld = [obj longDoubleM];
}
void createFoo3(void) {
MyClass *obj;
- obj = 0;
-
+ obj = 0;
+
long long ll = [obj longlongM];
}
void createFoo4(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
double d = [obj doubleM];
}
void createFoo5(void) {
- MyClass *obj = (id)@"";
-
+ MyClass *obj = (id)@"";
+
double d = [obj doubleM]; // no-warning
}
void createFoo6(void) {
MyClass *obj;
- obj = 0;
-
+ obj = 0;
+
unsigned long long ull = [obj unsignedLongLongM];
}
void handleNilPruneLoop(MyClass *obj) {
if (!!obj)
return;
-
+
// Test if [obj intM] evaluates to 0, thus pruning the entire loop.
for (int i = 0; i < [obj intM]; i++) {
long long j = [obj longlongM];
}
-
+
long long j = [obj longlongM];
}
diff --git a/clang/test/Analysis/novoidtypecrash.c b/clang/test/Analysis/novoidtypecrash.c
index 197516a2596187..5af30c20104386 100644
--- a/clang/test/Analysis/novoidtypecrash.c
+++ b/clang/test/Analysis/novoidtypecrash.c
@@ -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;
diff --git a/clang/test/Analysis/plist-output.m b/clang/test/Analysis/plist-output.m
index 96123243a833a0..b89aab0a7c4cfd 100644
--- a/clang/test/Analysis/plist-output.m
+++ b/clang/test/Analysis/plist-output.m
@@ -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);
diff --git a/clang/test/Analysis/plist-stats-output.c b/clang/test/Analysis/plist-stats-output.c
index 4bcae557d9276d..42e0a802d3e377 100644
--- a/clang/test/Analysis/plist-stats-output.c
+++ b/clang/test/Analysis/plist-stats-output.c
@@ -2,7 +2,7 @@
// REQUIRES: asserts
// RUN: FileCheck --input-file=%t.plist %s
-int foo(void) {}
+void foo(void) {}
// CHECK: <key>diagnostics</key>
diff --git a/clang/test/Analysis/scopes-cfg-output.cpp b/clang/test/Analysis/scopes-cfg-output.cpp
index 5e6706602d4564..c082bb179545fa 100644
--- a/clang/test/Analysis/scopes-cfg-output.cpp
+++ b/clang/test/Analysis/scopes-cfg-output.cpp
@@ -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:
diff --git a/clang/test/Analysis/structured_bindings.cpp b/clang/test/Analysis/structured_bindings.cpp
index 7004c2e7dcf43f..989c584189ab2d 100644
--- a/clang/test/Analysis/structured_bindings.cpp
+++ b/clang/test/Analysis/structured_bindings.cpp
@@ -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;
diff --git a/clang/test/CXX/drs/cwg605.cpp b/clang/test/CXX/drs/cwg605.cpp
index 2fd9e8155bf77b..b98c483f3118eb 100644
--- a/clang/test/CXX/drs/cwg605.cpp
+++ b/clang/test/CXX/drs/cwg605.cpp
@@ -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);
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
index 2a99ff0ea44f90..a07ee2213ce40c 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -3,7 +3,7 @@
// 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}}
@@ -25,7 +25,7 @@ void test_quals() {
lc();
auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \
- // expected-note{{method is not marked volatile}}
+ // expected-note{{method is not marked volatile}}
const decltype(ml) mlc = ml;
ml();
mlc(); // expected-error{{no matching function for call to object of type}}
@@ -56,8 +56,8 @@ void test_exception_spec() {
auto ntl1 = []() throw() {};
auto ntl2 = []() noexcept(true) {};
auto ntl3 = []() noexcept {};
- static_assert(noexcept(ntl1()), "lambda cannot throw");
- static_assert(noexcept(ntl2()), "lambda cannot throw");
- static_assert(noexcept(ntl3()), "lambda cannot throw");
+ static_assert(noexcept(ntl1()), "lambda cannot throw");
+ static_assert(noexcept(ntl2()), "lambda cannot throw");
+ static_assert(noexcept(ntl3()), "lambda cannot throw");
}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/clang/test/C...
[truncated]
|
@llvm/pr-subscribers-backend-systemz Author: None (Sirraide) ChangesThis makes
For tests that fall into categories 2 and 3, I just added Patch is 116.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/123464.diff 150 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9eeb872aa57d79..b017f51658a449 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -81,6 +81,9 @@ code bases.
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
and pointer overflow are well-defined.
+- The `-Wreturn-type` warning now defaults to an error. This behaviour can currently
+ be turned off by specifying `-Wno-error=return-type`.
+
C/C++ Language Potentially Breaking Changes
-------------------------------------------
@@ -310,7 +313,7 @@ C++23 Feature Support
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
-
+
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
C++20 Feature Support
@@ -715,7 +718,7 @@ Improvements to Clang's diagnostics
- Clang now diagnoses dangling references for C++20's parenthesized aggregate initialization (#101957).
-- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
+- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
defined a defaulted comparison operator (#GH116270).
.. code-block:: c++
@@ -934,7 +937,7 @@ Bug Fixes to C++ Support
- Fixed an assertion failure caused by invalid default argument substitutions in non-defining
friend declarations. (#GH113324)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
-- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
+- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
- Fixed a null pointer dereference issue when heuristically computing ``sizeof...(pack)`` expressions. (#GH81436)
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8be4f946dce1cc..c84177a9bc75cc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -707,10 +707,10 @@ def err_thread_unsupported : Error<
// FIXME: Combine fallout warnings to just one warning.
def warn_maybe_falloff_nonvoid_function : Warning<
"non-void function does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_function : Warning<
"non-void function does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_const_attr_with_pure_attr : Warning<
"'const' attribute imposes more restrictions; 'pure' attribute ignored">,
InGroup<IgnoredAttributes>;
@@ -724,10 +724,10 @@ def err_falloff_nonvoid_block : Error<
"non-void block does not return a value">;
def warn_maybe_falloff_nonvoid_coroutine : Warning<
"non-void coroutine does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_coroutine : Warning<
"non-void coroutine does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_suggest_noreturn_function : Warning<
"%select{function|method}0 %1 could be declared with attribute 'noreturn'">,
InGroup<MissingNoreturn>, DefaultIgnore;
@@ -8358,10 +8358,10 @@ let CategoryName = "Lambda Issue" in {
"lambda declared 'noreturn' should not return">;
def warn_maybe_falloff_nonvoid_lambda : Warning<
"non-void lambda does not return a value in all control paths">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def warn_falloff_nonvoid_lambda : Warning<
"non-void lambda does not return a value">,
- InGroup<ReturnType>;
+ InGroup<ReturnType>, DefaultError;
def err_access_lambda_capture : Error<
// The ERRORs represent other special members that aren't constructors, in
// hopes that someone will bother noticing and reporting if they appear
diff --git a/clang/test/ARCMT/autoreleases.m b/clang/test/ARCMT/autoreleases.m
index 4c268c09a715c6..7c046dc227a068 100644
--- a/clang/test/ARCMT/autoreleases.m
+++ b/clang/test/ARCMT/autoreleases.m
@@ -69,7 +69,7 @@ id test2(A* val) {
return val;
}
-id test3(void) {
+void test3(void) {
id a = [[A alloc] init];
[a autorelease];
}
diff --git a/clang/test/ARCMT/autoreleases.m.result b/clang/test/ARCMT/autoreleases.m.result
index b3aad804a45be6..29d00ea60deed8 100644
--- a/clang/test/ARCMT/autoreleases.m.result
+++ b/clang/test/ARCMT/autoreleases.m.result
@@ -64,6 +64,6 @@ id test2(A* val) {
return val;
}
-id test3(void) {
+void test3(void) {
id a = [[A alloc] init];
}
diff --git a/clang/test/ARCMT/retains.m b/clang/test/ARCMT/retains.m
index 43a94fc16cecf2..df1badf214b692 100644
--- a/clang/test/ARCMT/retains.m
+++ b/clang/test/ARCMT/retains.m
@@ -21,7 +21,7 @@ @implementation Foo
@synthesize bar;
--(id)something {}
+-(id)something { return (id)0; }
-(id)test:(id)obj {
id x = self.bar;
@@ -44,7 +44,7 @@ -(id)test:(id)obj {
[x release];
return [self retain];
}
-
+
- (id)test1 {
id x=0;
([x retain]);
diff --git a/clang/test/ARCMT/retains.m.result b/clang/test/ARCMT/retains.m.result
index 4e720d6bb4c112..211c4b50f53519 100644
--- a/clang/test/ARCMT/retains.m.result
+++ b/clang/test/ARCMT/retains.m.result
@@ -21,7 +21,7 @@ id IhaveSideEffect(void);
@synthesize bar;
--(id)something {}
+-(id)something { return (id)0; }
-(id)test:(id)obj {
id x = self.bar;
@@ -39,7 +39,7 @@ id IhaveSideEffect(void);
// do stuff with x;
return self;
}
-
+
- (id)test1 {
id x=0;
return (((x)));
diff --git a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
index 1b385e0fc33319..854d12b4cdba6e 100644
--- a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
+++ b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
@@ -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
diff --git a/clang/test/AST/ast-dump-special-member-functions.cpp b/clang/test/AST/ast-dump-special-member-functions.cpp
index b98c90f6760434..0fe2cee615c826 100644
--- a/clang/test/AST/ast-dump-special-member-functions.cpp
+++ b/clang/test/AST/ast-dump-special-member-functions.cpp
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
diff --git a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
index 32244329c434aa..8b8cc3239bd4bd 100644
--- a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
+++ b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
@@ -6151,7 +6151,7 @@
<key>type</key><string>Argument with 'nonnull' 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>
diff --git a/clang/test/Analysis/const-method-call.cpp b/clang/test/Analysis/const-method-call.cpp
index 7da7ca5554a23e..b37ce17447bdd2 100644
--- a/clang/test/Analysis/const-method-call.cpp
+++ b/clang/test/Analysis/const-method-call.cpp
@@ -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);
diff --git a/clang/test/Analysis/inline-unique-reports.c b/clang/test/Analysis/inline-unique-reports.c
index e58870ea74ab83..306e314a94e437 100644
--- a/clang/test/Analysis/inline-unique-reports.c
+++ b/clang/test/Analysis/inline-unique-reports.c
@@ -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) {
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index f2f8975b5f0e21..0dc667bc1ed505 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -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) {
diff --git a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
index bfc3cb92b639af..0dfeb298db7426 100644
--- a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
+++ b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -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 {}
@@ -25,53 +25,53 @@ - (void)voidM {}
@end
void createFoo(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
void *v = [obj voidPtrM]; // no-warning
int i = [obj intM]; // no-warning
}
void createFoo2(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
long double ld = [obj longDoubleM];
}
void createFoo3(void) {
MyClass *obj;
- obj = 0;
-
+ obj = 0;
+
long long ll = [obj longlongM];
}
void createFoo4(void) {
- MyClass *obj = 0;
-
+ MyClass *obj = 0;
+
double d = [obj doubleM];
}
void createFoo5(void) {
- MyClass *obj = (id)@"";
-
+ MyClass *obj = (id)@"";
+
double d = [obj doubleM]; // no-warning
}
void createFoo6(void) {
MyClass *obj;
- obj = 0;
-
+ obj = 0;
+
unsigned long long ull = [obj unsignedLongLongM];
}
void handleNilPruneLoop(MyClass *obj) {
if (!!obj)
return;
-
+
// Test if [obj intM] evaluates to 0, thus pruning the entire loop.
for (int i = 0; i < [obj intM]; i++) {
long long j = [obj longlongM];
}
-
+
long long j = [obj longlongM];
}
diff --git a/clang/test/Analysis/novoidtypecrash.c b/clang/test/Analysis/novoidtypecrash.c
index 197516a2596187..5af30c20104386 100644
--- a/clang/test/Analysis/novoidtypecrash.c
+++ b/clang/test/Analysis/novoidtypecrash.c
@@ -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;
diff --git a/clang/test/Analysis/plist-output.m b/clang/test/Analysis/plist-output.m
index 96123243a833a0..b89aab0a7c4cfd 100644
--- a/clang/test/Analysis/plist-output.m
+++ b/clang/test/Analysis/plist-output.m
@@ -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);
diff --git a/clang/test/Analysis/plist-stats-output.c b/clang/test/Analysis/plist-stats-output.c
index 4bcae557d9276d..42e0a802d3e377 100644
--- a/clang/test/Analysis/plist-stats-output.c
+++ b/clang/test/Analysis/plist-stats-output.c
@@ -2,7 +2,7 @@
// REQUIRES: asserts
// RUN: FileCheck --input-file=%t.plist %s
-int foo(void) {}
+void foo(void) {}
// CHECK: <key>diagnostics</key>
diff --git a/clang/test/Analysis/scopes-cfg-output.cpp b/clang/test/Analysis/scopes-cfg-output.cpp
index 5e6706602d4564..c082bb179545fa 100644
--- a/clang/test/Analysis/scopes-cfg-output.cpp
+++ b/clang/test/Analysis/scopes-cfg-output.cpp
@@ -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:
diff --git a/clang/test/Analysis/structured_bindings.cpp b/clang/test/Analysis/structured_bindings.cpp
index 7004c2e7dcf43f..989c584189ab2d 100644
--- a/clang/test/Analysis/structured_bindings.cpp
+++ b/clang/test/Analysis/structured_bindings.cpp
@@ -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;
diff --git a/clang/test/CXX/drs/cwg605.cpp b/clang/test/CXX/drs/cwg605.cpp
index 2fd9e8155bf77b..b98c483f3118eb 100644
--- a/clang/test/CXX/drs/cwg605.cpp
+++ b/clang/test/CXX/drs/cwg605.cpp
@@ -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);
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
index 2a99ff0ea44f90..a07ee2213ce40c 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -3,7 +3,7 @@
// 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}}
@@ -25,7 +25,7 @@ void test_quals() {
lc();
auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \
- // expected-note{{method is not marked volatile}}
+ // expected-note{{method is not marked volatile}}
const decltype(ml) mlc = ml;
ml();
mlc(); // expected-error{{no matching function for call to object of type}}
@@ -56,8 +56,8 @@ void test_exception_spec() {
auto ntl1 = []() throw() {};
auto ntl2 = []() noexcept(true) {};
auto ntl3 = []() noexcept {};
- static_assert(noexcept(ntl1()), "lambda cannot throw");
- static_assert(noexcept(ntl2()), "lambda cannot throw");
- static_assert(noexcept(ntl3()), "lambda cannot throw");
+ static_assert(noexcept(ntl1()), "lambda cannot throw");
+ static_assert(noexcept(ntl2()), "lambda cannot throw");
+ static_assert(noexcept(ntl3()), "lambda cannot throw");
}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/clang/test/C...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for working on this.
It seems a bit ambitious to do this at the end of the cycle (no time to react to feedback).
However, we might want to take what is offered and minimize churn.
How about
-
in this patch you modify the tests, and the test runner (hopefully lit config can do that, I haven't checked) such that ~all tests (including new ones) use -Werror=return-type (we might want to have tests where it's just a warning to make sure this still works)
-
In a separate patch we flip the default.
it would be a lot less disruptive in case we need to revert something.
WDYT?
-Wreturn-type
default to an error.-Wreturn-type
warnings everywhere in the test suite
Yeah, I agree that that makes sense (I was thinking about splitting it too since there are so many effectively NFC changes that are part of this...); I’ve changed this pr to just refactor all the tests. I don’t expect too many new tests to be added between when this is merged and when the actual change is made to make the warning an error since the vast majority of the tests I had to change (at least of the ones that I spent the most time refactoring) are fairly old (from around 2007–2010). |
Yeah, on the one hand, we could wait until after the branch before we make this change, but on the other hand, doing it now might result in more feedback as to how disruptive defaulting the warning to an error would actually end up being? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable.
anything you can do to reduce white space only changes?
// FIXME: We can't actually do 'return m[r][c]' here currently. | ||
static double d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we supposed to be able to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not entirely sure candidly. On the one hand, maybe exposing a reference to a matrix element is just fundamentally a bad idea, but on the other, support for matrix types is also incomplete in other areas (e.g. list initialisation doesn’t work at all, not even e.g. some_matrix_type{}
). I don’t really know which one is the case here, so I felt like I should maybe point out why I’m solving the problem of having to return a double&
in a weird way here.
Er, unless there is some way to do it w/ git that I’m not aware of it’d be pretty complicated for me because my IDE deletes trailing whitespace on save (and I’m pretty sure that’s true for a lot of other people too), so it becomes fairly cumbersome to try and edit a file w/o doing that—that and I am so used to it doing that that I’m pretty sure e.g. disabling that setting would have the opposite effect and introduce a bunch of trailing whitespace changes in every file I edit... :( |
96ddccb
to
e0099cf
Compare
Update: thanks to @cor3ntin and some git black magic, I was able to remove the whitespace-only changes. |
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 fixing tests that have relied on this being a warning, of which there seem to be 3 kinds: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 notmain
anymore, but which still is declared as returningint
, 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 literallyint
).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.Tests which test either
-Wreturn-type
,[[noreturn]]
, or what codegen and sanitisers do whenever you do fall off the end of a function.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 theRUN
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.