From: Nuno Lopes Date: Wed, 23 Dec 2009 23:40:33 +0000 (+0000) Subject: allow the noreturn attribute to be used in class methods X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f75b8309e3e40290683e3d34bac3a04e88d9c625;p=clang allow the noreturn attribute to be used in class methods git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92090 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f62d0aa6f9..b7584c311e 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -929,7 +929,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { // (C++98 8.3.5p3): // All declarations for a function shall agree exactly in both the // return type and the parameter-type-list. - if (OldQType == NewQType) + // attributes should be ignored when comparing. + if (Context.getNoReturnType(OldQType, false) == + Context.getNoReturnType(NewQType, false)) return MergeCompatibleFunctionDecls(New, Old); // Fall through for conflicting redeclarations and redefinitions. diff --git a/test/SemaCXX/attr-noreturn.cpp b/test/SemaCXX/attr-noreturn.cpp index ae614ac194..b7d39992b8 100644 --- a/test/SemaCXX/attr-noreturn.cpp +++ b/test/SemaCXX/attr-noreturn.cpp @@ -28,3 +28,12 @@ void test_f3() { f3(f0); // okay f3(f2); // expected-error{{no matching function for call}} } + + +class xpto { + int blah() __attribute__((noreturn)); +}; + +int xpto::blah() { + return 3; // expected-warning {{function 'blah' declared 'noreturn' should not return}} +}