Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-04-13 14:36:38 -0400
committerSergey Prigogin2012-04-13 14:48:35 -0400
commit33374d0a517f3c40e03352b63ec4edc8885fb633 (patch)
treecab9a2541a7977cebf2ab5e9f6c3717e961cd194 /core/org.eclipse.cdt.core.tests
parentb9097cd175b8a61b156f24821ef9c811b42228f6 (diff)
downloadorg.eclipse.cdt-33374d0a517f3c40e03352b63ec4edc8885fb633.tar.gz
org.eclipse.cdt-33374d0a517f3c40e03352b63ec4edc8885fb633.tar.xz
org.eclipse.cdt-33374d0a517f3c40e03352b63ec4edc8885fb633.zip
Bug 316230 - Representation of gcc attributes in AST. Also
contains a fix for bug 330635. Change-Id: I11d872bd68dc0819a95ad8bf83c6db20fbc81387 Reviewed-on: https://git.eclipse.org/r/5554 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java50
1 files changed, 41 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 61ebef86f9..cbbaeb85a0 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -191,11 +191,11 @@ public class AST2CPPTests extends AST2BaseTest {
}
private void assertDefinition(ICPPBinding b) {
- assertTrue(((IASTName)((ICPPInternalBinding) b).getDefinition()).isDefinition());
+ assertTrue(((IASTName) ((ICPPInternalBinding) b).getDefinition()).isDefinition());
}
private void assertDeclaration(ICPPBinding b) {
- assertTrue(((IASTName)((ICPPInternalBinding) b).getDeclarations()[0]).isDeclaration());
+ assertTrue(((IASTName) ((ICPPInternalBinding) b).getDeclarations()[0]).isDeclaration());
}
private ICPPMethod extractSingleMethod(IBinding[] bindings) {
@@ -4682,10 +4682,10 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
}
// class _A {
@@ -5396,7 +5396,7 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPASTFunctionDeclarator fdecl2= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2]).getDeclarators()[0];
IASTStatement[] stmts= ((IASTCompoundStatement) fdef.getBody()).getStatements();
- IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration)((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
+ IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
IASTName fnname1= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1]).getExpression()).getFunctionNameExpression()).getName();
IASTName fnname2= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2]).getExpression()).getFunctionNameExpression()).getName();
@@ -5906,8 +5906,8 @@ public class AST2CPPTests extends AST2BaseTest {
IType t1= ((IPointerType)pt1.getType().getParameterTypes()[0]).getType();
IQualifierType t2= (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
- IQualifierType t3= (IQualifierType)((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
- IQualifierType t4= (IQualifierType)((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
+ IQualifierType t3= (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
+ IQualifierType t4= (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
assertTrue(!(t1 instanceof IQualifierType));
assertTrue(t2.isConst()); assertTrue(!t2.isVolatile());
@@ -9559,4 +9559,36 @@ public class AST2CPPTests extends AST2BaseTest {
p= getDeclaration(S, 2);
p= getDeclaration(S, 3);
}
+
+ // typedef int int8_t __attribute__ ((__mode__ (__QI__)));
+ // typedef int int16_t __attribute__ ((__mode__ (__HI__)));
+ // typedef int int32_t __attribute__ ((__mode__ (__SI__)));
+ // typedef int int64_t __attribute__ ((__mode__ (__DI__)));
+ // typedef int word_t __attribute__ ((__mode__ (__word__)));
+ // void f(int8_t*) {}
+ // void f(int16_t*) {}
+ // void f(int32_t*) {}
+ // void f(int64_t*) {}
+ // void f(word_t*) {}
+ // void test(signed char* i8, short* i16, int* i32, long long* i64, word_t* word) {
+ // f(i8);
+ // f(i16);
+ // f(i32);
+ // f(i64);
+ // f(word);
+ // }
+ public void testModeAttribute_330635() throws Exception {
+ BindingAssertionHelper bh= getAssertionHelper();
+ String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
+ ICPPFunction[] functions = new ICPPFunction[calls.length];
+ for (int i = 0; i < calls.length; i++) {
+ functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
+ }
+ for (int i = 0; i < functions.length; i++) {
+ for (int j = i + 1; j < functions.length; j++) {
+ assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function",
+ functions[i], functions[j]);
+ }
+ }
+ }
}

Back to the top