summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-09-03 00:25:02 +0000
committerAnders Carlsson <andersca@mac.com>2010-09-03 00:25:02 +0000
commit5d1d7ae120c2c8e6cba5d2a712b33500a5aecc10 (patch)
tree0d94f03a157c06f8c5163dbe84739bf97e9bdd67
parent714bf175fdc84ec595ce10046259309d88944bfa (diff)
Get rid of the "functions declared 'noreturn' should have a 'void' result type" warning.
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
-rw-r--r--clang.xcodeproj/project.pbxproj7
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--lib/Sema/SemaType.cpp5
-rw-r--r--test/Analysis/misc-ps.m2
-rw-r--r--test/Sema/attr-noreturn.c2
-rw-r--r--test/Sema/block-return.c4
-rw-r--r--test/Sema/return-noreturn.c4
-rw-r--r--test/Sema/return.c2
-rw-r--r--test/Sema/warn-unreachable.c2
-rw-r--r--test/SemaCXX/attr-noreturn.cpp2
-rw-r--r--test/SemaCXX/warn-unreachable.cpp4
11 files changed, 18 insertions, 19 deletions
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index 5e464fe7b3..def722b45e 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -2039,7 +2039,14 @@
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 = "";
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index d3fdb8050b..390d22560e 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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">>;
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index bb2fb99033..20c909a8ea 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -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;
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 6727e7da3b..4fbaa49c11 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -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);
diff --git a/test/Sema/attr-noreturn.c b/test/Sema/attr-noreturn.c
index 927df7f412..5333a2c13f 100644
--- a/test/Sema/attr-noreturn.c
+++ b/test/Sema/attr-noreturn.c
@@ -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'}}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index d40cef18d2..5a4ec010d3 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -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}}
}
diff --git a/test/Sema/return-noreturn.c b/test/Sema/return-noreturn.c
index a7f4e6f216..ff43754a42 100644
--- a/test/Sema/return-noreturn.c
+++ b/test/Sema/return-noreturn.c
@@ -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}}
diff --git a/test/Sema/return.c b/test/Sema/return.c
index af78b41051..54c340634d 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -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());
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index 0d2efe95d6..10ed6961a5 100644
--- a/test/Sema/warn-unreachable.c
+++ b/test/Sema/warn-unreachable.c
@@ -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();
diff --git a/test/SemaCXX/attr-noreturn.cpp b/test/SemaCXX/attr-noreturn.cpp
index dbf73fbae8..b7d39992b8 100644
--- a/test/SemaCXX/attr-noreturn.cpp
+++ b/test/SemaCXX/attr-noreturn.cpp
@@ -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() {
diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp
index 827dc48ce7..f5601cd2df 100644
--- a/test/SemaCXX/warn-unreachable.cpp
+++ b/test/SemaCXX/warn-unreachable.cpp
@@ -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}}
}