]> granicus.if.org Git - clang/commitdiff
Get rid of the "functions declared 'noreturn' should have a 'void' result type" warning.
authorAnders Carlsson <andersca@mac.com>
Fri, 3 Sep 2010 00:25:02 +0000 (00:25 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 3 Sep 2010 00:25:02 +0000 (00:25 +0000)
The rationale behind this is that it is normal for callback functions to have a non-void return type
and it should still be possible to mark them noreturn. (JavaScriptCore is a good example of this).

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

clang.xcodeproj/project.pbxproj
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaType.cpp
test/Analysis/misc-ps.m
test/Sema/attr-noreturn.c
test/Sema/block-return.c
test/Sema/return-noreturn.c
test/Sema/return.c
test/Sema/warn-unreachable.c
test/SemaCXX/attr-noreturn.cpp
test/SemaCXX/warn-unreachable.cpp

index 5e464fe7b3d1a2b474344d4940f4c9f51fb3a803..def722b45e463c55b4f4ac94bb02bbf68520f5b7 100644 (file)
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
                        compatibilityVersion = "Xcode 2.4";
+                       developmentRegion = English;
                        hasScannedForEncodings = 1;
+                       knownRegions = (
+                               English,
+                               Japanese,
+                               French,
+                               German,
+                       );
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
                        projectRoot = "";
index d3fdb8050ba5b152ffc5afeb140f9ac5178beb58..390d22560ee8e3ba871eec97c75ac52d1885d710 100644 (file)
@@ -3145,9 +3145,6 @@ def ext_return_has_void_expr : Extension<
 def warn_noreturn_function_has_return_expr : Warning<
   "function %0 declared 'noreturn' should not return">,
   InGroup<DiagGroup<"invalid-noreturn">>;
-def warn_noreturn_function_has_nonvoid_result : Warning<
-  "%select{functions|blocks}0 declared 'noreturn' should have a 'void' result type">,
-  InGroup<DiagGroup<"invalid-noreturn">>;
 def warn_falloff_noreturn_function : Warning<
   "function declared 'noreturn' should not return">,
   InGroup<DiagGroup<"invalid-noreturn">>;
index bb2fb99033040a9cc2a4e343a5792aa4cdbb20e7..20c909a8ea43ca6839603061db3279910639dc9f 100644 (file)
@@ -1850,11 +1850,6 @@ bool ProcessFnAttr(Sema &S, QualType &Type, const AttributeList &Attr) {
         && !Type->isMemberFunctionPointerType())
       return true;
     
-    if (!GetResultType(Type)->isVoidType()) {
-      S.Diag(Attr.getLoc(), diag::warn_noreturn_function_has_nonvoid_result)
-        << (Type->isBlockPointerType() ? /* blocks */ 1 : /* functions */ 0);
-    }
-    
     // Otherwise we can process right away.
     Type = S.Context.getNoReturnType(Type);
     return false;
index 6727e7da3bba6237463c20def9499a3a50f04b62..4fbaa49c11682348e6f5b3c0277df9a105637f78 100644 (file)
@@ -323,7 +323,7 @@ int test_invalidate_by_ref() {
 // was the block containing the merge for '?', which would trigger an
 // assertion failure.
 int rdar_7027684_aux();
-int rdar_7027684_aux_2() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+int rdar_7027684_aux_2() __attribute__((noreturn));
 void rdar_7027684(int x, int y) {
   {}; // this empty compound statement is critical.
   (rdar_7027684_aux() ? rdar_7027684_aux_2() : (void) 0);
index 927df7f41224fa6450b20aa51fae93e2b3b40158..5333a2c13fc28e7d13473360b0baeb483a5c5343 100644 (file)
@@ -9,7 +9,7 @@ static void __attribute__((noreturn)) f0(void) {
 } // expected-warning {{function declared 'noreturn' should not return}}
 
 // On K&R
-int f1() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+int f1() __attribute__((noreturn));
 
 int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}}
 
index d40cef18d2112d8b59c5e0d022dc9ad1c42febfd..5a4ec010d3a2113b358e1f9fc8024ac7daf35323 100644 (file)
@@ -100,10 +100,10 @@ int (*funcptr3[5])(long);
 int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block declared as returning an array}}
 
 void foo6() {
-  int (^b)(int) __attribute__((noreturn)); // expected-warning{{blocks declared 'noreturn' should have a 'void' result type}}
+  int (^b)(int) __attribute__((noreturn));
   b = ^ (int i) __attribute__((noreturn)) { return 1; };  // expected-error {{block declared 'noreturn' should not return}}
   b(1);
-  int (^c)(void) __attribute__((noreturn)) = ^ __attribute__((noreturn)) { return 100; }; // expected-error {{block declared 'noreturn' should not return}} expected-warning{{blocks declared 'noreturn' should have a 'void' result type}}
+  int (^c)(void) __attribute__((noreturn)) = ^ __attribute__((noreturn)) { return 100; }; // expected-error {{block declared 'noreturn' should not return}}
 }
 
 
index a7f4e6f21634fe201151c869ecadee87a7646c4e..ff43754a429941802ef2d20d67dd11a5cbc6e2d8 100644 (file)
@@ -20,11 +20,11 @@ void test2_positive() {
 // This test case illustrates that we don't warn about the missing return
 // because the function is marked noreturn and there is an infinite loop.
 extern int foo_test_3();
-__attribute__((__noreturn__)) void* test3(int arg) { // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+__attribute__((__noreturn__)) void* test3(int arg) {
   while (1) foo_test_3();
 }
 
-__attribute__((__noreturn__)) void* test3_positive(int arg) { // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+__attribute__((__noreturn__)) void* test3_positive(int arg) {
   while (0) foo_test_3();
 } // expected-warning{{function declared 'noreturn' should not return}}
 
index af78b410512559ea7bef71982787bef8b346732d..54c340634d39850d7907aaf346f93930f62e5666 100644 (file)
@@ -60,7 +60,7 @@ int test8() {
   (void)(1 + unknown());
 } // expected-warning {{control reaches end of non-void function}}
 
-int halt3() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+int halt3() __attribute__((noreturn));
 
 int test9() {
   (void)(halt3() + unknown());
index 0d2efe95d6634a7a16ae03742420d6c85c4f35ce..10ed6961a556285c72d68fe67ad2712a9953ca35 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
 
-int halt() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+int halt() __attribute__((noreturn));
 int live();
 int dead();
 
index dbf73fbae8c10424ed7e81fe7aec5c94ee74d31e..b7d39992b8fb1f7ff7257cb1e067a4f4a55e973e 100644 (file)
@@ -31,7 +31,7 @@ void test_f3() {
 
 
 class xpto {
-  int blah() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+  int blah() __attribute__((noreturn));
 };
 
 int xpto::blah() {
index 827dc48ce7c869bd9a5c53eb2e9efe90929c5364..f5601cd2df08156e0065482d37a89047d8fb4c13 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
 
-int &halt() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+int &halt() __attribute__((noreturn));
 int &live();
 int dead();
 int liveti() throw(int);
@@ -60,7 +60,7 @@ void test5() {
   struct S {
     int mem;
   } s;
-  S &foor() __attribute__((noreturn)); // expected-warning{{functions declared 'noreturn' should have a 'void' result type}}
+  S &foor() __attribute__((noreturn));
   foor()
     .mem;       // expected-warning {{will never be executed}}
 }