Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ code bases.
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
and pointer overflow are well-defined.

- ``-Wreturn-type`` now defaults to an error in all language modes; like other
warnings, it can be reverted to just being a warning by specifying
``-Wno-error=return-type``.

C/C++ Language Potentially Breaking Changes
-------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,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>;
Expand All @@ -726,10 +726,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;
Expand Down Expand Up @@ -8365,10 +8365,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
Expand Down
10 changes: 5 additions & 5 deletions clang/test/CodeGen/armv7k-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef struct {
void simple_hfa(HFA h) {}

// CHECK: define{{.*}} %struct.HFA @return_simple_hfa
HFA return_simple_hfa() {}
HFA return_simple_hfa() { return (HFA){0}; }

typedef struct {
double arr[4];
Expand All @@ -43,7 +43,7 @@ typedef struct {
void big_struct_indirect(BigStruct b) {}

// CHECK: define{{.*}} void @return_big_struct_indirect(ptr dead_on_unwind noalias writable sret
BigStruct return_big_struct_indirect() {}
BigStruct return_big_struct_indirect() { return (BigStruct){0}; }

// Structs smaller than 16 bytes should be passed directly, and coerced to
// either [N x i32] or [N x i64] depending on alignment requirements.
Expand All @@ -58,7 +58,7 @@ typedef struct {
void small_struct_direct(SmallStruct s) {}

// CHECK: define{{.*}} [4 x i32] @return_small_struct_direct()
SmallStruct return_small_struct_direct() {}
SmallStruct return_small_struct_direct() { return (SmallStruct){0}; }

typedef struct {
float x;
Expand All @@ -75,14 +75,14 @@ typedef struct {
} PaddedSmallStruct;

// CHECK: define{{.*}} i32 @return_padded_small_struct()
PaddedSmallStruct return_padded_small_struct() {}
PaddedSmallStruct return_padded_small_struct() { return (PaddedSmallStruct){0}; }

typedef struct {
char arr[7];
} OddlySizedStruct;

// CHECK: define{{.*}} [2 x i32] @return_oddly_sized_struct()
OddlySizedStruct return_oddly_sized_struct() {}
OddlySizedStruct return_oddly_sized_struct() { return (OddlySizedStruct){0}; }

// CHECK: define{{.*}} <4 x float> @test_va_arg_vec(ptr noundef %l)

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenOpenCL/atomics-cas-remarks-gfx90a.cl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum memory_scope {
// GFX90A-CAS: atomicrmw fadd ptr addrspace(1) {{.*}} syncscope("agent-one-as") monotonic
// GFX90A-CAS: atomicrmw fadd ptr addrspace(1) {{.*}} syncscope("one-as") monotonic
// GFX90A-CAS: atomicrmw fadd ptr addrspace(1) {{.*}} syncscope("wavefront-one-as") monotonic
float atomic_cas(__global atomic_float *d, float a) {
void atomic_cas(__global atomic_float *d, float a) {
float ret1 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_work_group);
float ret2 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_device);
float ret3 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_all_svm_devices);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Index/warning-flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int *bar(float *f) { return f; }
// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s
// RUN: c-index-test -test-load-source all -w -O4 %s 2>&1 | FileCheck -check-prefix=NOWARNINGS %s

// CHECK-BOTH-WARNINGS: warning: non-void function does not return a value
// CHECK-BOTH-WARNINGS: error: non-void function does not return a value
// CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'

// CHECK-SECOND-WARNING-NOT:non-void function does not return a value
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=random_tags=1 %run %t
// RUN: %clang_hwasan -Wno-error=return-type %s -o %t && %env_hwasan_opts=random_tags=1 %run %t

#include <pthread.h>
#include <sanitizer/hwasan_interface.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// UNSUPPORTED: target=thumb{{.*}}
// UNSUPPORTED: android

// RUN: %clangxx -fsanitize=return %gmlt -O2 -fno-omit-frame-pointer -fasynchronous-unwind-tables %s -o %t
// RUN: %clangxx -Wno-error=return-type -fsanitize=return %gmlt -O2 -fno-omit-frame-pointer -fasynchronous-unwind-tables %s -o %t
// RUN: %env_ubsan_opts=print_stacktrace=1:fast_unwind_on_fatal=0 not %run %t 2>&1 | FileCheck %s
// RUN: %env_ubsan_opts=print_stacktrace=1:fast_unwind_on_fatal=1 not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx -fsanitize=return %gmlt -O2 -fno-omit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables %s -o %t
// RUN: %clangxx -Wno-error=return-type -fsanitize=return %gmlt -O2 -fno-omit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables %s -o %t
// RUN: %env_ubsan_opts=print_stacktrace=1:fast_unwind_on_fatal=0 not %run %t 2>&1 | FileCheck %s
// RUN: %env_ubsan_opts=print_stacktrace=1:fast_unwind_on_fatal=1 not %run %t 2>&1 | FileCheck %s

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/ubsan/TestCases/Misc/missing_return.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsanitize=return %gmlt %s -O3 -o %t
// RUN: %clangxx -Wno-error=return-type -fsanitize=return %gmlt %s -O3 -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-STACKTRACE
// Error message does not exact what expected
Expand Down
Loading