Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glslang
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
deqp-deps
glslang
Commits
d2762564
Commit
d2762564
authored
9 years ago
by
John Kessenich
Browse files
Options
Downloads
Patches
Plain Diff
Preprocessor: Prevent (and give an error on) expression division by 0.
parent
e9022e1f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Test/baseResults/cppComplexExpr.vert.out
+5
-1
5 additions, 1 deletion
Test/baseResults/cppComplexExpr.vert.out
Test/cppComplexExpr.vert
+7
-0
7 additions, 0 deletions
Test/cppComplexExpr.vert
glslang/MachineIndependent/preprocessor/Pp.cpp
+7
-0
7 additions, 0 deletions
glslang/MachineIndependent/preprocessor/Pp.cpp
with
19 additions
and
1 deletion
Test/baseResults/cppComplexExpr.vert.out
+
5
−
1
View file @
d2762564
...
...
@@ -42,8 +42,12 @@ ERROR: 0:3006: '#undef' : predefined names can't be (un)defined: __LINE__
ERROR: 0:3007: '#undef' : predefined names can't be (un)defined: __FILE__
ERROR: 0:3008: '#undef' : predefined names can't be (un)defined: __VERSION__
ERROR: 0:3009: '#undef' : names beginning with "GL_" can't be (un)defined: GL_SOME_EXTENSION
ERROR: 0:4000: 'preprocessor evaluation' : division by 0
ERROR: 0:0: 'preprocessor evaluation' : division by 0
ERROR: 0:3: 'preprocessor evaluation' : bad expression
ERROR: 0:3: 'preprocessor evaluation' : division by 0
ERROR: 0:10001: '' : missing #endif
ERROR: 4
4
compilation errors. No code generated.
ERROR: 4
8
compilation errors. No code generated.
Shader version: 300
...
...
This diff is collapsed.
Click to expand it.
Test/cppComplexExpr.vert
+
7
−
0
View file @
d2762564
...
...
@@ -171,6 +171,13 @@ float c = foobar(1.1, 2.2
#undef __VERSION__
#undef GL_SOME_EXTENSION
#line 4000
#line 200 % 0 // ERROR, div by 0
#if __LINE__ / 0 // ERROR, div by 0
#endif
#if 7% // ERROR incomplete expression
#line 10000
#if 0
// ERROR, EOF
\ No newline at end of file
This diff is collapsed.
Click to expand it.
glslang/MachineIndependent/preprocessor/Pp.cpp
+
7
−
0
View file @
d2762564
...
...
@@ -505,6 +505,13 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
token
=
scanToken
(
ppToken
);
token
=
eval
(
token
,
binop
[
op
].
precedence
,
shortCircuit
,
res
,
err
,
ppToken
);
if
(
binop
[
op
].
op
==
op_div
||
binop
[
op
].
op
==
op_mod
)
{
if
(
res
==
0
)
{
parseContext
.
ppError
(
loc
,
"division by 0"
,
"preprocessor evaluation"
,
""
);
res
=
1
;
}
}
res
=
binop
[
op
].
op
(
leftSide
,
res
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment