Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2009-04-17 14:53:47 -0400
committerMike Kucera2009-04-17 14:53:47 -0400
commitd849341ad44d8962c61c19a7977b48a0830f9e62 (patch)
tree78411e23ee6b49a41cf232f1b750aed5aa38a6a4 /xlc/org.eclipse.cdt.core.lrparser.xlc.tests
parentcb8fe367dd2c4ffeda055c5d5ba1ad16f2640903 (diff)
downloadorg.eclipse.cdt-d849341ad44d8962c61c19a7977b48a0830f9e62.tar.gz
org.eclipse.cdt-d849341ad44d8962c61c19a7977b48a0830f9e62.tar.xz
org.eclipse.cdt-d849341ad44d8962c61c19a7977b48a0830f9e62.zip
[272745] initial commit of XLC parser extensions testing plug-in
Diffstat (limited to 'xlc/org.eclipse.cdt.core.lrparser.xlc.tests')
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.classpath7
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.project28
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/META-INF/MANIFEST.MF13
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/about.html24
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/build.properties15
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/VectorExtensionsTest.java203
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCExtensionsTest.java268
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCParserTestSuite.java25
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCTestBase.java46
10 files changed, 637 insertions, 0 deletions
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.classpath b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.classpath
new file mode 100644
index 0000000000..64c5e31b7a
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.project b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.project
new file mode 100644
index 0000000000..78df19795f
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.core.lrparser.xlc.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..3b4cf4f033
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Mar 30 15:57:59 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..19e3fcd35d
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests
+Bundle-SymbolicName: org.eclipse.cdt.core.lrparser.xlc.tests
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.junit,
+ org.eclipse.cdt.core.lrparser;bundle-version="5.1.0",
+ org.eclipse.cdt.core.lrparser.xlc;bundle-version="1.0.0",
+ org.eclipse.cdt.core.tests;bundle-version="5.1.0",
+ org.eclipse.cdt.core;bundle-version="5.1.0",
+ org.eclipse.cdt.core.lrparser.tests;bundle-version="5.1.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0"
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/about.html b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/about.html
new file mode 100644
index 0000000000..3b35b65391
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>April 17, 2009</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/build.properties b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/build.properties
new file mode 100644
index 0000000000..6e948c2375
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/build.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/VectorExtensionsTest.java b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/VectorExtensionsTest.java
new file mode 100644
index 0000000000..da1d30aae8
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/VectorExtensionsTest.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser.xlc.tests;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+
+public class VectorExtensionsTest extends XLCTestBase {
+
+ public VectorExtensionsTest() {
+ }
+
+ public VectorExtensionsTest(String name) {
+ super(name);
+ }
+
+
+
+ public void testVector1() {
+ String code =
+ "int test() { \n" +
+ " vector unsigned int a = {1,2,3,4}; \n" +
+ " vector unsigned int b = {2,4,6,8}; \n" +
+ " vector unsigned int c = a + b; \n" +
+ " int e = b > a; \n" +
+ " int f = a[2]; \n" +
+ " vector unsigned int d = ++a; \n" +
+ "}\n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVectorDeclarations() {
+ String code =
+ "vector unsigned char a; \n" +
+ "vector signed char b; \n" +
+ "vector bool char c; \n" +
+ "vector unsigned short d; \n" +
+ "vector unsigned short int e; \n" +
+ "vector signed short f; \n" +
+ "vector signed short int g; \n" +
+ "vector bool short h; \n" +
+ "vector bool short int i; \n" +
+ "vector unsigned int j; \n" +
+ "vector unsigned long k; \n" +
+ "vector unsigned long int l; \n" +
+ "vector signed int m; \n" +
+ "vector signed long n; \n" +
+ "vector signed long int o; \n" +
+ "vector bool int p; \n" +
+ "vector bool long q; \n" +
+ "vector bool long int r; \n" +
+ "vector float s; \n" +
+ "vector pixel t; \n" +
+ "__vector __pixel u; \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ // these are only treated as keywords inside a vector declaration
+ public void testReservedWords() {
+ String code =
+ "int pixel; " +
+ "int bool; ";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+ public void testVectorLiterals() {
+ String code =
+ "int test() {" +
+ " (vector unsigned int)(10); " +
+ " (vector unsigned int)(14, 82, 73, 700); " +
+ " (vector pixel)(14, 82, 73, 700); " +
+ " (vector bool int)(10); " +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVectorInitializers() {
+ String code =
+ "int test() {" +
+ " vector unsigned int v3 = {1,2,3,4}; " +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+ public void testVectorTypedefs() {
+ String code =
+ "int test() {" +
+ " typedef vector pixel vint16; " +
+ " vint16 v1;" +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVectorCompoundLiterals() {
+ String code =
+ "int test() {" +
+ " (vector unsigned int){10}; " +
+ " (vector unsigned int){14, 82, 73, 700}; " +
+ " (vector pixel){14, 82, 73, 700}; " +
+ " (vector bool int){10}; " +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVectorAlignof() {
+ String code =
+ "int test() {" +
+ " vector unsigned int v1 = (vector unsigned int)(10); \n" +
+ " vector unsigned int *pv1 = &v1; \n" +
+ " __alignof__(v1); \n" +
+ " __alignof__(&v1); \n" +
+ " __alignof__(*pv1); \n" +
+ " __alignof__(pv1); \n" +
+ " __alignof__(vector signed char); \n" +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVectorTypeof() {
+ String code =
+ "int test() {" +
+ " vector unsigned int v1 = (vector unsigned int)(10); \n" +
+ " vector unsigned int *pv1 = &v1; \n" +
+ " __typeof__(v1); \n" +
+ " __typeof__(&v1); \n" +
+ " __typeof__(*pv1); \n" +
+ " __typeof__(pv1); \n" +
+ " __typeof__(vector signed char); \n" +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void _testOverloads() {
+ String code =
+ "void foo(int); \n" +
+ "void foo(vector unsigned int); \n" +
+ "void foo(vector pixel) \n" +
+ "int test() { \n" +
+ " int x; \n" +
+ " vector unsigned int y; \n" +
+ " vector pixel z; \n" +
+ " foo(x); \n" +
+ " foo(y); \n" +
+ " foo(z); \n" +
+ "} \n";
+
+ IASTTranslationUnit tu = parse(code, getCPPLanguage(), true);
+
+
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTName foo1 = ((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getName();
+ IASTName foo2 = ((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getName();
+ IASTName foo3 = ((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getName();
+
+ IASTFunctionDefinition func = (IASTFunctionDefinition) decls[4];
+ IASTStatement[] stats = ((IASTCompoundStatement)func.getBody()).getStatements();
+
+ IASTName fooCall1 = ((IASTIdExpression)((IASTFunctionCallExpression)((IASTExpressionStatement)stats[3]).getExpression()).getFunctionNameExpression()).getName();
+ IASTName fooCall2 = ((IASTIdExpression)((IASTFunctionCallExpression)((IASTExpressionStatement)stats[4]).getExpression()).getFunctionNameExpression()).getName();
+ IASTName fooCall3 = ((IASTIdExpression)((IASTFunctionCallExpression)((IASTExpressionStatement)stats[5]).getExpression()).getFunctionNameExpression()).getName();
+
+ assertSame(foo1.resolveBinding(), fooCall1.resolveBinding());
+ assertSame(foo2.resolveBinding(), fooCall2.resolveBinding());
+ assertSame(foo3.resolveBinding(), fooCall3.resolveBinding());
+ }
+}
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCExtensionsTest.java b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCExtensionsTest.java
new file mode 100644
index 0000000000..2a90e5d129
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCExtensionsTest.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser.xlc.tests;
+
+
+public class XLCExtensionsTest extends XLCTestBase {
+
+ public XLCExtensionsTest() {
+ }
+
+ public XLCExtensionsTest(String name) {
+ super(name);
+ }
+
+ public void testHexadecimalFloatingPointLiterals() throws Exception {
+ String code =
+ "int test() { \n"+
+ " 0x0A2B.0FDp+2f; \n"+
+ " 0X12D.p-44F; \n"+
+ " 0xBACP+2L; \n"+
+ "}\n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testFuncPredefinedIdentifier() {
+ String code =
+ "void test() { \n" +
+ " __func__; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testStringConcatenation() {
+ String code =
+ "void test() { \n" +
+ " \"hello \" \"there\"; \n" +
+ " \"hello \" L\"there\"; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testLongLong() {
+ String code =
+ "void test() { \n" +
+ " long long x; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testComplex() {
+ String code =
+ "void test() { \n" +
+ " float _Complex x; \n" +
+ " double _Complex y; \n" +
+ " long double _Complex z; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testBool() {
+ String code =
+ "_Bool f(int a, int b) { \n" +
+ " return a==b; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testTrailingCommaInEnum() {
+ String code =
+ "void test() { \n" +
+ " enum grain { oats, wheat, barley, corn, rice, }; \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+ public void testNonLValueArraySubscript() {
+ String code =
+ "struct trio{int a[3];}; \n" +
+ "struct trio f(); \n" +
+ "foo (int index) \n" +
+ "{ \n" +
+ " return f().a[index]; \n" +
+ "} \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testStaticArrayIndices() {
+ String code =
+ "void test() { \n" +
+ " void foo1(int arr [static 10]); \n" +
+ " int i = 10; \n" +
+ " void foo2(int arr [static const i]); \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testFunctionLikeMacrosVariableArguments() {
+ String code =
+ "#define debug(...) fprintf(stderr, __VA_ARGS__) \n" +
+ "int test() { \n" +
+ " debug(\"flag\"); \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), false);
+ }
+
+ public void testFunctionLikeMacrosEmptyArgument() {
+ String code =
+ "#define SUM(a,b,c) a + b + c \n" +
+ "int test() { \n" +
+ " SUM(1,,3); \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testPredefinedMacroNamesC() {
+ String code =
+ "void test() { \n" +
+ " __DATE__; \n" +
+ " __FILE__; \n" +
+ " __LINE__; \n" +
+ " __STDC_HOSTED__; \n" +
+ " __STDC_VERSION__; \n" +
+ " __TIME__; \n" +
+ "} \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testPredefinedMacroNamesCpp() {
+ String code =
+ "void test() { \n" +
+ " __DATE__; \n" +
+ " __FILE__; \n" +
+ " __LINE__; \n" +
+ " __TIME__; \n" +
+ // " __cplusplus; \n" +
+ "} \n";
+
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+ public void testCompoundLiterals() {
+ String code =
+ "void test() { \n" +
+ " drawline((struct point){6,7}); \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), false);
+ }
+
+
+
+ public void testPragma() {
+ String code =
+ "void test() { \n" +
+ " _Pragma ( \"pack(full)\" ) \n" +
+ " } \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+
+ public void testStandardPragmas() {
+ String code =
+ "#pragma STDC FP_CONTRACT ON \n" +
+ "#pragma STDC FENV_ACCESS OFF \n" +
+ "#pragma STDC CX_LIMITED_RANGE DEFAULT \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+ public void testLineDirective() {
+ String code =
+ "#define LINE200 200 \n" +
+ "#line 100 \n" +
+ "#line LINE200 \n";
+
+ parse(code, getCLanguage(), true);
+ }
+
+
+ /**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=228826
+ * http://publib.boulder.ibm.com/infocenter/comphelp/v101v121/index.jsp?topic=/com.ibm.xlcpp101.aix.doc/language_ref/restrict_type_qualifier.html
+ *
+ * TODO Need a properties page so that things like this can be configured by the user.
+ */
+ public void testRestrictC() {
+ String code =
+ "void foo(int n, int * restrict a, int * __restrict b, int * __restrict__ c) {} ";
+
+ parse(code, getCLanguage(), true);
+ }
+ public void testRestrictCPP() {
+ String code =
+ "void restrict(); \n " +
+ "void __restrict(); \n " +
+ "void __restrict__(); \n ";
+
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+
+ public void testUTFLiterals() {
+ String code =
+ "void test() { \n " +
+ " u\"ucs characters \\u1234 and \\u8180 \"; \n " +
+ " U\"ucs characters \\u1234 and \\u8180 \"; \n " +
+ " U\"concatenation \\u1234 \" u\"is allowed \\u8180 \"; \n " +
+ " u'\\u1234'; \n " +
+ " U'\\u1234'; \n " +
+ "}";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+
+ public void testFloatingPoingTypes() {
+ String code =
+ " _Decimal32 x = 22.2df; \n " +
+ " _Decimal64 y = 33.3dd; \n " +
+ " _Decimal128 z = 33.3dl; \n ";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true);
+ }
+
+ public void testVariableLengthArrays() {
+ String code =
+ "double maximum1(int n, int m, double a[n][m]);\n" +
+ "double maximum2(int n, int m, double a[*][*]);\n" +
+ "double maximum3(int n, int m, double a[ ][*]);\n" +
+ "double maximum4(int n, int m, double a[ ][m]);\n";
+
+ parse(code, getCLanguage(), true);
+ parse(code, getCPPLanguage(), true); // xlc supports this in C++
+ }
+
+}
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCParserTestSuite.java b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCParserTestSuite.java
new file mode 100644
index 0000000000..933bffbc08
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCParserTestSuite.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser.xlc.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class XLCParserTestSuite {
+
+
+ public static Test suite() {
+ return new TestSuite() {{
+ addTestSuite(VectorExtensionsTest.class);
+ addTestSuite(XLCExtensionsTest.class);
+ }};
+ }
+} \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCTestBase.java b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCTestBase.java
new file mode 100644
index 0000000000..5d6b8fe4b7
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/src/org/eclipse/cdt/core/parser/xlc/tests/XLCTestBase.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser.xlc.tests;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.lrparser.tests.ParseHelper;
+import org.eclipse.cdt.core.lrparser.xlc.XlcCLanguage;
+import org.eclipse.cdt.core.lrparser.xlc.XlcCPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
+
+public class XLCTestBase extends TestCase {
+
+ public XLCTestBase() {
+ }
+
+ public XLCTestBase(String name) {
+ super(name);
+ }
+
+ protected IASTTranslationUnit parse(String code, ILanguage language, boolean checkBindings) {
+ ParseHelper.Options options = new ParseHelper.Options();
+ options.setCheckSyntaxProblems(true);
+ options.setCheckPreprocessorProblems(true);
+ options.setCheckBindings(checkBindings);
+ return ParseHelper.parse(code, language, options);
+ }
+
+ protected XlcCLanguage getCLanguage() {
+ return XlcCLanguage.getDefault();
+ }
+
+ protected XlcCPPLanguage getCPPLanguage() {
+ return XlcCPPLanguage.getDefault();
+ }
+
+}

Back to the top