- 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}}
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}}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits