mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 15:35:24 +02:00
Bug 534332 - In the unused symbol checker, check for 'unused' attribute on the decl-specifier too
Change-Id: Ib4f26e5a04742af93c884819a5b2f1f714faeb97
This commit is contained in:
parent
d8d04e2731
commit
45bbb2bb5b
2 changed files with 8 additions and 0 deletions
|
@ -133,6 +133,10 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
|||
// declarations
|
||||
IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) element;
|
||||
|
||||
IASTDeclSpecifier declSpec = simpleDeclaration.getDeclSpecifier();
|
||||
if (AttributeUtil.hasAttribute(declSpec, ATTRIBUTE_UNUSED)) {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
|
||||
for (IASTDeclarator decl : declarators) {
|
||||
if (AttributeUtil.hasAttribute(decl, ATTRIBUTE_UNUSED))
|
||||
|
|
|
@ -306,6 +306,7 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// static int v1 __attribute__((unused));
|
||||
// static int __attribute__((unused)) v2;
|
||||
// int f1() __attribute__((__unused__));
|
||||
// extern int f2() __attribute__((unused));
|
||||
// static void f3() __attribute__((unused));
|
||||
|
@ -314,6 +315,9 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
|||
public void testAttributeUnused() throws Exception {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
|
||||
loadCodeAndRunCpp(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// extern int* pxCurrentTCB;
|
||||
|
|
Loading…
Add table
Reference in a new issue