mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 545562 - Fix return checker check for template functions
Change-Id: Ie5e3d4560cb3784f6c8393290d64794db56294d7 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
e70a63a424
commit
f2635eed74
3 changed files with 16 additions and 7 deletions
|
@ -504,4 +504,15 @@ public class ReturnCheckerTest extends CheckerTestCase {
|
|||
public void testFunctionWithAttribute_519105() throws Exception {
|
||||
checkSampleAboveCpp();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// [[noreturn]] void foo(const T& e) {
|
||||
// throw e;
|
||||
// }
|
||||
// int bar() {
|
||||
// foo<int>(5);
|
||||
// }
|
||||
public void testTemplateFunctionNoReturn() throws Exception {
|
||||
checkSampleAboveCpp();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -734,7 +734,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
ICPPASTFunctionDeclarator dtor = getPreferredDtor();
|
||||
return isNoReturn(getPreferredDtor());
|
||||
}
|
||||
|
||||
public static boolean isNoReturn(ICPPASTFunctionDeclarator dtor) {
|
||||
if (dtor == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.parser.util.AttributeUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
@ -390,11 +389,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
|
|||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
ICPPASTFunctionDeclarator fdecl = getFirstFunctionDtor();
|
||||
if (fdecl != null) {
|
||||
return AttributeUtil.hasNoreturnAttribute(fdecl);
|
||||
}
|
||||
return false;
|
||||
return CPPFunction.isNoReturn(getFirstFunctionDtor());
|
||||
}
|
||||
|
||||
private IASTDeclarator getDeclaratorByName(IASTNode node) {
|
||||
|
|
Loading…
Add table
Reference in a new issue