]> granicus.if.org Git - clang/commitdiff
allow the noreturn attribute to be used in class methods
authorNuno Lopes <nunoplopes@sapo.pt>
Wed, 23 Dec 2009 23:40:33 +0000 (23:40 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Wed, 23 Dec 2009 23:40:33 +0000 (23:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/attr-noreturn.cpp

index f62d0aa6f9bda3ac743384bc091bcea29bff2195..b7584c311ed6daedec6717b21aa6ea25126a1099 100644 (file)
@@ -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.
index ae614ac194d47abb96d7e8ea6cabd17e15054855..b7d39992b8fb1f7ff7257cb1e067a4f4a55e973e 100644 (file)
@@ -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}}
+}