]> granicus.if.org Git - clang/commitdiff
fix PR7280 by making the warning on code like this:
authorChris Lattner <sabre@nondot.org>
Sun, 11 Jul 2010 23:34:02 +0000 (23:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 11 Jul 2010 23:34:02 +0000 (23:34 +0000)
int test1() {
  return;
}

default to an error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108108 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
test/Analysis/null-deref-ps.c
test/CodeGen/statements.c
test/Rewriter/dllimport-typedef.c
test/Rewriter/missing-dllimport.c
test/Sema/function.c
test/Sema/implicit-decl.c
test/Sema/return.c
test/SemaTemplate/instantiate-function-1.cpp

index e3792c1178aae74eb4b46f8e5d5b2ad6567891fa..10121d86828aafccdc464431003e50b89d3a7e7a 100644 (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">;
index eac7957fb9219b90cffa119b301895bf86b88cd2..7ca22ada7da7fd83684ea0ef84dc12ca5abfd859 100644 (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;
 
index e3835f062a6909fb44ccac6ec1c1569e9484615b..7ed82add69b0a9f488cf72a4528b3fafea36eca8 100644 (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) {
index b86fa4a1c7375e69815231921979b301a6d77d79..441f498668174febf95057a191dd2501a2e08543 100644 (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
 
index c060379db0fd91b6e38e5959a7aed3af6317af7b..1dfc04c5b80c39746df5ea7716a0eff9a774a89b 100644 (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
 
index 9a83519a90b52690470fab46c868e6f18fae702a..b51c137ce7dc2c6ddce5ad5b38943b2ac5e2db26 100644 (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>
index 830cde9b9f90d939b790c866473e45eb19c4abec..f455977536630b4a6a8dda70052184d41019526d 100644 (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;
index 0d46d981bed20f362e243524b86d05de99ed9e06..2d23e080396799eaaa6f7b22e78b510ccf71ba23 100644 (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 
index 1bda43000b2a571d2469db79695315091fae725f..a293e9a788decad494dd5972f449e1b0985cb79d 100644 (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}}
   }
 };