[PATCH] Ignore noreturn when checking function template specializations
Reid Kleckner
rnk at google.com
Tue Sep 10 15:12:44 PDT 2013
- Split out noreturn specialization test case to test the warning.
Hi rsmith,
http://llvm-reviews.chandlerc.com/D1634
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1634?vs=4155&id=4180#toc
Files:
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/function-template-specialization-noreturn.cpp
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6415,12 +6415,15 @@
}
}
- // 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);
}
Index: test/SemaTemplate/function-template-specialization-noreturn.cpp
===================================================================
--- /dev/null
+++ 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}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1634.2.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130910/3895138e/attachment.bin>
More information about the cfe-commits
mailing list