Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
2eb13550
Commit
2eb13550
authored
Jun 07, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GLSL: Fix #396: Error when 'defined' comes from macro expansion.
parent
65755667
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
1 deletion
+24
-1
cppSimple.vert.out
Test/baseResults/cppSimple.vert.out
+3
-1
cppSimple.vert
Test/cppSimple.vert
+10
-0
Pp.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
+8
-0
PpContext.h
glslang/MachineIndependent/preprocessor/PpContext.h
+3
-0
No files found.
Test/baseResults/cppSimple.vert.out
View file @
2eb13550
...
...
@@ -90,8 +90,10 @@ ERROR: 12:9504: '#if' : unexpected tokens following directive
ERROR: 12:9506: '#error' : \ 377
ERROR: 12:9507: '#error' : \ 376
ERROR: 12:9508: '#error' : \ 377
ERROR: 12:9602: 'defined' : cannot use in preprocessor expression when expanded from macros
ERROR: 12:9603: '#error' : DEF_DEFINED then
ERROR: 12:10002: '' : missing #endif
ERROR:
88
compilation errors. No code generated.
ERROR:
90
compilation errors. No code generated.
Shader version: 400
...
...
Test/cppSimple.vert
View file @
2eb13550
...
...
@@ -337,6 +337,16 @@ int aoeua = FOOOM;
#error \ 376
#error \377
// ERROR for macro expansion to yield 'defined'
#line 9600
#define DEF_MAC
#define DEF_DEFINED defined
#if DEF_DEFINED DEF_MAC
#error DEF_DEFINED then
#else
#error DEF_DEFINED else
#endif
#line 10000
#if 1
#else
...
...
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
2eb13550
...
...
@@ -393,6 +393,14 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
TSourceLoc
loc
=
ppToken
->
loc
;
// because we sometimes read the newline before reporting the error
if
(
token
==
PpAtomIdentifier
)
{
if
(
strcmp
(
"defined"
,
ppToken
->
name
)
==
0
)
{
if
(
isMacroInput
())
{
if
(
parseContext
.
relaxedErrors
())
parseContext
.
ppWarn
(
ppToken
->
loc
,
"nonportable when expanded from macros for preprocessor expression"
,
"defined"
,
""
);
else
parseContext
.
ppError
(
ppToken
->
loc
,
"cannot use in preprocessor expression when expanded from macros"
,
"defined"
,
""
);
}
bool
needclose
=
0
;
token
=
scanToken
(
ppToken
);
if
(
token
==
'('
)
{
...
...
glslang/MachineIndependent/preprocessor/PpContext.h
View file @
2eb13550
...
...
@@ -200,6 +200,7 @@ public:
virtual
void
ungetch
()
=
0
;
virtual
bool
peekPasting
()
{
return
false
;
}
// true when about to see ##
virtual
bool
endOfReplacementList
()
{
return
false
;
}
// true when at the end of a macro replacement list (RHS of #define)
virtual
bool
isMacroInput
()
{
return
false
;
}
// Will be called when we start reading tokens from this instance
virtual
void
notifyActivated
()
{}
...
...
@@ -306,6 +307,7 @@ protected:
void
ungetChar
()
{
inputStack
.
back
()
->
ungetch
();
}
bool
peekPasting
()
{
return
!
inputStack
.
empty
()
&&
inputStack
.
back
()
->
peekPasting
();
}
bool
endOfReplacementList
()
{
return
inputStack
.
empty
()
||
inputStack
.
back
()
->
endOfReplacementList
();
}
bool
isMacroInput
()
{
return
inputStack
.
size
()
>
0
&&
inputStack
.
back
()
->
isMacroInput
();
}
static
const
int
maxIfNesting
=
64
;
...
...
@@ -329,6 +331,7 @@ protected:
virtual
void
ungetch
()
override
{
assert
(
0
);
}
bool
peekPasting
()
override
{
return
prepaste
;
}
bool
endOfReplacementList
()
override
{
return
mac
->
body
.
atEnd
();
}
bool
isMacroInput
()
override
{
return
true
;
}
MacroSymbol
*
mac
;
TVector
<
TokenStream
*>
args
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment