diff options
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaTemplate/function-template-specialization-noreturn.cpp | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index b6313307c42..d3223356baa 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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<FunctionProtoType>(); - 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/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp b/clang/test/SemaTemplate/function-template-specialization-noreturn.cpp new file mode 100644 index 00000000000..3e1f61855a5 --- /dev/null +++ b/clang/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 <int N> void __attribute__((noreturn)) f3() { __builtin_unreachable(); } +template <> void f3<1>() { } // expected-warning {{function declared 'noreturn' should not return}} |