From: Chris Lattner Date: Sun, 11 Jul 2010 23:34:02 +0000 (+0000) Subject: fix PR7280 by making the warning on code like this: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=184aa4e6ded190bfb3bbe207040467f8d7e28a04;p=clang fix PR7280 by making the warning on code like this: int test1() { return; } default to an error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108108 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e3792c1178..10121d8682 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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; 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; 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; def ext_return_has_void_expr : Extension< "void %select{function|method}1 %0 should not return void expression">; diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index eac7957fb9..7ca22ada7d 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -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; diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c index e3835f062a..7ed82add69 100644 --- a/test/CodeGen/statements.c +++ b/test/CodeGen/statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 < %s -emit-llvm +// RUN: %clang_cc1 -Wreturn-type < %s -emit-llvm void test1(int x) { switch (x) { diff --git a/test/Rewriter/dllimport-typedef.c b/test/Rewriter/dllimport-typedef.c index b86fa4a1c7..441f498668 100644 --- a/test/Rewriter/dllimport-typedef.c +++ b/test/Rewriter/dllimport-typedef.c @@ -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 diff --git a/test/Rewriter/missing-dllimport.c b/test/Rewriter/missing-dllimport.c index c060379db0..1dfc04c5b8 100644 --- a/test/Rewriter/missing-dllimport.c +++ b/test/Rewriter/missing-dllimport.c @@ -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 diff --git a/test/Sema/function.c b/test/Sema/function.c index 9a83519a90..b51c137ce7 100644 --- a/test/Sema/function.c +++ b/test/Sema/function.c @@ -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}} } // diff --git a/test/Sema/implicit-decl.c b/test/Sema/implicit-decl.c index 830cde9b9f..f455977536 100644 --- a/test/Sema/implicit-decl.c +++ b/test/Sema/implicit-decl.c @@ -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; diff --git a/test/Sema/return.c b/test/Sema/return.c index 0d46d981be..2d23e08039 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -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 diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp index 1bda43000b..a293e9a788 100644 --- a/test/SemaTemplate/instantiate-function-1.cpp +++ b/test/SemaTemplate/instantiate-function-1.cpp @@ -39,11 +39,11 @@ template struct X3; template 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}} } };