fix PR7280 by making the warning on code like this:

int test1() {
  return;
}

default to an error.

llvm-svn: 108108
This commit is contained in:
Chris Lattner 2010-07-11 23:34:02 +00:00
parent b6df00c29a
commit 33919e7450
9 changed files with 21 additions and 22 deletions

View File

@ -3053,13 +3053,13 @@ def err_first_argument_to_va_arg_not_of_type_va_list : Error<
"first argument to 'va_arg' is of type %0 and not 'va_list'">;
def warn_return_missing_expr : Warning<
"non-void %select{function|method}1 %0 should return a value">,
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
InGroup<ReturnType>;
def ext_return_missing_expr : ExtWarn<
"non-void %select{function|method}1 %0 should return a value">,
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
InGroup<ReturnType>;
def ext_return_has_expr : ExtWarn<
"void %select{function|method}1 %0 should not return a value">,
"void %select{function|method}1 %0 should not return a value">, DefaultError,
InGroup<ReturnType>;
def ext_return_has_void_expr : Extension<
"void %select{function|method}1 %0 should not return void expression">;

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=basic -analyzer-store=basic
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=range -analyzer-store=basic
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-no-purge-dead -verify %s
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=basic -analyzer-store=basic -Wreturn-type
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=range -analyzer-store=basic -Wreturn-type
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-no-purge-dead -verify %s -Wreturn-type
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type
typedef unsigned uintptr_t;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 < %s -emit-llvm
// RUN: %clang_cc1 -Wreturn-type < %s -emit-llvm
void test1(int x) {
switch (x) {

View File

@ -9,9 +9,9 @@ typedef __declspec(dllimport) int CB(void);
// diagnostics we expect.
void bar() { return 1; }
// CHECK-NEG: warning: void function 'bar' should not return a value
// CHECK-NEG: 1 warning generated
// CHECK-NEG: error: void function 'bar' should not return a value
// CHECK-NEG: 1 error generated
// CHECK-POS: warning: 'dllimport' attribute only applies to variable and function type
// CHECK-POS: warning: void function 'bar' should not return a value
// CHECK-POS: 2 warnings generated
// CHECK-POS: error: void function 'bar' should not return a value
// CHECK-POS: 1 warning and 1 error generated

View File

@ -11,9 +11,9 @@ inline int __cdecl foo() { return 0; }
// diagnostics we expect.
void bar() { return 1; }
// CHECK-NEG: warning: void function 'bar' should not return a value
// CHECK-NEG: 1 warning generated
// CHECK-NEG: error: void function 'bar' should not return a value
// CHECK-NEG: 1 error generated
// CHECK-POS: warning: 'foo' redeclared without dllimport attribute: previous dllimport ignored
// CHECK-POS: warning: void function 'bar' should not return a value
// CHECK-POS: 2 warnings generated
// CHECK-POS: error: void function 'bar' should not return a value
// CHECK-POS: 1 warning and 1 error generated

View File

@ -34,10 +34,10 @@ void t12(int) {} // expected-error{{parameter name omitted}}
// PR2790
void t13() {
return 0; // expected-warning {{void function 't13' should not return a value}}
return 0; // expected-error {{void function 't13' should not return a value}}
}
int t14() {
return; // expected-warning {{non-void function 't14' should return a value}}
return; // expected-error {{non-void function 't14' should return a value}}
}
// <rdar://problem/6097326>

View File

@ -10,7 +10,6 @@ void func() {
if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
}
return ((void *)0); // expected-warning {{void function 'func' should not return a value}}
}
Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
return 0;

View File

@ -1,4 +1,4 @@
// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
// RUN: %clang %s -fsyntax-only -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the

View File

@ -39,11 +39,11 @@ template struct X3<int>;
template <typename T> struct X4 {
T f() const {
return; // expected-warning{{non-void function 'f' should return a value}}
return; // expected-error{{non-void function 'f' should return a value}}
}
T g() const {
return 1; // expected-warning{{void function 'g' should not return a value}}
return 1; // expected-error{{void function 'g' should not return a value}}
}
};