mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Tests 2_3s2 and 6_10_3_5s5 from the cpp-spec are passing with CPreprocessor.
This commit is contained in:
parent
7411260aef
commit
8cd6358322
4 changed files with 62 additions and 69 deletions
|
@ -30,26 +30,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
|
|||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(CPP 2.3-2):
|
||||
??=define arraycheck(a,b) a??(b??) ??!??! b??(a??)
|
||||
// becomes
|
||||
#define arraycheck(a,b) a[b] || b[a]
|
||||
--End Example]
|
||||
*/
|
||||
public void test2_3s2() { // TODO exists bug 64993
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("??=define arraycheck(a,b) a??(b??) ??!??! b??(a??)\n"); //$NON-NLS-1$
|
||||
buffer.append("// becomes\n"); //$NON-NLS-1$
|
||||
buffer.append("#define arraycheck(a,b) a[b] || b[a]\n"); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
assertTrue(false);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(CPP 6.4-3):
|
||||
int foo() {
|
||||
|
|
|
@ -69,6 +69,22 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(CPP 2.3-2):
|
||||
??=define arraycheck(a,b) a??(b??) ??!??! b??(a??)
|
||||
// becomes
|
||||
#define arraycheck(a,b) a[b] || b[a]
|
||||
--End Example]
|
||||
*/
|
||||
public void test2_3s2() throws Exception { // TODO exists bug 64993
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("??=define arraycheck(a,b) a??(b??) ??!??! b??(a??)\n"); //$NON-NLS-1$
|
||||
buffer.append("// becomes\n"); //$NON-NLS-1$
|
||||
buffer.append("#define arraycheck(a,b) a[b] || b[a]\n"); //$NON-NLS-1$
|
||||
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(CPP 3.1-3):
|
||||
int a; // defines a
|
||||
|
|
|
@ -53,52 +53,4 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
|
|||
assertTrue(false);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(C 6.10.3.5-5):
|
||||
#define x 3
|
||||
#define f(a) f(x * (a))
|
||||
#undef x
|
||||
#define x 2
|
||||
#define g f
|
||||
#define z z[0]
|
||||
#define h g(~
|
||||
#define m(a) a(w)
|
||||
#define w 0,1
|
||||
#define t(a) a
|
||||
#define p() int
|
||||
#define q(x) x
|
||||
#define r(x,y) x ## y
|
||||
#define str(x) # x
|
||||
int foo() {
|
||||
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
|
||||
char c[2][6] = { str(hello), str() };
|
||||
}
|
||||
--End Example]
|
||||
*/
|
||||
public void test6_10_3_5s5() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#define x 3\n"); //$NON-NLS-1$
|
||||
buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
|
||||
buffer.append("#undef x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define x 2\n"); //$NON-NLS-1$
|
||||
buffer.append("#define g f\n"); //$NON-NLS-1$
|
||||
buffer.append("#define z z[0]\n"); //$NON-NLS-1$
|
||||
buffer.append("#define h g(~\n"); //$NON-NLS-1$
|
||||
buffer.append("#define m(a) a(w)\n"); //$NON-NLS-1$
|
||||
buffer.append("#define w 0,1\n"); //$NON-NLS-1$
|
||||
buffer.append("#define t(a) a\n"); //$NON-NLS-1$
|
||||
buffer.append("#define p() int\n"); //$NON-NLS-1$
|
||||
buffer.append("#define q(x) x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define r(x,y) x ## y\n"); //$NON-NLS-1$
|
||||
buffer.append("#define str(x) # x\n"); //$NON-NLS-1$
|
||||
buffer.append("int foo() {\n"); //$NON-NLS-1$
|
||||
buffer.append("p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\n"); //$NON-NLS-1$
|
||||
buffer.append("char c[2][6] = { str(hello), str() };\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
try {
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
assertTrue(false);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1911,6 +1911,51 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(C 6.10.3.5-5):
|
||||
#define x 3
|
||||
#define f(a) f(x * (a))
|
||||
#undef x
|
||||
#define x 2
|
||||
#define g f
|
||||
#define z z[0]
|
||||
#define h g(~
|
||||
#define m(a) a(w)
|
||||
#define w 0,1
|
||||
#define t(a) a
|
||||
#define p() int
|
||||
#define q(x) x
|
||||
#define r(x,y) x ## y
|
||||
#define str(x) # x
|
||||
int foo() {
|
||||
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
|
||||
char c[2][6] = { str(hello), str() };
|
||||
}
|
||||
--End Example]
|
||||
*/
|
||||
public void test6_10_3_5s5() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("#define x 3\n"); //$NON-NLS-1$
|
||||
buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
|
||||
buffer.append("#undef x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define x 2\n"); //$NON-NLS-1$
|
||||
buffer.append("#define g f\n"); //$NON-NLS-1$
|
||||
buffer.append("#define z z[0]\n"); //$NON-NLS-1$
|
||||
buffer.append("#define h g(~\n"); //$NON-NLS-1$
|
||||
buffer.append("#define m(a) a(w)\n"); //$NON-NLS-1$
|
||||
buffer.append("#define w 0,1\n"); //$NON-NLS-1$
|
||||
buffer.append("#define t(a) a\n"); //$NON-NLS-1$
|
||||
buffer.append("#define p() int\n"); //$NON-NLS-1$
|
||||
buffer.append("#define q(x) x\n"); //$NON-NLS-1$
|
||||
buffer.append("#define r(x,y) x ## y\n"); //$NON-NLS-1$
|
||||
buffer.append("#define str(x) # x\n"); //$NON-NLS-1$
|
||||
buffer.append("int foo() {\n"); //$NON-NLS-1$
|
||||
buffer.append("p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\n"); //$NON-NLS-1$
|
||||
buffer.append("char c[2][6] = { str(hello), str() };\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
[--Start Example(C 6.10.3.5-6):
|
||||
#define str(s) # s
|
||||
|
|
Loading…
Add table
Reference in a new issue