From: Reid Kleckner Date: Tue, 10 Sep 2013 22:21:37 +0000 (+0000) Subject: Ignore noreturn when checking function template specializations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8bcd4c8e5a867c52bef3837731e44b88eba6a36;p=clang Ignore noreturn when checking function template specializations As requested when applying the same logic to calling conventions. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1634 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190441 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index b6313307c4..d3223356ba 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -6415,12 +6415,15 @@ bool Sema::CheckFunctionTemplateSpecialization( } } - // Ignore differences in calling convention until decl merging. + // Ignore differences in calling convention and noreturn until decl + // merging. const FunctionProtoType *TmplFT = TmplFD->getType()->castAs(); - if (FPT->getCallConv() != TmplFT->getCallConv()) { + if (FPT->getCallConv() != TmplFT->getCallConv() || + FPT->getNoReturnAttr() != TmplFT->getNoReturnAttr()) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExtInfo = EPI.ExtInfo.withCallingConv(TmplFT->getCallConv()); + EPI.ExtInfo = EPI.ExtInfo.withNoReturn(TmplFT->getNoReturnAttr()); FT = Context.getFunctionType(FPT->getResultType(), FPT->getArgTypes(), EPI); } diff --git a/test/SemaTemplate/function-template-specialization-noreturn.cpp b/test/SemaTemplate/function-template-specialization-noreturn.cpp new file mode 100644 index 0000000000..3e1f61855a --- /dev/null +++ b/test/SemaTemplate/function-template-specialization-noreturn.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Split from function-template-specialization.cpp because the noreturn warning +// requires analysis-based warnings, which the other errors in that test case +// disable. + +template void __attribute__((noreturn)) f3() { __builtin_unreachable(); } +template <> void f3<1>() { } // expected-warning {{function declared 'noreturn' should not return}}