diff options
author | Emil Velikov <[email protected]> | 2016-01-18 12:16:48 +0200 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-01-26 16:08:33 +0000 |
commit | eb63640c1d38a200a7b1540405051d3ff79d0d8a (patch) | |
tree | da46321a41f309b1d02aeb14d5d5487791c45aeb /src/compiler/glsl/glcpp/tests | |
parent | a39a8fbbaa129f4e52f2a3ad2747182e9a74d910 (diff) |
glsl: move to compiler/
Signed-off-by: Emil Velikov <[email protected]>
Acked-by: Matt Turner <[email protected]>
Acked-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glcpp/tests')
291 files changed, 2440 insertions, 0 deletions
diff --git a/src/compiler/glsl/glcpp/tests/.gitignore b/src/compiler/glsl/glcpp/tests/.gitignore new file mode 100644 index 00000000000..3802c850a3e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/.gitignore @@ -0,0 +1,4 @@ +subtest-cr/ +subtest-lf/ +subtest-cr-lf/ +subtest-lf-cr/ diff --git a/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c b/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c new file mode 100644 index 00000000000..1f2320e6fc1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c @@ -0,0 +1 @@ + this is four tokens with spaces diff --git a/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c.expected b/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c.expected new file mode 100644 index 00000000000..00791910ed5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/000-content-with-spaces.c.expected @@ -0,0 +1 @@ + this is four tokens with spaces diff --git a/src/compiler/glsl/glcpp/tests/001-define.c b/src/compiler/glsl/glcpp/tests/001-define.c new file mode 100644 index 00000000000..cbf2fee0e75 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/001-define.c @@ -0,0 +1,2 @@ +#define foo 1 +foo diff --git a/src/compiler/glsl/glcpp/tests/001-define.c.expected b/src/compiler/glsl/glcpp/tests/001-define.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/001-define.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/src/compiler/glsl/glcpp/tests/002-define-chain.c b/src/compiler/glsl/glcpp/tests/002-define-chain.c new file mode 100644 index 00000000000..87d75c68751 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/002-define-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar foo +bar diff --git a/src/compiler/glsl/glcpp/tests/002-define-chain.c.expected b/src/compiler/glsl/glcpp/tests/002-define-chain.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/002-define-chain.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c b/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c new file mode 100644 index 00000000000..a18b724eca0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar foo +#define foo 1 +bar diff --git a/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c.expected b/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/003-define-chain-reverse.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/src/compiler/glsl/glcpp/tests/004-define-recursive.c b/src/compiler/glsl/glcpp/tests/004-define-recursive.c new file mode 100644 index 00000000000..2ac56ea3dcf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/004-define-recursive.c @@ -0,0 +1,6 @@ +#define foo bar +#define bar baz +#define baz foo +foo +bar +baz diff --git a/src/compiler/glsl/glcpp/tests/004-define-recursive.c.expected b/src/compiler/glsl/glcpp/tests/004-define-recursive.c.expected new file mode 100644 index 00000000000..2d07687f8ca --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/004-define-recursive.c.expected @@ -0,0 +1,6 @@ + + + +foo +bar +baz diff --git a/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c b/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c new file mode 100644 index 00000000000..f5521df968d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar a foo +bar diff --git a/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c.expected b/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c.expected new file mode 100644 index 00000000000..892975c268c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/005-define-composite-chain.c.expected @@ -0,0 +1,3 @@ + + +a 1 diff --git a/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c b/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c new file mode 100644 index 00000000000..4bb91a1221a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar a foo +#define foo 1 +bar diff --git a/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected b/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected new file mode 100644 index 00000000000..892975c268c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected @@ -0,0 +1,3 @@ + + +a 1 diff --git a/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c b/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c new file mode 100644 index 00000000000..5784565bdf3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c @@ -0,0 +1,6 @@ +#define foo a bar +#define bar b baz +#define baz c foo +foo +bar +baz diff --git a/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c.expected b/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c.expected new file mode 100644 index 00000000000..0b0b477d9df --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/007-define-composite-recursive.c.expected @@ -0,0 +1,6 @@ + + + +a b c foo +b c a bar +c a b baz diff --git a/src/compiler/glsl/glcpp/tests/008-define-empty.c b/src/compiler/glsl/glcpp/tests/008-define-empty.c new file mode 100644 index 00000000000..b1bd17ec215 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/008-define-empty.c @@ -0,0 +1,2 @@ +#define foo +foo diff --git a/src/compiler/glsl/glcpp/tests/008-define-empty.c.expected b/src/compiler/glsl/glcpp/tests/008-define-empty.c.expected new file mode 100644 index 00000000000..d148bc8e800 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/008-define-empty.c.expected @@ -0,0 +1,2 @@ + + diff --git a/src/compiler/glsl/glcpp/tests/009-undef.c b/src/compiler/glsl/glcpp/tests/009-undef.c new file mode 100644 index 00000000000..3fc1fb44243 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/009-undef.c @@ -0,0 +1,4 @@ +#define foo 1 +foo +#undef foo +foo diff --git a/src/compiler/glsl/glcpp/tests/009-undef.c.expected b/src/compiler/glsl/glcpp/tests/009-undef.c.expected new file mode 100644 index 00000000000..9c0b35a4518 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/009-undef.c.expected @@ -0,0 +1,4 @@ + +1 + +foo diff --git a/src/compiler/glsl/glcpp/tests/010-undef-re-define.c b/src/compiler/glsl/glcpp/tests/010-undef-re-define.c new file mode 100644 index 00000000000..32ff73798b1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/010-undef-re-define.c @@ -0,0 +1,6 @@ +#define foo 1 +foo +#undef foo +foo +#define foo 2 +foo diff --git a/src/compiler/glsl/glcpp/tests/010-undef-re-define.c.expected b/src/compiler/glsl/glcpp/tests/010-undef-re-define.c.expected new file mode 100644 index 00000000000..5970f49028e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/010-undef-re-define.c.expected @@ -0,0 +1,6 @@ + +1 + +foo + +2 diff --git a/src/compiler/glsl/glcpp/tests/011-define-func-empty.c b/src/compiler/glsl/glcpp/tests/011-define-func-empty.c new file mode 100644 index 00000000000..d9ce13c2284 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/011-define-func-empty.c @@ -0,0 +1,2 @@ +#define foo() +foo() diff --git a/src/compiler/glsl/glcpp/tests/011-define-func-empty.c.expected b/src/compiler/glsl/glcpp/tests/011-define-func-empty.c.expected new file mode 100644 index 00000000000..d148bc8e800 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/011-define-func-empty.c.expected @@ -0,0 +1,2 @@ + + diff --git a/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c b/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c new file mode 100644 index 00000000000..c2bb730b115 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c @@ -0,0 +1,2 @@ +#define foo() bar +foo() diff --git a/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c.expected b/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c.expected new file mode 100644 index 00000000000..9f075f26004 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/012-define-func-no-args.c.expected @@ -0,0 +1,2 @@ + +bar diff --git a/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c b/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c new file mode 100644 index 00000000000..f78fb8b118a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x) 1 +foo(bar) diff --git a/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected b/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c b/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c new file mode 100644 index 00000000000..11feb2624b7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x,y) 1 +foo(bar,baz) diff --git a/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected b/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c b/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c new file mode 100644 index 00000000000..558da9c617b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c @@ -0,0 +1,4 @@ +#define foo ()1 +foo() +#define bar ()2 +bar() diff --git a/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c.expected b/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c.expected new file mode 100644 index 00000000000..a70321a4c51 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/015-define-object-with-parens.c.expected @@ -0,0 +1,4 @@ + +()1() + +()2() diff --git a/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c b/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c new file mode 100644 index 00000000000..a2e2404c7c1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c @@ -0,0 +1,2 @@ +#define foo(x) ((x)+1) +foo(bar) diff --git a/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c.expected b/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c.expected new file mode 100644 index 00000000000..6bfe04f7381 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/016-define-func-1-arg.c.expected @@ -0,0 +1,2 @@ + +((bar)+1) diff --git a/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c b/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c new file mode 100644 index 00000000000..c7253835278 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c @@ -0,0 +1,2 @@ +#define foo(x,y) ((x)*(y)) +foo(bar,baz) diff --git a/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c.expected b/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c.expected new file mode 100644 index 00000000000..f7a2b8c26cb --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/017-define-func-2-args.c.expected @@ -0,0 +1,2 @@ + +((bar)*(baz)) diff --git a/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c b/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c new file mode 100644 index 00000000000..668130b8f9b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c @@ -0,0 +1,3 @@ +#define x 0 +#define foo(x) x +foo(1) diff --git a/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c b/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c new file mode 100644 index 00000000000..c4e62b25508 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(this is more than one word) diff --git a/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected b/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected new file mode 100644 index 00000000000..1e89b8cfd0c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected @@ -0,0 +1,2 @@ + +(this is more than one word) diff --git a/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c b/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c new file mode 100644 index 00000000000..3049ad15465 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x,y) x,two fish,red fish,y +foo(one fish, blue fish) diff --git a/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected b/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected new file mode 100644 index 00000000000..19f59f5ecb7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected @@ -0,0 +1,2 @@ + +one fish,two fish,red fish,blue fish diff --git a/src/compiler/glsl/glcpp/tests/021-define-func-compose.c b/src/compiler/glsl/glcpp/tests/021-define-func-compose.c new file mode 100644 index 00000000000..21ddd0e65f9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/021-define-func-compose.c @@ -0,0 +1,3 @@ +#define bar(x) (1+(x)) +#define foo(y) (2*(y)) +foo(bar(3)) diff --git a/src/compiler/glsl/glcpp/tests/021-define-func-compose.c.expected b/src/compiler/glsl/glcpp/tests/021-define-func-compose.c.expected new file mode 100644 index 00000000000..87f51f0baca --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/021-define-func-compose.c.expected @@ -0,0 +1,3 @@ + + +(2*((1+(3)))) diff --git a/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c b/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c new file mode 100644 index 00000000000..c20d73a4a28 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(argument(including parens)for the win) diff --git a/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected b/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected new file mode 100644 index 00000000000..1dfc6698bb7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected @@ -0,0 +1,2 @@ + +(argument(including parens)for the win) diff --git a/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c b/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c new file mode 100644 index 00000000000..7ebfed6516c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c @@ -0,0 +1,8 @@ +#define noargs() 1 +# define onearg(foo) foo + # define twoargs( x , y ) x y + # define threeargs( a , b , c ) a b c +noargs ( ) +onearg ( 2 ) +twoargs ( 3 , 4 ) +threeargs ( 5 , 6 , 7 ) diff --git a/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c.expected b/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c.expected new file mode 100644 index 00000000000..9c58275d0f9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/023-define-extra-whitespace.c.expected @@ -0,0 +1,8 @@ + + + + +1 +2 +3 4 +5 6 7 diff --git a/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c b/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c new file mode 100644 index 00000000000..e788adce30c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c @@ -0,0 +1,3 @@ +#define foo foo +#define bar foo +bar diff --git a/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected new file mode 100644 index 00000000000..15600af546b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected @@ -0,0 +1,3 @@ + + +foo diff --git a/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c b/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c new file mode 100644 index 00000000000..b433671d1bf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo bar diff --git a/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected b/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected new file mode 100644 index 00000000000..4a59f0520e3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected @@ -0,0 +1,2 @@ + +foo bar diff --git a/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c b/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c new file mode 100644 index 00000000000..0d837405309 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c @@ -0,0 +1,6 @@ +#define foo(a) bar + +foo +( +1 +) diff --git a/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected b/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected new file mode 100644 index 00000000000..5e3c70f2cc5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected @@ -0,0 +1,3 @@ + + +bar diff --git a/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c b/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c new file mode 100644 index 00000000000..5ccb52caba5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure() +foo diff --git a/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected b/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c b/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c new file mode 100644 index 00000000000..44962a71876 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c @@ -0,0 +1,3 @@ +#define success() failure +#define foo success +foo diff --git a/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c b/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c new file mode 100644 index 00000000000..261f7d28fc2 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c @@ -0,0 +1,3 @@ +#define bar(failure) failure +#define foo bar(success) +foo diff --git a/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c b/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c new file mode 100644 index 00000000000..e56fbefd62d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo bar(baz(success)) +foo diff --git a/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c b/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c new file mode 100644 index 00000000000..3f4c8744dff --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo() bar(baz(success)) +foo() diff --git a/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c b/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c new file mode 100644 index 00000000000..b3ac70f499c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2*(a)) +foo(3) diff --git a/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c.expected b/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c.expected new file mode 100644 index 00000000000..983f9417401 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/032-define-func-self-recurse.c.expected @@ -0,0 +1,2 @@ + +foo(2*(3)) diff --git a/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c b/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c new file mode 100644 index 00000000000..f65e48286cf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2*(a)) +foo(foo(3)) diff --git a/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c.expected b/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c.expected new file mode 100644 index 00000000000..08183623643 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/033-define-func-self-compose.c.expected @@ -0,0 +1,2 @@ + +foo(2*(foo(2*(3)))) diff --git a/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c b/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c new file mode 100644 index 00000000000..209a5f7e07c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(foo) diff --git a/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected new file mode 100644 index 00000000000..3f808fe665d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected @@ -0,0 +1,2 @@ + +foo diff --git a/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c new file mode 100644 index 00000000000..c307fbe830f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(1+foo) diff --git a/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected new file mode 100644 index 00000000000..09dfdd64e9b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected @@ -0,0 +1,2 @@ + +1+foo diff --git a/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c b/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c new file mode 100644 index 00000000000..b21ff336738 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c @@ -0,0 +1,3 @@ +#define bar success +#define foo(x) x +foo(more bar) diff --git a/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected new file mode 100644 index 00000000000..580ed9599c5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected @@ -0,0 +1,3 @@ + + +more success diff --git a/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c b/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c new file mode 100644 index 00000000000..b3a2f37f1b9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c @@ -0,0 +1,3 @@ +#define expand(x) expand(x once) +#define foo(x) x +foo(expand(just)) diff --git a/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected new file mode 100644 index 00000000000..e804d7e4f9f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected @@ -0,0 +1,3 @@ + + +expand(just once) diff --git a/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c b/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c new file mode 100644 index 00000000000..1407c7d6e3c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c @@ -0,0 +1,2 @@ +#define foo(x) success +foo(argument (with,embedded , commas) -- tricky) diff --git a/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c.expected b/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c.expected new file mode 100644 index 00000000000..6544adb3a25 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/038-func-arg-with-commas.c.expected @@ -0,0 +1,2 @@ + +success diff --git a/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c b/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c new file mode 100644 index 00000000000..a7c053bb402 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c @@ -0,0 +1,24 @@ +/* This works. */ +#define foo(a) (a) +#define bar two,words +foo(bar) + +/* So does this. */ +#define foo2(a,b) (a separate b) +#define foo2_wrap(a) foo2(a) +foo2_wrap(bar) + +/* But this generates an error. */ +#define foo_wrap(a) foo(a) +foo_wrap(bar) + +/* Adding parentheses to foo_wrap fixes it. */ +#define foo_wrap_parens(a) foo((a)) +foo_wrap_parens(bar) + +/* As does adding parentheses to bar */ +#define bar_parens (two,words) +foo_wrap(bar_parens) +foo_wrap_parens(bar_parens) + + diff --git a/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected new file mode 100644 index 00000000000..4cc795338b2 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected @@ -0,0 +1,26 @@ +0:12(21): preprocessor error: Error: macro foo invoked with 2 arguments (expected 1) + + + + +(two,words) + + + + +(two separate words) + + + +foo(two,words) + + + +((two,words)) + + + +((two,words)) +(((two,words))) + + diff --git a/src/compiler/glsl/glcpp/tests/040-token-pasting.c b/src/compiler/glsl/glcpp/tests/040-token-pasting.c new file mode 100644 index 00000000000..caab3ba7368 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/040-token-pasting.c @@ -0,0 +1,2 @@ +#define paste(a,b) a ## b +paste(one , token) diff --git a/src/compiler/glsl/glcpp/tests/040-token-pasting.c.expected b/src/compiler/glsl/glcpp/tests/040-token-pasting.c.expected new file mode 100644 index 00000000000..48e836ec3fa --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/040-token-pasting.c.expected @@ -0,0 +1,2 @@ + +onetoken diff --git a/src/compiler/glsl/glcpp/tests/041-if-0.c b/src/compiler/glsl/glcpp/tests/041-if-0.c new file mode 100644 index 00000000000..2cab677d3e8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/041-if-0.c @@ -0,0 +1,5 @@ +success_1 +#if 0 +failure +#endif +success_2 diff --git a/src/compiler/glsl/glcpp/tests/041-if-0.c.expected b/src/compiler/glsl/glcpp/tests/041-if-0.c.expected new file mode 100644 index 00000000000..8b506b32d55 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/041-if-0.c.expected @@ -0,0 +1,5 @@ +success_1 + + + +success_2 diff --git a/src/compiler/glsl/glcpp/tests/042-if-1.c b/src/compiler/glsl/glcpp/tests/042-if-1.c new file mode 100644 index 00000000000..874a25cf41b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/042-if-1.c @@ -0,0 +1,5 @@ +success_1 +#if 1 +success_2 +#endif +success_3 diff --git a/src/compiler/glsl/glcpp/tests/042-if-1.c.expected b/src/compiler/glsl/glcpp/tests/042-if-1.c.expected new file mode 100644 index 00000000000..a6ae9465a97 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/042-if-1.c.expected @@ -0,0 +1,5 @@ +success_1 + +success_2 + +success_3 diff --git a/src/compiler/glsl/glcpp/tests/043-if-0-else.c b/src/compiler/glsl/glcpp/tests/043-if-0-else.c new file mode 100644 index 00000000000..323351f9dbf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/043-if-0-else.c @@ -0,0 +1,7 @@ +success_1 +#if 0 +failure +#else +success_2 +#endif +success_3 diff --git a/src/compiler/glsl/glcpp/tests/043-if-0-else.c.expected b/src/compiler/glsl/glcpp/tests/043-if-0-else.c.expected new file mode 100644 index 00000000000..3d7e6be96c8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/043-if-0-else.c.expected @@ -0,0 +1,7 @@ +success_1 + + + +success_2 + +success_3 diff --git a/src/compiler/glsl/glcpp/tests/044-if-1-else.c b/src/compiler/glsl/glcpp/tests/044-if-1-else.c new file mode 100644 index 00000000000..28dfc25c6f0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/044-if-1-else.c @@ -0,0 +1,7 @@ +success_1 +#if 1 +success_2 +#else +failure +#endif +success_3 diff --git a/src/compiler/glsl/glcpp/tests/044-if-1-else.c.expected b/src/compiler/glsl/glcpp/tests/044-if-1-else.c.expected new file mode 100644 index 00000000000..4a31e1cfa9e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/044-if-1-else.c.expected @@ -0,0 +1,7 @@ +success_1 + +success_2 + + + +success_3 diff --git a/src/compiler/glsl/glcpp/tests/045-if-0-elif.c b/src/compiler/glsl/glcpp/tests/045-if-0-elif.c new file mode 100644 index 00000000000..e50f686d461 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/045-if-0-elif.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 1 +success_3 +#elif 1 +failure_3 +#endif +success_4 diff --git a/src/compiler/glsl/glcpp/tests/045-if-0-elif.c.expected b/src/compiler/glsl/glcpp/tests/045-if-0-elif.c.expected new file mode 100644 index 00000000000..a9bb1588e4f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/045-if-0-elif.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + +success_3 + + + +success_4 diff --git a/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c b/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c new file mode 100644 index 00000000000..130515a01ea --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c @@ -0,0 +1,11 @@ +success_1 +#if 1 +success_2 +#elif 0 +failure_1 +#elif 1 +failure_2 +#elif 0 +failure_3 +#endif +success_3 diff --git a/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c.expected b/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c.expected new file mode 100644 index 00000000000..a4995713ca5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/046-if-1-elsif.c.expected @@ -0,0 +1,11 @@ +success_1 + +success_2 + + + + + + + +success_3 diff --git a/src/compiler/glsl/glcpp/tests/047-if-elif-else.c b/src/compiler/glsl/glcpp/tests/047-if-elif-else.c new file mode 100644 index 00000000000..e8f0838a9ed --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/047-if-elif-else.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 0 +failure_3 +#else +success_2 +#endif +success_3 diff --git a/src/compiler/glsl/glcpp/tests/047-if-elif-else.c.expected b/src/compiler/glsl/glcpp/tests/047-if-elif-else.c.expected new file mode 100644 index 00000000000..54d30861197 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/047-if-elif-else.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + + + +success_2 + +success_3 diff --git a/src/compiler/glsl/glcpp/tests/048-if-nested.c b/src/compiler/glsl/glcpp/tests/048-if-nested.c new file mode 100644 index 00000000000..fc4679c3be4 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/048-if-nested.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#if 1 +failure_2 +#else +failure_3 +#endif +failure_4 +#endif +success_2 diff --git a/src/compiler/glsl/glcpp/tests/048-if-nested.c.expected b/src/compiler/glsl/glcpp/tests/048-if-nested.c.expected new file mode 100644 index 00000000000..8beb9c32c37 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/048-if-nested.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + + + + + +success_2 diff --git a/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c b/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c new file mode 100644 index 00000000000..833ea03882a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c @@ -0,0 +1,5 @@ +#if 1 + 2 * 3 + - (25 % 17 - + 1) +failure with operator precedence +#else +success +#endif diff --git a/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c.expected b/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c.expected new file mode 100644 index 00000000000..729bdd15f80 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/049-if-expression-precedence.c.expected @@ -0,0 +1,5 @@ + + + +success + diff --git a/src/compiler/glsl/glcpp/tests/050-if-defined.c b/src/compiler/glsl/glcpp/tests/050-if-defined.c new file mode 100644 index 00000000000..34f0f95140e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/050-if-defined.c @@ -0,0 +1,17 @@ +#if defined foo +failure_1 +#else +success_1 +#endif +#define foo +#if defined foo +success_2 +#else +failure_2 +#endif +#undef foo +#if defined foo +failure_3 +#else +success_3 +#endif diff --git a/src/compiler/glsl/glcpp/tests/050-if-defined.c.expected b/src/compiler/glsl/glcpp/tests/050-if-defined.c.expected new file mode 100644 index 00000000000..737eb8d9403 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/050-if-defined.c.expected @@ -0,0 +1,17 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + diff --git a/src/compiler/glsl/glcpp/tests/051-if-relational.c b/src/compiler/glsl/glcpp/tests/051-if-relational.c new file mode 100644 index 00000000000..c3db488e0de --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/051-if-relational.c @@ -0,0 +1,35 @@ +#if 3 < 2 +failure_1 +#else +success_1 +#endif + +#if 3 >= 2 +success_2 +#else +failure_2 +#endif + +#if 2 + 3 <= 5 +success_3 +#else +failure_3 +#endif + +#if 3 - 2 == 1 +success_3 +#else +failure_3 +#endif + +#if 1 > 3 +failure_4 +#else +success_4 +#endif + +#if 1 != 5 +success_5 +#else +failure_5 +#endif diff --git a/src/compiler/glsl/glcpp/tests/051-if-relational.c.expected b/src/compiler/glsl/glcpp/tests/051-if-relational.c.expected new file mode 100644 index 00000000000..652fefdd43b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/051-if-relational.c.expected @@ -0,0 +1,35 @@ + + + +success_1 + + + +success_2 + + + + + +success_3 + + + + + +success_3 + + + + + + + +success_4 + + + +success_5 + + + diff --git a/src/compiler/glsl/glcpp/tests/052-if-bitwise.c b/src/compiler/glsl/glcpp/tests/052-if-bitwise.c new file mode 100644 index 00000000000..2d8e45eb61e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/052-if-bitwise.c @@ -0,0 +1,20 @@ +#if (0xaaaaaaaa | 0x55555555) != 4294967295 +failure_1 +#else +success_1 +#endif +#if (0x12345678 ^ 0xfdecba98) == 4023971040 +success_2 +#else +failure_2 +#endif +#if (~ 0xdeadbeef) != -3735928560 +failure_3 +#else +success_3 +#endif +#if (0667 & 0733) == 403 +success_4 +#else +failure_4 +#endif diff --git a/src/compiler/glsl/glcpp/tests/052-if-bitwise.c.expected b/src/compiler/glsl/glcpp/tests/052-if-bitwise.c.expected new file mode 100644 index 00000000000..44e52b206e5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/052-if-bitwise.c.expected @@ -0,0 +1,20 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + + +success_4 + + + diff --git a/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c b/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c new file mode 100644 index 00000000000..d24c54a88d1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c @@ -0,0 +1,15 @@ +#if (15 / 2) != 7 +failure_1 +#else +success_1 +#endif +#if (1 << 12) == 4096 +success_2 +#else +failure_2 +#endif +#if (31762 >> 8) != 124 +failure_3 +#else +success_3 +#endif diff --git a/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c.expected b/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c.expected new file mode 100644 index 00000000000..7e78e0454e0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/053-if-divide-and-shift.c.expected @@ -0,0 +1,15 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + diff --git a/src/compiler/glsl/glcpp/tests/054-if-with-macros.c b/src/compiler/glsl/glcpp/tests/054-if-with-macros.c new file mode 100644 index 00000000000..3da79a0d96e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/054-if-with-macros.c @@ -0,0 +1,34 @@ +#define one 1 +#define two 2 +#define three 3 +#define five 5 +#if five < two +failure_1 +#else +success_1 +#endif +#if three >= two +success_2 +#else +failure_2 +#endif +#if two + three <= five +success_3 +#else +failure_3 +#endif +#if five - two == three +success_4 +#else +failure_4 +#endif +#if one > three +failure_5 +#else +success_5 +#endif +#if one != five +success_6 +#else +failure_6 +#endif diff --git a/src/compiler/glsl/glcpp/tests/054-if-with-macros.c.expected b/src/compiler/glsl/glcpp/tests/054-if-with-macros.c.expected new file mode 100644 index 00000000000..70f737c90a9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/054-if-with-macros.c.expected @@ -0,0 +1,34 @@ + + + + + + + +success_1 + + +success_2 + + + + +success_3 + + + + +success_4 + + + + + + +success_5 + + +success_6 + + + diff --git a/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c b/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c new file mode 100644 index 00000000000..00f2c2346d6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure +foo() diff --git a/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c b/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c new file mode 100644 index 00000000000..58701d1f25b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c @@ -0,0 +1,4 @@ +#define bar with,embedded,commas +#define function(x) success +#define foo function +foo(bar) diff --git a/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected b/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/src/compiler/glsl/glcpp/tests/057-empty-arguments.c b/src/compiler/glsl/glcpp/tests/057-empty-arguments.c new file mode 100644 index 00000000000..6140232865d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/057-empty-arguments.c @@ -0,0 +1,6 @@ +#define zero() success +zero() +#define one(x) success +one() +#define two(x,y) success +two(,) diff --git a/src/compiler/glsl/glcpp/tests/057-empty-arguments.c.expected b/src/compiler/glsl/glcpp/tests/057-empty-arguments.c.expected new file mode 100644 index 00000000000..7d97e15e29d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/057-empty-arguments.c.expected @@ -0,0 +1,6 @@ + +success + +success + +success diff --git a/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c b/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c new file mode 100644 index 00000000000..8ac260c76b6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c @@ -0,0 +1,5 @@ +#define paste(x,y) x ## y +paste(a,b) +paste(a,) +paste(,b) +paste(,) diff --git a/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected new file mode 100644 index 00000000000..e0967a1b951 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected @@ -0,0 +1,5 @@ + +ab +a +b + diff --git a/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c b/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c new file mode 100644 index 00000000000..37b895a4237 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c @@ -0,0 +1,4 @@ +#define paste(x,y) x ## y +paste(1,2) +paste(1,000) +paste(identifier,2) diff --git a/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c.expected b/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c.expected new file mode 100644 index 00000000000..f1288aa7cb7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/059-token-pasting-integer.c.expected @@ -0,0 +1,4 @@ + +12 +1000 +identifier2 diff --git a/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c b/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c new file mode 100644 index 00000000000..ed80ea879ce --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c @@ -0,0 +1,3 @@ +#define double(a) a*2 +#define foo double( +foo 5) diff --git a/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected new file mode 100644 index 00000000000..3e5501aa6e8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected @@ -0,0 +1,3 @@ + + +5*2 diff --git a/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c b/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c new file mode 100644 index 00000000000..6dbfd1f62d1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c @@ -0,0 +1,5 @@ +#define foo(x) success +#define bar foo +#define baz bar +#define joe baz +joe (failure) diff --git a/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected new file mode 100644 index 00000000000..15eb64b97f1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected @@ -0,0 +1,5 @@ + + + + +success diff --git a/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c b/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c new file mode 100644 index 00000000000..d9e439bb890 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c @@ -0,0 +1,5 @@ +#define foo(a,b) +#if 0 +foo(bar) +foo( +#endif diff --git a/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected b/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected @@ -0,0 +1,5 @@ + + + + + diff --git a/src/compiler/glsl/glcpp/tests/063-comments.c b/src/compiler/glsl/glcpp/tests/063-comments.c new file mode 100644 index 00000000000..e641d2f0f9e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/063-comments.c @@ -0,0 +1,20 @@ +/* this is a comment */ +// so is this +// */ +f = g/**//h; +/*//*/l(); +m = n//**/o ++ p; +/* this +comment spans +multiple lines and +contains *** stars +and slashes / *** / +and other stuff. +****/ +more code here +/* Test that /* nested + comments */ +are not treated like comments. +/*/ this is a comment */ +/*/*/ diff --git a/src/compiler/glsl/glcpp/tests/063-comments.c.expected b/src/compiler/glsl/glcpp/tests/063-comments.c.expected new file mode 100644 index 00000000000..f6e10ce0377 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/063-comments.c.expected @@ -0,0 +1,20 @@ + + + +f = g /h; + l(); +m = n ++ p; + + + + + + + +more code here + + +are not treated like comments. + + diff --git a/src/compiler/glsl/glcpp/tests/064-version.c b/src/compiler/glsl/glcpp/tests/064-version.c new file mode 100644 index 00000000000..21326481b87 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/064-version.c @@ -0,0 +1,2 @@ +#version 130 +#define FOO diff --git a/src/compiler/glsl/glcpp/tests/064-version.c.expected b/src/compiler/glsl/glcpp/tests/064-version.c.expected new file mode 100644 index 00000000000..4036b1ee374 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/064-version.c.expected @@ -0,0 +1,2 @@ +#version 130 + diff --git a/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c b/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c new file mode 100644 index 00000000000..48aa0f8c3ef --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c @@ -0,0 +1,17 @@ +#if defined(foo) +failure_1 +#else +success_1 +#endif +#define foo +#if defined ( foo ) +success_2 +#else +failure_2 +#endif +#undef foo +#if defined (foo) +failure_3 +#else +success_3 +#endif diff --git a/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c.expected b/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c.expected new file mode 100644 index 00000000000..737eb8d9403 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/065-if-defined-parens.c.expected @@ -0,0 +1,17 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + diff --git a/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c b/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c new file mode 100644 index 00000000000..3b0b47349d0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c @@ -0,0 +1,3 @@ +#if(1) +success +#endif diff --git a/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c.expected b/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c.expected new file mode 100644 index 00000000000..5a28fb3b66c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/066-if-nospace-expression.c.expected @@ -0,0 +1,3 @@ + +success + diff --git a/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c b/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c new file mode 100644 index 00000000000..f46cce4e60a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c @@ -0,0 +1,40 @@ +#define D1 +#define D2 + +#define result success + +#ifdef U1 +#ifdef U2 +#undef result +#define result failure +#endif +#endif +result + +#ifndef D1 +#ifndef D2 +#undef result +#define result failure +#endif +#endif +result + +#undef result +#define result failure +#ifdef D1 +#ifdef D2 +#undef result +#define result success +#endif +#endif +result + +#undef result +#define result failure +#ifndef U1 +#ifndef U2 +#undef result +#define result success +#endif +#endif +result diff --git a/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected b/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected new file mode 100644 index 00000000000..9a5ed2eb2d3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected @@ -0,0 +1,40 @@ + + + + + + + + + + + +success + + + + + + + +success + + + + + + + + + +success + + + + + + + + + +success diff --git a/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c b/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c new file mode 100644 index 00000000000..699ac5144e5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c @@ -0,0 +1,11 @@ +#define empty +<empty< +<empty= +>empty> +>empty= +=empty= +!empty= +&empty& +|empty| ++empty+ +-empty- diff --git a/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c.expected b/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c.expected new file mode 100644 index 00000000000..27582cda5e8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/068-accidental-pasting.c.expected @@ -0,0 +1,11 @@ + +< < +< = +> > +> = += = +! = +& & +| | ++ + +- - diff --git a/src/compiler/glsl/glcpp/tests/069-repeated-argument.c b/src/compiler/glsl/glcpp/tests/069-repeated-argument.c new file mode 100644 index 00000000000..2b46ead294c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/069-repeated-argument.c @@ -0,0 +1,2 @@ +#define double(x) x x +double(1) diff --git a/src/compiler/glsl/glcpp/tests/069-repeated-argument.c.expected b/src/compiler/glsl/glcpp/tests/069-repeated-argument.c.expected new file mode 100644 index 00000000000..8b4b095e488 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/069-repeated-argument.c.expected @@ -0,0 +1,2 @@ + +1 1 diff --git a/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c b/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c new file mode 100644 index 00000000000..d15a4840b01 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c @@ -0,0 +1,5 @@ +#if UNDEFINED_MACRO +Failure +#else +Success +#endif diff --git a/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected b/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected new file mode 100644 index 00000000000..44b93a434fa --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected @@ -0,0 +1,5 @@ + + + +Success + diff --git a/src/compiler/glsl/glcpp/tests/071-punctuator.c b/src/compiler/glsl/glcpp/tests/071-punctuator.c new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/071-punctuator.c @@ -0,0 +1 @@ +a = b diff --git a/src/compiler/glsl/glcpp/tests/071-punctuator.c.expected b/src/compiler/glsl/glcpp/tests/071-punctuator.c.expected new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/071-punctuator.c.expected @@ -0,0 +1 @@ +a = b diff --git a/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c b/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c new file mode 100644 index 00000000000..e421e9d5e29 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c @@ -0,0 +1,2 @@ +#define paste(x) success_ ## x +paste(1) paste(2) paste(3) diff --git a/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c.expected b/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c.expected new file mode 100644 index 00000000000..7b80af7e465 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/072-token-pasting-same-line.c.expected @@ -0,0 +1,2 @@ + +success_1 success_2 success_3 diff --git a/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c b/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c new file mode 100644 index 00000000000..61a48097ca3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c @@ -0,0 +1,4 @@ +#ifdef UNDEF +#if UNDEF > 1 +#endif +#endif diff --git a/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c.expected b/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c.expected new file mode 100644 index 00000000000..fd40910d9e7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/073-if-in-ifdef.c.expected @@ -0,0 +1,4 @@ + + + + diff --git a/src/compiler/glsl/glcpp/tests/074-elif-undef.c b/src/compiler/glsl/glcpp/tests/074-elif-undef.c new file mode 100644 index 00000000000..67aac8977e0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/074-elif-undef.c @@ -0,0 +1,3 @@ +#ifndef UNDEF +#elif UNDEF < 0 +#endif diff --git a/src/compiler/glsl/glcpp/tests/074-elif-undef.c.expected b/src/compiler/glsl/glcpp/tests/074-elif-undef.c.expected new file mode 100644 index 00000000000..b28b04f6431 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/074-elif-undef.c.expected @@ -0,0 +1,3 @@ + + + diff --git a/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c b/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c new file mode 100644 index 00000000000..264bc4f10ee --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c @@ -0,0 +1,4 @@ +#ifndef UNDEF +#elif UNDEF < 0 +#elif UNDEF == 3 +#endif diff --git a/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c.expected b/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c.expected new file mode 100644 index 00000000000..fd40910d9e7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/075-elif-elif-undef.c.expected @@ -0,0 +1,4 @@ + + + + diff --git a/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c b/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c new file mode 100644 index 00000000000..ebd550ed005 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c @@ -0,0 +1,5 @@ +#ifdef UNDEF +#if UNDEF == 4 +#elif UNDEF == 5 +#endif +#endif diff --git a/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c.expected b/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/076-elif-undef-nested.c.expected @@ -0,0 +1,5 @@ + + + + + diff --git a/src/compiler/glsl/glcpp/tests/077-else-without-if.c b/src/compiler/glsl/glcpp/tests/077-else-without-if.c new file mode 100644 index 00000000000..81f00bfe278 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/077-else-without-if.c @@ -0,0 +1 @@ +#else diff --git a/src/compiler/glsl/glcpp/tests/077-else-without-if.c.expected b/src/compiler/glsl/glcpp/tests/077-else-without-if.c.expected new file mode 100644 index 00000000000..69f34047033 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/077-else-without-if.c.expected @@ -0,0 +1,3 @@ +0:1(1): preprocessor error: #else without #if + + diff --git a/src/compiler/glsl/glcpp/tests/078-elif-without-if.c b/src/compiler/glsl/glcpp/tests/078-elif-without-if.c new file mode 100644 index 00000000000..60466b3890a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/078-elif-without-if.c @@ -0,0 +1 @@ +#elif defined FOO diff --git a/src/compiler/glsl/glcpp/tests/078-elif-without-if.c.expected b/src/compiler/glsl/glcpp/tests/078-elif-without-if.c.expected new file mode 100644 index 00000000000..b8e40ecc09b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/078-elif-without-if.c.expected @@ -0,0 +1,3 @@ +0:1(1): preprocessor error: #elif without #if + + diff --git a/src/compiler/glsl/glcpp/tests/079-endif-without-if.c b/src/compiler/glsl/glcpp/tests/079-endif-without-if.c new file mode 100644 index 00000000000..69331c3ca9d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/079-endif-without-if.c @@ -0,0 +1 @@ +#endif diff --git a/src/compiler/glsl/glcpp/tests/079-endif-without-if.c.expected b/src/compiler/glsl/glcpp/tests/079-endif-without-if.c.expected new file mode 100644 index 00000000000..7ae579dd25e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/079-endif-without-if.c.expected @@ -0,0 +1,3 @@ +0:1(1): preprocessor error: #endif without #if + + diff --git a/src/compiler/glsl/glcpp/tests/080-if-without-expression.c b/src/compiler/glsl/glcpp/tests/080-if-without-expression.c new file mode 100644 index 00000000000..a27ba36a366 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/080-if-without-expression.c @@ -0,0 +1,4 @@ +/* Error message for unskipped #if with no expression. */ +#if +#endif + diff --git a/src/compiler/glsl/glcpp/tests/080-if-without-expression.c.expected b/src/compiler/glsl/glcpp/tests/080-if-without-expression.c.expected new file mode 100644 index 00000000000..2e4cd7323c5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/080-if-without-expression.c.expected @@ -0,0 +1,5 @@ +0:2(1): preprocessor error: #if with no expression + + + + diff --git a/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c b/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c new file mode 100644 index 00000000000..79c78663dd3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c @@ -0,0 +1,3 @@ +#if 0 +#elif +#endif diff --git a/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c.expected b/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c.expected new file mode 100644 index 00000000000..b607b849068 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/081-elif-without-expression.c.expected @@ -0,0 +1,4 @@ +0:2(1): preprocessor error: #elif with no expression + + + diff --git a/src/compiler/glsl/glcpp/tests/082-invalid-paste.c b/src/compiler/glsl/glcpp/tests/082-invalid-paste.c new file mode 100644 index 00000000000..8b84d50c3a0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/082-invalid-paste.c @@ -0,0 +1,7 @@ +#define PASTE(x,y) x ## y +PASTE(<,>) +PASTE(0,abc) +PASTE(1,=) +PASTE(2,@) +PASTE(3,-4) +PASTE(4,+5.2) diff --git a/src/compiler/glsl/glcpp/tests/082-invalid-paste.c.expected b/src/compiler/glsl/glcpp/tests/082-invalid-paste.c.expected new file mode 100644 index 00000000000..b48a2d6d296 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/082-invalid-paste.c.expected @@ -0,0 +1,19 @@ +0:2(7): preprocessor error: +Pasting "<" and ">" does not give a valid preprocessing token. +0:3(7): preprocessor error: +Pasting "0" and "abc" does not give a valid preprocessing token. +0:4(7): preprocessor error: +Pasting "1" and "=" does not give a valid preprocessing token. +0:5(7): preprocessor error: +Pasting "2" and "@" does not give a valid preprocessing token. +0:6(7): preprocessor error: +Pasting "3" and "-" does not give a valid preprocessing token. +0:7(7): preprocessor error: +Pasting "4" and "+" does not give a valid preprocessing token. + +< +0 +1 +2 +34 +45.2 diff --git a/src/compiler/glsl/glcpp/tests/083-unterminated-if.c b/src/compiler/glsl/glcpp/tests/083-unterminated-if.c new file mode 100644 index 00000000000..91806350927 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/083-unterminated-if.c @@ -0,0 +1,2 @@ +#if 1 + diff --git a/src/compiler/glsl/glcpp/tests/083-unterminated-if.c.expected b/src/compiler/glsl/glcpp/tests/083-unterminated-if.c.expected new file mode 100644 index 00000000000..4659ab6fe67 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/083-unterminated-if.c.expected @@ -0,0 +1,4 @@ +0:1(6): preprocessor error: Unterminated #if + + + diff --git a/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c b/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c new file mode 100644 index 00000000000..0789ba5e525 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c @@ -0,0 +1,2 @@ +#define FUNC(x) (2*(x)) +FUNC(23 diff --git a/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected b/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected new file mode 100644 index 00000000000..af49a37369d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected @@ -0,0 +1,2 @@ +0:2(8): preprocessor error: syntax error, unexpected $end + diff --git a/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c b/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c new file mode 100644 index 00000000000..91bea600612 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c @@ -0,0 +1,5 @@ +#define MULT(x,y) ((x)*(y)) +MULT() +MULT(1) +MULT(1,2,3) + diff --git a/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c.expected b/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c.expected new file mode 100644 index 00000000000..d23845bfd49 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/085-incorrect-argument-count.c.expected @@ -0,0 +1,11 @@ +0:2(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) + +0:3(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) + +0:4(1): preprocessor error: Error: macro MULT invoked with 3 arguments (expected 2) + + +MULT() +MULT(1) +MULT(1,2,3) + diff --git a/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c b/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c new file mode 100644 index 00000000000..a6b7201f95d --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c @@ -0,0 +1,3 @@ +#define __BAD reserved +#define GL_ALSO_BAD() also reserved +#define THIS__TOO__IS__BAD reserved diff --git a/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c.expected b/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c.expected new file mode 100644 index 00000000000..38b089daec3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/086-reserved-macro-names.c.expected @@ -0,0 +1,9 @@ +0:1(9): preprocessor warning: Macro names containing "__" are reserved for use by the implementation. + +0:2(9): preprocessor error: Macro names starting with "GL_" are reserved. + +0:3(9): preprocessor warning: Macro names containing "__" are reserved for use by the implementation. + + + + diff --git a/src/compiler/glsl/glcpp/tests/087-if-comments.c b/src/compiler/glsl/glcpp/tests/087-if-comments.c new file mode 100644 index 00000000000..ce8dc43057f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/087-if-comments.c @@ -0,0 +1,5 @@ +#if (1 == 0) // dangerous comment +fail +#else +win +#endif diff --git a/src/compiler/glsl/glcpp/tests/087-if-comments.c.expected b/src/compiler/glsl/glcpp/tests/087-if-comments.c.expected new file mode 100644 index 00000000000..2783a9c14d5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/087-if-comments.c.expected @@ -0,0 +1,5 @@ + + + +win + diff --git a/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c b/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c new file mode 100644 index 00000000000..422c6546414 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c @@ -0,0 +1,5 @@ +#define abc 123 +#define abc 123 + +#define foo(x) ( x ) + 23 +#define foo(x) ( x ) + 23 diff --git a/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected b/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected @@ -0,0 +1,5 @@ + + + + + diff --git a/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c b/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c new file mode 100644 index 00000000000..b3d1391e160 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c @@ -0,0 +1,17 @@ +#define x y +#define x z + +#define abc 123 +#define abc() 123 + +#define foo() bar +#define foo(x) bar + +#define bar() baz +#define bar baz + +#define biff(a,b) a+b +#define biff(a,b,c) a+b + +#define oper(a,b) a+b +#define oper(a,b) a*b diff --git a/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c.expected b/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c.expected new file mode 100644 index 00000000000..a945161497f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/089-redefine-macro-error.c.expected @@ -0,0 +1,29 @@ +0:2(9): preprocessor error: Redefinition of macro x + +0:5(9): preprocessor error: Redefinition of macro abc + +0:8(9): preprocessor error: Redefinition of macro foo + +0:11(9): preprocessor error: Redefinition of macro bar + +0:14(9): preprocessor error: Redefinition of macro biff + +0:17(9): preprocessor error: Redefinition of macro oper + + + + + + + + + + + + + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/090-hash-error.c b/src/compiler/glsl/glcpp/tests/090-hash-error.c new file mode 100644 index 00000000000..d19bb7faed8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/090-hash-error.c @@ -0,0 +1 @@ +#error human error diff --git a/src/compiler/glsl/glcpp/tests/090-hash-error.c.expected b/src/compiler/glsl/glcpp/tests/090-hash-error.c.expected new file mode 100644 index 00000000000..876a6ea9cc5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/090-hash-error.c.expected @@ -0,0 +1 @@ +0:1(1): preprocessor error: #error human error diff --git a/src/compiler/glsl/glcpp/tests/091-hash-line.c b/src/compiler/glsl/glcpp/tests/091-hash-line.c new file mode 100644 index 00000000000..26d70382a89 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/091-hash-line.c @@ -0,0 +1,14 @@ +#line 0 +#error line 0 error +#line 25 +#error line 25 error +#line 0 1 +#error source 1, line 0 error +#line 30 2 +#error source 2, line 30 error +#line 45 2 /* A line with a comment */ +#define NINETY 90 +#define TWO 2 +#line NINETY TWO /* A #line line with macro expansion */ +#define FUNCTION_LIKE_MACRO(source, line) source line +#line FUNCTION_LIKE_MACRO(180,2) diff --git a/src/compiler/glsl/glcpp/tests/091-hash-line.c.expected b/src/compiler/glsl/glcpp/tests/091-hash-line.c.expected new file mode 100644 index 00000000000..ac9ab252f1e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/091-hash-line.c.expected @@ -0,0 +1,14 @@ +0:0(1): preprocessor error: #error line 0 error +0:25(1): preprocessor error: #error line 25 error +1:0(1): preprocessor error: #error source 1, line 0 error +2:30(1): preprocessor error: #error source 2, line 30 error +#line 0 +#line 25 +#line 0 1 +#line 30 2 +#line 45 2 + + +#line 90 2 + +#line 180 2 diff --git a/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c b/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c new file mode 100644 index 00000000000..3c161a5c501 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c @@ -0,0 +1,5 @@ +#define A +#define A 1 + +#define B 1 +#define B diff --git a/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected b/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected new file mode 100644 index 00000000000..698294d91f2 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected @@ -0,0 +1,9 @@ +0:2(9): preprocessor error: Redefinition of macro A + +0:5(9): preprocessor error: Redefinition of macro B + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c b/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c new file mode 100644 index 00000000000..bf65d4f5271 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c @@ -0,0 +1,2 @@ +#if (1 / 0) +#endif diff --git a/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c.expected b/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c.expected new file mode 100644 index 00000000000..a858870b794 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/093-divide-by-zero.c.expected @@ -0,0 +1,3 @@ +0:1(12): preprocessor error: division by 0 in preprocessor directive + + diff --git a/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c b/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c new file mode 100644 index 00000000000..04497b17913 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c @@ -0,0 +1,13 @@ +/* glcpp is generating a division-by-zero error for this case. It's + * easy to argue that it should be short-circuiting the evaluation and + * not generating the diagnostic (which happens to be what gcc does). + * But it doesn't seem like we should force this behavior on our + * pre-processor, (and, as always, the GLSL specification of the + * pre-processor is too vague on this point). + * + * If a short-circuit evaluation optimization does get added to the + * pre-processor then it would legitimate to update the expected file + * for this test. +*/ +#if 1 || (1 / 0) +#endif diff --git a/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected b/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected new file mode 100644 index 00000000000..570952b2454 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected @@ -0,0 +1,14 @@ +0:12(17): preprocessor error: division by 0 in preprocessor directive + + + + + + + + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/095-recursive-define.c b/src/compiler/glsl/glcpp/tests/095-recursive-define.c new file mode 100644 index 00000000000..801d90ce2e3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/095-recursive-define.c @@ -0,0 +1,3 @@ +#define A(a, b) B(a, b) +#define C A(0, C) +C diff --git a/src/compiler/glsl/glcpp/tests/095-recursive-define.c.expected b/src/compiler/glsl/glcpp/tests/095-recursive-define.c.expected new file mode 100644 index 00000000000..493ab091be7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/095-recursive-define.c.expected @@ -0,0 +1,3 @@ + + +B(0, C) diff --git a/src/compiler/glsl/glcpp/tests/096-paste-twice.c b/src/compiler/glsl/glcpp/tests/096-paste-twice.c new file mode 100644 index 00000000000..8da756fcba4 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/096-paste-twice.c @@ -0,0 +1,3 @@ +#define paste_twice(a,b,c) a ## b ## c +paste_twice(just, one, token) + diff --git a/src/compiler/glsl/glcpp/tests/096-paste-twice.c.expected b/src/compiler/glsl/glcpp/tests/096-paste-twice.c.expected new file mode 100644 index 00000000000..96c57d2a6ec --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/096-paste-twice.c.expected @@ -0,0 +1,3 @@ + +justonetoken + diff --git a/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c b/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c new file mode 100644 index 00000000000..0f46835c29e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c @@ -0,0 +1,3 @@ +#define PASTE_MACRO one ## token +PASTE_MACRO + diff --git a/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected b/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected new file mode 100644 index 00000000000..36f66992539 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected @@ -0,0 +1,3 @@ + +onetoken + diff --git a/src/compiler/glsl/glcpp/tests/098-elif-undefined.c b/src/compiler/glsl/glcpp/tests/098-elif-undefined.c new file mode 100644 index 00000000000..1f520d4d432 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/098-elif-undefined.c @@ -0,0 +1,7 @@ +#if 0 +Not this +#elif UNDEFINED_MACRO +Nor this +#else +Yes, this. +#endif diff --git a/src/compiler/glsl/glcpp/tests/098-elif-undefined.c.expected b/src/compiler/glsl/glcpp/tests/098-elif-undefined.c.expected new file mode 100644 index 00000000000..c6ef689ce4b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/098-elif-undefined.c.expected @@ -0,0 +1,7 @@ + + + + + +Yes, this. + diff --git a/src/compiler/glsl/glcpp/tests/099-c99-example.c b/src/compiler/glsl/glcpp/tests/099-c99-example.c new file mode 100644 index 00000000000..d1976b1f265 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/099-c99-example.c @@ -0,0 +1,17 @@ +#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 +f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +g(x +(3,4)-w) | h 5) & m + (f)^m(m); +p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; diff --git a/src/compiler/glsl/glcpp/tests/099-c99-example.c.expected b/src/compiler/glsl/glcpp/tests/099-c99-example.c.expected new file mode 100644 index 00000000000..352bbff48f5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/099-c99-example.c.expected @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +int i[] = { 1, 23, 4, 5, }; diff --git a/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c b/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c new file mode 100644 index 00000000000..31dbb9a9edc --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c @@ -0,0 +1,7 @@ +#define one 1 +#define two 2 + +switch (1) { + case one + two: + break; +} diff --git a/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c.expected b/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c.expected new file mode 100644 index 00000000000..09f1f417bdd --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/100-macro-with-colon.c.expected @@ -0,0 +1,7 @@ + + + +switch (1) { + case 1 + 2: + break; +} diff --git a/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c b/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c new file mode 100644 index 00000000000..e1693805b6a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c @@ -0,0 +1,16 @@ +#define object 1 +#define function(x) 1 + +#if object +once +#endif +#if object +twice +#endif + +#if function(0) +once +#endif +#if function(0) +once again +#endif diff --git a/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c.expected b/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c.expected new file mode 100644 index 00000000000..1e0b30696cb --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/101-macros-used-twice.c.expected @@ -0,0 +1,16 @@ + + + + +once + + +twice + + + +once + + +once again + diff --git a/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c b/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c new file mode 100644 index 00000000000..301779eb948 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c @@ -0,0 +1,2 @@ +#if 0 +#endif garbage diff --git a/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c.expected b/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c.expected new file mode 100644 index 00000000000..d9f3bdc9465 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/102-garbage-after-endif.c.expected @@ -0,0 +1,2 @@ +0:2(8): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE + diff --git a/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c b/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c new file mode 100644 index 00000000000..c460feadf57 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c @@ -0,0 +1,3 @@ +#if 0 +#else garbage +#endif diff --git a/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c.expected b/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c.expected new file mode 100644 index 00000000000..b053b399775 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/103-garbage-after-else-0.c.expected @@ -0,0 +1,4 @@ +0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE +0:1(6): preprocessor error: Unterminated #if + + diff --git a/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c b/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c new file mode 100644 index 00000000000..3fbeec48e4c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c @@ -0,0 +1,2 @@ +#line 2 +int foo(); diff --git a/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c.expected b/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c.expected new file mode 100644 index 00000000000..3fbeec48e4c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/104-hash-line-followed-by-code.c.expected @@ -0,0 +1,2 @@ +#line 2 +int foo(); diff --git a/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c b/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c new file mode 100644 index 00000000000..da156c6a596 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c @@ -0,0 +1,5 @@ +#define X(x) x +#line X( \ + 1 \ + ) +#line 2 diff --git a/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c.expected b/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c.expected new file mode 100644 index 00000000000..814cef1b8c5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/105-multiline-hash-line.c.expected @@ -0,0 +1,5 @@ + +#line 1 + + +#line 2 diff --git a/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c b/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c new file mode 100644 index 00000000000..929e93e782f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c @@ -0,0 +1,6 @@ +#define X(x) x +#if X( \ + 1 \ + ) +int foo(); +#endif diff --git a/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c.expected b/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c.expected new file mode 100644 index 00000000000..1c0cbc970f5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/106-multiline-hash-if.c.expected @@ -0,0 +1,6 @@ + + + + +int foo(); + diff --git a/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c b/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c new file mode 100644 index 00000000000..8c1c67a4d6b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c @@ -0,0 +1,7 @@ +#define X(x) x +#if 0 +#elif X( \ + 1 \ + ) +int foo(); +#endif diff --git a/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c.expected b/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c.expected new file mode 100644 index 00000000000..b0601d7ee42 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/107-multiline-hash-elif.c.expected @@ -0,0 +1,7 @@ + + + + + +int foo(); + diff --git a/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c b/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c new file mode 100644 index 00000000000..0ce36f2eb1b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c @@ -0,0 +1 @@ +#version110 diff --git a/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected b/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected new file mode 100644 index 00000000000..4f4243f947f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected @@ -0,0 +1 @@ +0:1(1): preprocessor error: Illegal non-directive after # diff --git a/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c b/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c new file mode 100644 index 00000000000..f52966a8e80 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c @@ -0,0 +1 @@ +#line2 diff --git a/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected b/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected new file mode 100644 index 00000000000..4f4243f947f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected @@ -0,0 +1 @@ +0:1(1): preprocessor error: Illegal non-directive after # diff --git a/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c b/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c new file mode 100644 index 00000000000..6d7d0f38d9a --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c @@ -0,0 +1,3 @@ +#if 1 +#elif110 +#endif diff --git a/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected b/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected new file mode 100644 index 00000000000..4d93de41dd3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected @@ -0,0 +1,3 @@ +0:2(1): preprocessor error: Illegal non-directive after # + + diff --git a/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c b/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c new file mode 100644 index 00000000000..b3413371ec2 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c @@ -0,0 +1,19 @@ +#if(1) +success +#endif + +#if+1 +success +#endif + +#if-1 +success +#endif + +#if!1 +success +#endif + +#if~1 +success +#endif diff --git a/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected b/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected new file mode 100644 index 00000000000..5c005c393a9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected @@ -0,0 +1,19 @@ + +success + + + +success + + + +success + + + + + + + +success + diff --git a/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c b/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c new file mode 100644 index 00000000000..e8221bc49c3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c @@ -0,0 +1,24 @@ +#if 0 +#elif(1) +success +#endif + +#if 0 +#elif+1 +success +#endif + +#if 0 +#elif-1 +success +#endif + +#if 0 +#elif!1 +success +#endif + +#if 0 +#elif~1 +success +#endif diff --git a/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected b/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected new file mode 100644 index 00000000000..86b37036b65 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected @@ -0,0 +1,24 @@ + + +success + + + + +success + + + + +success + + + + + + + + + +success + diff --git a/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c b/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c new file mode 100644 index 00000000000..369c4879260 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c @@ -0,0 +1,7 @@ +1. Number of dalmations: __LINE__ __FILE__ __LINE__ +2. Nominal visual acuity: __LINE__ __FILE__ / __LINE__ __FILE__ +3. Battle of Thermopylae, as film: __LINE__ __FILE__ __FILE__ +4. HTTP code for "Not Found": __LINE__ __FILE__ __LINE__ +5. Hexadecimal for 20560: __LINE__ __FILE__ __LINE__ __FILE__ +6: Zip code for Nortonville, KS: __LINE__ __LINE__ __FILE__ __LINE__ __FILE__ +7. James Bond, as a number: __FILE__ __FILE__ __LINE__ diff --git a/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c.expected b/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c.expected new file mode 100644 index 00000000000..55bc788ffd7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/113-line-and-file-macros.c.expected @@ -0,0 +1,7 @@ +1. Number of dalmations: 1 0 1 +2. Nominal visual acuity: 2 0 / 2 0 +3. Battle of Thermopylae, as film: 3 0 0 +4. HTTP code for "Not Found": 4 0 4 +5. Hexadecimal for 20560: 5 0 5 0 +6: Zip code for Nortonville, KS: 6 6 0 6 0 +7. James Bond, as a number: 0 0 7 diff --git a/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c b/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c new file mode 100644 index 00000000000..d80d9c7ef4b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c @@ -0,0 +1,7 @@ +#define PASTE3(a,b,c) a ## b ## c +#define PASTE4(a,b,c,d) a ## b ## c ## d +#define PASTE5(a,b,c,d,e) a ## b ## c ## d ## e +4. HTTP code for "Not Found": PASTE3(__LINE__, __FILE__ , __LINE__) +5. Hexadecimal for 20560: PASTE4(__LINE__, __FILE__, __LINE__, __FILE__) +6: Zip code for Nortonville, KS: PASTE5(__LINE__, __LINE__, __FILE__, __LINE__, __FILE__) +7. James Bond, as a number: PASTE3(__FILE__, __FILE__, __LINE__) diff --git a/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c.expected b/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c.expected new file mode 100644 index 00000000000..aa9711034a6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/114-paste-integer-tokens.c.expected @@ -0,0 +1,7 @@ + + + +4. HTTP code for "Not Found": 404 +5. Hexadecimal for 20560: 5050 +6: Zip code for Nortonville, KS: 66060 +7. James Bond, as a number: 007 diff --git a/src/compiler/glsl/glcpp/tests/115-line-continuations.c b/src/compiler/glsl/glcpp/tests/115-line-continuations.c new file mode 100644 index 00000000000..105590d85ed --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/115-line-continuations.c @@ -0,0 +1,9 @@ +// This comment continues to the next line, hiding the define \ +#define CONTINUATION_UNSUPPORTED + +#ifdef CONTINUATION_UNSUPPORTED +failure +#else +success +#endif + diff --git a/src/compiler/glsl/glcpp/tests/115-line-continuations.c.expected b/src/compiler/glsl/glcpp/tests/115-line-continuations.c.expected new file mode 100644 index 00000000000..428b5e822c5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/115-line-continuations.c.expected @@ -0,0 +1,9 @@ + + + + + + +success + + diff --git a/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c b/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c new file mode 100644 index 00000000000..83d5ddf681b --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c @@ -0,0 +1,13 @@ +// glcpp-args: --disable-line-continuations + +// This comments ends with a backslash \\ +#define NO_CONTINUATION + +#ifdef NO_CONTINUATION +success +#else +failure +#endif + + + diff --git a/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c.expected b/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c.expected new file mode 100644 index 00000000000..5ca78928a61 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/116-disable-line-continuations.c.expected @@ -0,0 +1,13 @@ + + + + + + +success + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c b/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c new file mode 100644 index 00000000000..6a6f2829883 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c @@ -0,0 +1,12 @@ +/* This test case is the minimal case to replicate the bug reported here: + * + * https://bugs.freedesktop.org/show_bug.cgi?id=65112 + * + * To trigger the bug, there must be a line-continuation sequence + * (backslash newline), then an additional newline character, and + * finally another backslash that is not part of a line-continuation + * sequence. + */ +\ + +/* \ */ diff --git a/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c.expected b/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c.expected new file mode 100644 index 00000000000..8aaa04d28e4 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c.expected @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c b/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c new file mode 100644 index 00000000000..53e80394ab6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c @@ -0,0 +1,4 @@ +#define FOO first/* +*/second + +FOO diff --git a/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c.expected b/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c.expected new file mode 100644 index 00000000000..1fa8135cb13 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/118-comment-becomes-space.c.expected @@ -0,0 +1,4 @@ + + + +first second diff --git a/src/compiler/glsl/glcpp/tests/119-elif-after-else.c b/src/compiler/glsl/glcpp/tests/119-elif-after-else.c new file mode 100644 index 00000000000..9b9e9233bcb --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/119-elif-after-else.c @@ -0,0 +1,6 @@ +#if 0 +#else +int foo; +#elif 0 +int bar; +#endif diff --git a/src/compiler/glsl/glcpp/tests/119-elif-after-else.c.expected b/src/compiler/glsl/glcpp/tests/119-elif-after-else.c.expected new file mode 100644 index 00000000000..636956799cd --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/119-elif-after-else.c.expected @@ -0,0 +1,7 @@ +0:4(1): preprocessor error: #elif after #else + + +int foo; + +int bar; + diff --git a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c new file mode 100644 index 00000000000..49e7696613e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c @@ -0,0 +1,3 @@ +#undef __LINE__ +#undef __FILE__ +#undef __VERSION__ diff --git a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected new file mode 100644 index 00000000000..3b736df378e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected @@ -0,0 +1,6 @@ +0:1(1): preprocessor error: Built-in (pre-defined) macro names cannot be undefined. +0:2(1): preprocessor error: Built-in (pre-defined) macro names cannot be undefined. +0:3(1): preprocessor error: Built-in (pre-defined) macro names cannot be undefined. + + + diff --git a/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c b/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c new file mode 100644 index 00000000000..67ebe73e5cf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c @@ -0,0 +1,2 @@ +/* + */ // diff --git a/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c.expected b/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c.expected new file mode 100644 index 00000000000..8cb7cb9891f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/121-comment-bug-72686.c.expected @@ -0,0 +1,2 @@ + + diff --git a/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c b/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c new file mode 100644 index 00000000000..ae7ea09f67e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c @@ -0,0 +1,16 @@ +/* Original definitions. */ +#define TWO ( 1+1 ) +#define FOUR (2 + 2) +#define SIX (3 + 3) + +/* Redefinitions with whitespace in same places, but different amounts, (so no + * error). */ +#define TWO ( 1+1 ) +#define FOUR (2 + 2) +#define SIX (3/*comment is whitespace*/+ /* collapsed */ /* to */ /* one */ /* space */ 3) + +/* Redefinitions with whitespace in different places. Each of these should + * trigger an error. */ +#define TWO (1 + 1) +#define FOUR ( 2+2 ) +#define SIX (/*not*/3 + 3/*expected*/) diff --git a/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c.expected b/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c.expected new file mode 100644 index 00000000000..602bdef94c2 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/122-redefine-whitespace.c.expected @@ -0,0 +1,22 @@ +0:14(9): preprocessor error: Redefinition of macro TWO + +0:15(9): preprocessor error: Redefinition of macro FOUR + +0:16(9): preprocessor error: Redefinition of macro SIX + + + + + + + + + + + + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c b/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c new file mode 100644 index 00000000000..0b341a381f8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c @@ -0,0 +1,3 @@ +#if 1 +#else garbage +#endif diff --git a/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c.expected b/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c.expected new file mode 100644 index 00000000000..b053b399775 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/123-garbage-after-else-1.c.expected @@ -0,0 +1,4 @@ +0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE +0:1(6): preprocessor error: Unterminated #if + + diff --git a/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c b/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c new file mode 100644 index 00000000000..947ba1885ec --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c @@ -0,0 +1,37 @@ +#define e THIS_SHOULD_NOT_BE_EXPANDED +#define E NOR_THIS +#define p NOT_THIS_EITHER +#define P AND_SURELY_NOT_THIS +#define OK CRAZY_BUT_TRUE_THIS_NEITHER + +/* This one is actually meant to be expanded */ +#define MUST_EXPAND GO + +/* The following are "preprocessing numbers" and should not trigger macro + * expansion. */ +1e +1OK + +/* These are also "preprocessing numbers", so no expansion */ +123e+OK +.23E+OK +1.3e-OK +12.E-OK +123p+OK +.23P+OK +1.3p-OK +12.P-OK +123..OK +.23.OK.OK + +/* Importantly, just before the MUST_EXPAND in each of these, the preceding + * "preprocessing number" ends and we have an actual expression. So the + * MUST_EXPAND macro must be expanded (who would have though?) in each case. */ +123ef+MUST_EXPAND +.23E3-MUST_EXPAND +1.3e--MUST_EXPAND +12.E-&MUST_EXPAND +123p+OK+MUST_EXPAND +.23P+OK;MUST_EXPAND +1.3p-OK-MUST_EXPAND +12.P-OK&MUST_EXPAND diff --git a/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c.expected b/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c.expected new file mode 100644 index 00000000000..6ec588862d6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/124-preprocessing-numbers.c.expected @@ -0,0 +1,37 @@ + + + + + + + + + + + +1e +1OK + + +123e+OK +.23E+OK +1.3e-OK +12.E-OK +123p+OK +.23P+OK +1.3p-OK +12.P-OK +123..OK +.23.OK.OK + + + + +123ef+GO +.23E3-GO +1.3e--GO +12.E-&GO +123p+OK+GO +.23P+OK;GO +1.3p-OK-GO +12.P-OK&GO diff --git a/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c b/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c new file mode 100644 index 00000000000..4ee29f6d93f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c @@ -0,0 +1,27 @@ +/* For GLSL in OpenGL ES, an undefined macro appearing in an #if or #elif + * expression, (other than as an argument to defined) is an error. + * + * Except in the case of a short-circuiting && or || operator, where the + * specification explicitly mandates that there be no error. + */ +#version 300 es + +/* These yield errors */ +#if NOT_DEFINED +#endif + +#if 0 +#elif ALSO_NOT_DEFINED +#endif + +/* But these yield no errors */ +#if 1 || STILL_NOT_DEFINED +Success +#endif + +#if 0 +#elif 0 && WILL_ANYONE_DEFINE_ANYTHING +#else +More success +#endif + diff --git a/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected b/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected new file mode 100644 index 00000000000..616aa912e2f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected @@ -0,0 +1,29 @@ +0:10(16): preprocessor error: undefined macro NOT_DEFINED in expression (illegal in GLES) +0:14(23): preprocessor error: undefined macro ALSO_NOT_DEFINED in expression (illegal in GLES) + + + + + + +#version 300 es + + + + + + + + + + + +Success + + + + + +More success + + diff --git a/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c b/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c new file mode 100644 index 00000000000..4c0d29000a3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c @@ -0,0 +1,5 @@ +#ifdef MACRO garbage +#endif + +#ifndef MORE garbage +#endif diff --git a/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c.expected b/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c.expected new file mode 100644 index 00000000000..82a06f8a3b3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/126-garbage-after-directive.c.expected @@ -0,0 +1,7 @@ +0:1(14): preprocessor error: extra tokens at end of directive +0:4(14): preprocessor error: extra tokens at end of directive + + + + + diff --git a/src/compiler/glsl/glcpp/tests/127-pragma-empty.c b/src/compiler/glsl/glcpp/tests/127-pragma-empty.c new file mode 100644 index 00000000000..0f9b0b3d38f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/127-pragma-empty.c @@ -0,0 +1,3 @@ +/* It seems an odd (and particularly useless) thing to have an empty pragma, + * but we probably shouldn't trigger an error in this case. */ +#pragma diff --git a/src/compiler/glsl/glcpp/tests/127-pragma-empty.c.expected b/src/compiler/glsl/glcpp/tests/127-pragma-empty.c.expected new file mode 100644 index 00000000000..92371a07c32 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/127-pragma-empty.c.expected @@ -0,0 +1,3 @@ + + + diff --git a/src/compiler/glsl/glcpp/tests/128-space-before-hash.c b/src/compiler/glsl/glcpp/tests/128-space-before-hash.c new file mode 100644 index 00000000000..fba9596baf8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/128-space-before-hash.c @@ -0,0 +1,21 @@ + /* Any directive can be preceded by a space. */ + #version 300 + #pragma Testing spaces before hash + # + #line 3 + #define FOO + #ifdef FOO + yes + #endif + #if 0 + #elif defined FOO + yes again + #endif + #if 0 + #else + for the third time, yes! + #endif + #undef FOO + #ifndef FOO + yes, of course + #endif diff --git a/src/compiler/glsl/glcpp/tests/128-space-before-hash.c.expected b/src/compiler/glsl/glcpp/tests/128-space-before-hash.c.expected new file mode 100644 index 00000000000..9babb6fb078 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/128-space-before-hash.c.expected @@ -0,0 +1,21 @@ + +#version 300 +#pragma Testing spaces before hash + +#line 3 + + + yes + + + + yes again + + + + for the third time, yes! + + + + yes, of course + diff --git a/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c b/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c new file mode 100644 index 00000000000..a229179f18c --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c @@ -0,0 +1 @@ +#define 123 456 diff --git a/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c.expected b/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c.expected new file mode 100644 index 00000000000..fd0b41347fa --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/129-define-non-identifier.c.expected @@ -0,0 +1,2 @@ +0:1(9): preprocessor error: #define followed by a non-identifier: 123 +0:1(9): preprocessor error: syntax error, unexpected INTEGER_STRING, expecting FUNC_IDENTIFIER or OBJ_IDENTIFIER diff --git a/src/compiler/glsl/glcpp/tests/130-define-comment.c b/src/compiler/glsl/glcpp/tests/130-define-comment.c new file mode 100644 index 00000000000..33312362cc7 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/130-define-comment.c @@ -0,0 +1,2 @@ +#define /*...*/ FUNC( /*...*/ x /*...*/ ) /*...*/ FOO( /*...*/ x /*...*/ ) +FUNC(bar) diff --git a/src/compiler/glsl/glcpp/tests/130-define-comment.c.expected b/src/compiler/glsl/glcpp/tests/130-define-comment.c.expected new file mode 100644 index 00000000000..d789e29d5a8 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/130-define-comment.c.expected @@ -0,0 +1,2 @@ + +FOO( bar ) diff --git a/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c b/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c new file mode 100644 index 00000000000..240292dad01 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c @@ -0,0 +1 @@ +this file ends with no newline
\ No newline at end of file diff --git a/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c.expected b/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c.expected new file mode 100644 index 00000000000..57800306322 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/131-eof-without-newline.c.expected @@ -0,0 +1 @@ +this file ends with no newline diff --git a/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c b/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c new file mode 100644 index 00000000000..6795e35ea00 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c @@ -0,0 +1 @@ +#define
\ No newline at end of file diff --git a/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c.expected b/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c.expected new file mode 100644 index 00000000000..341e5e2aa67 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/132-eof-without-newline-define.c.expected @@ -0,0 +1 @@ +0:1(1): preprocessor error: #define without macro name diff --git a/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c b/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c new file mode 100644 index 00000000000..56ec5f722c0 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c @@ -0,0 +1 @@ +This file ends with no newline within a comment /*
\ No newline at end of file diff --git a/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c.expected b/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c.expected new file mode 100644 index 00000000000..d186f48761f --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/133-eof-without-newline-comment.c.expected @@ -0,0 +1,2 @@ +0:1(51): preprocessor error: Unterminated comment +This file ends with no newline within a comment diff --git a/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c b/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c new file mode 100644 index 00000000000..3015f0e886e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c @@ -0,0 +1,22 @@ +/*...*/ # /*...*/ version 300 + /*...*/#/*...*/ extension whatever + /*..*/ # /*..*/ pragma ignored +/**/ # /**/ line 4 + /*...*/# /*...*/ ifdef NOT_DEFINED + /*...*/# /*...*/ else + /*..*/ #/*..*/ endif + /*...*/# /*...*/ ifndef ALSO_NOT_DEFINED + /*...*/# /*...*/ else + /*..*/ #/*..*/ endif +/*...*/ # /*...*/ if 0 + /*...*/#/*...*/ elif 1 + /*..*/ # /*..*/ else + /**/ # /**/ endif + /*...*/# /*...*/ define FOO bar + /*..*/ #/*..*/ define FUNC() baz + /*..*/ # /*..*/ define FUNC2(a,b) b a +FOO +FUNC() +FUNC2(x,y) + + diff --git a/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c.expected b/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c.expected new file mode 100644 index 00000000000..760c960cb62 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/134-hash-comment-directive.c.expected @@ -0,0 +1,22 @@ +#version 300 +#extension whatever +#pragma ignored +#line 4 + + + + + + + + + + + + + +bar +baz +y x + + diff --git a/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c b/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c new file mode 100644 index 00000000000..fd96bd64c74 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c @@ -0,0 +1,2 @@ +#define FOO(a,a) which a? +#define BAR(x,y,z,x) so very x diff --git a/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c.expected b/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c.expected new file mode 100644 index 00000000000..bc1a334ed29 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/135-duplicate-parameter.c.expected @@ -0,0 +1,4 @@ +0:1(9): preprocessor error: Duplicate macro parameter "a" +0:2(9): preprocessor error: Duplicate macro parameter "x" + + diff --git a/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c b/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c new file mode 100644 index 00000000000..167d3c8a3cf --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c @@ -0,0 +1,8 @@ +/* The body can include C expressions with ++ and -- */ +a = x++; +b = ++x; +c = x--; +d = --x; +/* But these are not legal in preprocessor expressions. */ +#if x++ > 4 +#endif diff --git a/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected b/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected new file mode 100644 index 00000000000..137921b1695 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected @@ -0,0 +1,8 @@ +0:7(12): preprocessor error: syntax error, unexpected PLUS_PLUS + +a = x++; +b = ++x; +c = x--; +d = --x; + + diff --git a/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c b/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c new file mode 100644 index 00000000000..c8cd47fb57e --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c @@ -0,0 +1,4 @@ +#define FIELD(x) foo.x +#define FIELD_OF(s, x) s.x +FIELD(bar) +FIELD_OF(foo, bar) diff --git a/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c.expected b/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c.expected new file mode 100644 index 00000000000..f9f5be13e01 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/137-expand-macro-after-period.c.expected @@ -0,0 +1,4 @@ + + +foo.bar +foo.bar diff --git a/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c b/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c new file mode 100644 index 00000000000..38967dc57d1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c @@ -0,0 +1,7 @@ +#if 0 +/* + * This multi-line comment needs to be 3 lines to test what's intended. + */ +#else +SUCCESS +#endif diff --git a/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c.expected b/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c.expected new file mode 100644 index 00000000000..0d6ef4d9ad4 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/138-multi-line-comment-in-if-0.c.expected @@ -0,0 +1,7 @@ + + + + + +SUCCESS + diff --git a/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c b/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c new file mode 100644 index 00000000000..30e128db4c5 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c @@ -0,0 +1,5 @@ +#define +#define +#define /*...*/ +#define //... +Errors expected because no macro name is ever given! diff --git a/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c.expected b/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c.expected new file mode 100644 index 00000000000..42b02d1a8a1 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/139-define-without-macro-name.c.expected @@ -0,0 +1,5 @@ +0:1(1): preprocessor error: #define without macro name +0:2(1): preprocessor error: #define without macro name +0:3(1): preprocessor error: #define without macro name +0:4(1): preprocessor error: #define without macro name +Errors expected because no macro name is ever given! diff --git a/src/compiler/glsl/glcpp/tests/140-null-directive.c b/src/compiler/glsl/glcpp/tests/140-null-directive.c new file mode 100644 index 00000000000..1dcb26ef8b9 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/140-null-directive.c @@ -0,0 +1,9 @@ +/* GLSL accepts a null directive. Let's test that in several variations: */ +# + # +/*....*/#/*....*/ + /*..*/ # /*..*/ +#//... + # //... +/*....*/#/**///.. + /*..*/ # /**/ // diff --git a/src/compiler/glsl/glcpp/tests/140-null-directive.c.expected b/src/compiler/glsl/glcpp/tests/140-null-directive.c.expected new file mode 100644 index 00000000000..fa103f60e82 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/140-null-directive.c.expected @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c b/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c new file mode 100644 index 00000000000..a93f3ce35fd --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c @@ -0,0 +1,6 @@ +Line 1 /* Test for a bug where #pragma was throwing off the __LINE__ count. */ +Line __LINE__ /* Line 2 */ +#pragma Line 3 +Line __LINE__ /* Line 4 */ +#pragma Line 5 +Line __LINE__ /* Line 6 */ diff --git a/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c.expected b/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c.expected new file mode 100644 index 00000000000..330731dc800 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/141-pragma-and-__LINE__.c.expected @@ -0,0 +1,6 @@ +Line 1 +Line 2 +#pragma Line 3 +Line 4 +#pragma Line 5 +Line 6 diff --git a/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c new file mode 100644 index 00000000000..b60c04232a6 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c @@ -0,0 +1,94 @@ +/* Macro using defined with a hard-coded identifier (no parentheses) */ +#define is_foo_defined defined /*...*/ foo +#undef foo +#if is_foo_defined +failure +#else +success +#endif +#define foo +#if is_foo_defined +success +#else +failure +#endif + +/* Macro using defined with a hard-coded identifier within parentheses */ +#define is_foo_defined_parens defined /*...*/ ( /*...*/ foo /*...*/ ) // +#define foo +#if is_foo_defined_parens +success +#else +failure +#endif +#undef foo +#if is_foo_defined_parens +failure +#else +success +#endif + +/* Macro using defined with an argument identifier (no parentheses) */ +#define is_defined(arg) defined /*...*/ arg +#define foo bar +#undef bar +#if is_defined(foo) +failure +#else +success +#endif +#define bar bar +#if is_defined(foo) +success +#else +failure +#endif + +/* Macro using defined with an argument identifier within parentheses */ +#define is_defined_parens(arg) defined /*...*/ ( /*...*/ arg /*...*/ ) // +#define foo bar +#define bar bar +#if is_defined_parens(foo) +success +#else +failure +#endif +#undef bar +#if is_defined_parens(foo) +failure +#else +success +#endif + +/* Multiple levels of macro resulting in defined */ +#define X defined A && Y +#define Y defined B && Z +#define Z defined C +#define A +#define B +#define C +#if X +success +#else +failure +#endif +#undef A +#if X +failure +#else +success +#endif +#define A +#undef B +#if X +failure +#else +success +#endif +#define B +#undef C +#if X +failure +#else +success +#endif diff --git a/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c.expected b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c.expected new file mode 100644 index 00000000000..4eca90bc3db --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c.expected @@ -0,0 +1,94 @@ + + + + + + +success + + + +success + + + + + + + + +success + + + + + + + +success + + + + + + + + + +success + + + +success + + + + + + + + + +success + + + + + + + +success + + + + + + + + + + +success + + + + + + + +success + + + + + + +success + + + + + + +success + diff --git a/src/compiler/glsl/glcpp/tests/143-multiple-else.c b/src/compiler/glsl/glcpp/tests/143-multiple-else.c new file mode 100644 index 00000000000..62ad49cf7bb --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/143-multiple-else.c @@ -0,0 +1,6 @@ +#if 0 +#else +int foo; +#else +int bar; +#endif diff --git a/src/compiler/glsl/glcpp/tests/143-multiple-else.c.expected b/src/compiler/glsl/glcpp/tests/143-multiple-else.c.expected new file mode 100644 index 00000000000..00b3328c835 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/143-multiple-else.c.expected @@ -0,0 +1,7 @@ +0:4(1): preprocessor error: multiple #else + + +int foo; + +int bar; + diff --git a/src/compiler/glsl/glcpp/tests/glcpp-test b/src/compiler/glsl/glcpp/tests/glcpp-test new file mode 100755 index 00000000000..3945ee4f6ce --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/glcpp-test @@ -0,0 +1,110 @@ +#!/bin/sh + +if [ ! -z "$srcdir" ]; then + testdir=$srcdir/glsl/glcpp/tests + outdir=`pwd`/glsl/glcpp/tests + glcpp=`pwd`/glsl/glcpp/glcpp +else + testdir=. + outdir=. + glcpp=../glcpp +fi + +trap 'rm $test.valgrind-errors; exit 1' INT QUIT + +usage () +{ + cat <<EOF +Usage: glcpp [options...] + +Run the test suite for mesa's GLSL pre-processor. + +Valid options include: + + --testdir=<DIR> Use tests in the given <DIR> (default is ".") + --valgrind Run the test suite a second time under valgrind +EOF +} + +test_specific_args () +{ + test="$1" + + tr "\r" "\n" < "$test" | grep 'glcpp-args:' | sed -e 's,^.*glcpp-args: *,,' +} + +# Parse command-line options +for option; do + case "${option}" in + "--help") + usage + exit 0 + ;; + "--valgrind") + do_valgrind=yes + ;; + "--testdir="*) + testdir="${option#--testdir=}" + outdir="${outdir}/${option#--testdir=}" + ;; + *) + echo "Unrecognized option: $option" >&2 + echo >&2 + usage + exit 1 + ;; + esac +done + +total=0 +pass=0 +clean=0 + +mkdir -p $outdir + +echo "====== Testing for correctness ======" +for test in $testdir/*.c; do + out=$outdir/${test##*/}.out + + printf "Testing $test... > $out ($test.expected) " + $glcpp $(test_specific_args $test) < $test > $out 2>&1 + total=$((total+1)) + if cmp $test.expected $out >/dev/null 2>&1; then + echo "PASS" + pass=$((pass+1)) + else + echo "FAIL" + diff -u $test.expected $out + fi +done + +echo "" +echo "$pass/$total tests returned correct results" +echo "" + +if [ "$do_valgrind" = "yes" ]; then + echo "====== Testing for valgrind cleanliness ======" + for test in $testdir/*.c; do + printf "Testing $test with valgrind..." + valgrind --error-exitcode=31 --log-file=$test.valgrind-errors $glcpp $(test_specific_args $test) < $test >/dev/null 2>&1 + if [ "$?" = "31" ]; then + echo "ERRORS" + cat $test.valgrind-errors + else + echo "CLEAN" + clean=$((clean+1)) + rm $test.valgrind-errors + fi + done + + echo "" + echo "$pass/$total tests returned correct results" + echo "$clean/$total tests are valgrind-clean" +fi + +if [ "$pass" = "$total" ] && [ "$do_valgrind" != "yes" ] || [ "$pass" = "$total" ]; then + exit 0 +else + exit 1 +fi + diff --git a/src/compiler/glsl/glcpp/tests/glcpp-test-cr-lf b/src/compiler/glsl/glcpp/tests/glcpp-test-cr-lf new file mode 100755 index 00000000000..c75370f48c3 --- /dev/null +++ b/src/compiler/glsl/glcpp/tests/glcpp-test-cr-lf @@ -0,0 +1,141 @@ +#!/bin/sh + +# The build system runs this test from a different working directory, and may +# be in a build directory entirely separate from the source. So if the +# "srcdir" variable is set, we must use it to locate the test files and the +# glcpp-test script. + +if [ ! -z "$srcdir" ]; then + testdir="$srcdir/glsl/glcpp/tests" + glcpp_test="$srcdir/glsl/glcpp/tests/glcpp-test" +else + testdir=. + glcpp_test=./glcpp-test +fi + +total=0 +pass=0 + +# This supports a pipe that doesn't destroy the exit status of first command +# +# http://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another +stdintoexitstatus() { + read exitstatus + return $exitstatus +} + +run_test () +{ + cmd="$1" + + total=$((total+1)) + + if [ "$VERBOSE" = "yes" ]; then + if $cmd; then + echo "PASS" + pass=$((pass+1)) + else + echo "FAIL" + fi + else + # This is "$cmd | tail -2" but with the exit status of "$cmd" not "tail -2" + if (((($cmd; echo $? >&3) | tail -2 | head -1 >&4) 3>&1) | stdintoexitstatus) 4>&1; then + echo "PASS" + pass=$((pass+1)) + else + echo "FAIL" + fi + fi +} + +usage () +{ + cat <<EOF +Usage: glcpp-cr-lf [options...] + +Run the entire glcpp-test suite several times, each time with each source +file transformed to use a non-standard line-termination character. Each +entire run with a different line-termination character is considered a +single test. + +Valid options include: + + -v|--verbose Print all output from the various sub-tests +EOF +} + +# Parse command-line options +for option; do + case "${option}" in + -v|--verbose) + VERBOSE=yes; + ;; + *) + echo "Unrecognized option: $option" >&2 + echo >&2 + usage + exit 1 + ;; + esac +done + +# All tests depend on the .out files being present. So first do a +# normal run of the test suite, (silently) just to create the .out +# files as a side effect. +rm -rf ./subtest-lf +mkdir subtest-lf +for file in "$testdir"/*.c; do + base=$(basename "$file") + cp "$file" subtest-lf +done + +${glcpp_test} --testdir=subtest-lf >/dev/null 2>&1 + +echo "===== Testing with \\\\r line terminators (old Mac format) =====" + +# Prepare test files with '\r' instead of '\n' +rm -rf ./subtest-cr +mkdir subtest-cr +for file in "$testdir"/*.c; do + base=$(basename "$file") + tr "\n" "\r" < "$file" > subtest-cr/"$base" + cp `pwd`/glsl/glcpp/tests/subtest-lf/"$base".out subtest-cr/"$base".expected +done + +run_test "${glcpp_test} --testdir=subtest-cr" + +echo "===== Testing with \\\\r\\\\n line terminators (DOS format) =====" + +# Prepare test files with '\r\n' instead of '\n' +rm -rf ./subtest-cr-lf +mkdir subtest-cr-lf +for file in "$testdir"/*.c; do + base=$(basename "$file") + sed -e 's/$/
/' < "$file" > subtest-cr-lf/"$base" + cp `pwd`/glsl/glcpp/tests/subtest-lf/"$base".out subtest-cr-lf/"$base".expected +done + +run_test "${glcpp_test} --testdir=subtest-cr-lf" + +echo "===== Testing with \\\\n\\\\r (bizarre, but allowed by GLSL spec.) =====" + +# Prepare test files with '\n\r' instead of '\n' +rm -rf ./subtest-lf-cr +mkdir subtest-lf-cr +for file in "$testdir"/*.c; do + base=$(basename "$file") + sed -e 's/$/
/' < "$file" | tr "\n\r" "\r\n" > subtest-lf-cr/"$base" + cp `pwd`/glsl/glcpp/tests/subtest-lf/"$base".out subtest-lf-cr/"$base".expected +done + +run_test "${glcpp_test} --testdir=subtest-lf-cr" + +echo "" +echo "$pass/$total tests returned correct results" +echo "" + +if [ "$pass" = "$total" ]; then + exit 0 +else + exit 1 +fi |