diff options
author | Thomas Corbat | 2017-05-08 09:41:26 +0000 |
---|---|---|
committer | Thomas Corbat | 2017-05-08 17:23:13 +0000 |
commit | 0f27b20848e526bfddea0de20693696885cb214d (patch) | |
tree | 5d7434ceae1a1fc8039771dfca333751a11e8883 /core/org.eclipse.cdt.core.tests | |
parent | fb898b608824b0a4354adce9c5611808d879ba8d (diff) | |
download | org.eclipse.cdt-0f27b20848e526bfddea0de20693696885cb214d.tar.gz org.eclipse.cdt-0f27b20848e526bfddea0de20693696885cb214d.tar.xz org.eclipse.cdt-0f27b20848e526bfddea0de20693696885cb214d.zip |
Bug 516298 - Improved recognition of [[noreturn]] attribute
Change-Id: I275f0ee38045600c104d5ed7e2c14fec04eac046
Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
3 files changed, 35 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java index ad6089ffa2a..1e27f21c3bc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java @@ -278,11 +278,31 @@ public class AST2CPPAttributeTests extends AST2TestBase { // void foo() throw(char const *) [[noreturn]] -> void { // throw "exception"; // } - public void testAttributedFunction() throws Exception { + public void testTrailingNoreturnFunctionDefinition() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); } + // [[noreturn]] void foo() throw(char const *) { + // throw "exception"; + // } + public void testLeadingNoreturnFunctionDefinition() throws Exception { + IASTTranslationUnit tu = parseAndCheckBindings(); + checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDefinition.class); + } + + // void foo() throw(char const *) [[noreturn]]; + public void testTrailingNoReturnFunctionDeclaration() throws Exception { + IASTTranslationUnit tu = parseAndCheckBindings(); + checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); + } + + // [[noreturn]] void foo() throw(char const *); + public void testLeadingNoReturnFunctionDeclaration() throws Exception { + IASTTranslationUnit tu = parseAndCheckBindings(); + checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); + } + // class [[attr]] C{}; public void testAttributedClass() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java index 183e57b11a8..0b85c3fc359 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java @@ -143,12 +143,20 @@ public class CPPFunctionTests extends PDOMTestBase { assertTrue(((ICPPFunction) bindings[0]).takesVarArgs()); } - public void testNoReturnCPPFunction() throws Exception { - IBinding[] bindings = findQualifiedName(pdom, "noReturnCPPFunction"); + private void assertNoReturnFunction(String functionName) throws CoreException { + IBinding[] bindings = findQualifiedName(pdom, functionName); assertEquals(1, bindings.length); assertTrue(((ICPPFunction) bindings[0]).isNoReturn()); } + public void testNoReturnCPPFunction() throws Exception { + assertNoReturnFunction("noReturnCPPFunction"); + assertNoReturnFunction("trailingNoReturnStdAttributeDecl"); + assertNoReturnFunction("leadingNoReturnStdAttributeDecl"); + assertNoReturnFunction("trailingNoReturnStdAttributeDef"); + assertNoReturnFunction("leadingNoReturnStdAttributeDef"); + } + public void testForwardDeclarationType() throws Exception { assertType(pdom, "forwardDeclaration", ICPPFunction.class); } diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp index 3f9d5b91370..e64112ba4c5 100644 --- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp @@ -5,6 +5,10 @@ extern float externCPPFunction(int p1); inline void inlineCPPFunction(long p1); void varArgsCPPFunction(int p1, ...); void noReturnCPPFunction() __attribute__((noreturn)); +[[noreturn]] void trailingNoReturnStdAttributeDecl(); +void leadingNoReturnStdAttributeDecl() [[noreturn]]; +[[noreturn]] void trailingNoReturnStdAttributeDef(){} +void leadingNoReturnStdAttributeDef() [[noreturn]]{} void voidCPPFunction(); int intCPPFunction(); |