for ( int a = 0; a <= 20; a++) { if (ga==0) a = 4; } // ERROR\r
for (float a = 0.0; a <= 20.0; a += 2.0);\r
for (float a = 0.0; a != 20.0; a -= 2.0) { if (ga==0) ga = 4; }\r
- for (float a = 0.0; a == 20.0; a--) for (float a = 0.0; a == 20.0; a--); // two different 'a's, everything okay\r
+ for (float a = 0.0; a == 20.0; a--) for (float a = 0.0; a == 20.0; a--); // two different a, everything okay\r
for (float a = 0.0; a <= 20.0; a += 2.0);\r
for (float a = 0.0; a <= 20.0; a += 2.0);\r
for (float a = 0.0; a > 2.0 * 20.0; a += v3.y);\r
\r
float f; // ERROR: redefinition\r
float tan; // okay, built-in is in an outer scope\r
-float sin(float x); // ERROR: can't redefine built-in functions\r
-float cos(float x) // ERROR: can't redefine built-in functions\r
+float sin(float x); // ERROR: cant redefine built-in functions\r
+float cos(float x) // ERROR: cant redefine built-in functions\r
{\r
return 1.0;\r
}\r
int z = z; // ERROR: z not previously defined.\r
}\r
{\r
- int x = x; // x is initialized to '1'\r
+ int x = x; // x is initialized to 1\r
}\r
\r
struct S \r
int x; \r
};\r
{\r
- S S = S(0); // 'S' is only visible as a struct and constructor \r
- S.x; // 'S' is now visible as a variable\r
+ S S = S(0); // S is only visible as a struct and constructor \r
+ S.x; // S is now visible as a variable\r
}\r
}\r
ERROR: 0:15: 'line continuation' : not supported for this version or the enabled extensions \r
ERROR: 0:18: '#error' : e3 \r
ERROR: 0:24: 'line continuation' : not supported for this version or the enabled extensions \r
-ERROR: 9 compilation errors. No code generated.\r
+ERROR: 0:28: 'line continuation' : not supported for this version or the enabled extensions \r
+ERROR: 0:29: 'non-language character ($) in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:29: 'non-language character (") in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:29: 'non-language character (') in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:31: 'non-language character (@) in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:32: 'non-language character (@) in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:32: 'non-language character (@) in comment' : not supported for this version or the enabled extensions \r
+ERROR: 0:33: 'non-language character (@) in comment' : not supported for this version or the enabled extensions \r
+ERROR: 17 compilation errors. No code generated.\r
\r
\r
ERROR: node is still EOpNull!\r
vec4 b = a; \
return b;
}
+
+// aoeuntheo unatehutna \ antaehnathe
+// anteonuth $ natohe " '
+// anteonuth natohe
#error e1\r
\r
float f\\r
-oo; // same as 'float foo;'\r
+oo; // same as float foo;\r
\r
#error e2\r
\r
vec4 b = a; \\r
return b; \r
}\r
+\r
+// aoeuntheo unatehutna \ antaehnathe \r
+// anteonuth $ natohe " '\r
+// anteonuth natohe\r
+/*@*/\r
+/* *@/*/\r
+//@\r
//
void TParseContext::lineContinuationCheck(TSourceLoc loc)
{
+ if ((profile == EEsProfile && version >= 300) ||
+ (profile != EEsProfile && version >= 420))
+ return;
+
const char* message = "line continuation";
if (messages & EShMsgRelaxedErrors) {
warn(loc, "not allowed in this version", message, "");
}
}
+//
+// See if this version/profile allows use the given character in a comment.
+//
+void TParseContext::commentCharacterCheck(TSourceLoc loc, int ch)
+{
+ if ((profile == EEsProfile && version >= 300) ||
+ (profile != EEsProfile))
+ return;
+
+ TString message("non-language character (");
+ if (ch > 32 && ch <= 126)
+ message.push_back(ch);
+ message.append(") in comment");
+ if (messages & EShMsgRelaxedErrors) {
+ warn(loc, "not allowed in this version", message.c_str(), "");
+ } else {
+ requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, message.c_str());
+ profileRequires(loc, EEsProfile, 300, 0, message.c_str());
+ profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 0, message.c_str());
+ }
+}
+
bool TParseContext::builtInName(const TString& identifier)
{
return identifier.compare(0, 3, "gl_") == 0;
bool reservedErrorCheck(TSourceLoc, const TString&);
void reservedPpErrorCheck(TSourceLoc, const char* name, const char* op);
void lineContinuationCheck(TSourceLoc);
+ void commentCharacterCheck(TSourceLoc, int ch);
bool builtInName(const TString&);
void handlePragma(TSourceLoc, const TVector<TString>&);
for (elsetracker = 0; elsetracker < maxIfNesting; elsetracker++)
elseSeen[elsetracker] = false;
elsetracker = 0;
+
+ for (int c = 0; c < 256; ++c)
+ languageCharacters[c] = false;
+ for (int c = 'a'; c <= 'z'; ++c)
+ languageCharacters[c] = true;
+ for (int c = 'A'; c <= 'Z'; ++c)
+ languageCharacters[c] = true;
+ languageCharacters['_'] = true;
+ for (int c = '0'; c <= '9'; ++c)
+ languageCharacters[c] = true;
+ languageCharacters['.'] = true;
+ languageCharacters['+'] = true;
+ languageCharacters['-'] = true;
+ languageCharacters['/'] = true;
+ languageCharacters['*'] = true;
+ languageCharacters['%'] = true;
+ languageCharacters['<'] = true;
+ languageCharacters['>'] = true;
+ languageCharacters['['] = true;
+ languageCharacters[']'] = true;
+ languageCharacters['('] = true;
+ languageCharacters[')'] = true;
+ languageCharacters['{'] = true;
+ languageCharacters['}'] = true;
+ languageCharacters['^'] = true;
+ languageCharacters['|'] = true;
+ languageCharacters['&'] = true;
+ languageCharacters['~'] = true;
+ languageCharacters['='] = true;
+ languageCharacters['!'] = true;
+ languageCharacters[':'] = true;
+ languageCharacters[';'] = true;
+ languageCharacters[','] = true;
+ languageCharacters['?'] = true;
+ languageCharacters['#'] = true;
+
+ // white space
+ languageCharacters[' '] = true;
+ for (int c = 9; c <= 13; ++c)
+ languageCharacters[c] = true;
}
TPpContext::~TPpContext()
InputSrc *currentInput;
bool errorOnVersion;
+ bool languageCharacters[256];
+
//
// from Pp.cpp
//
else
ch = nextch;
}
- }
+ } else if (ch > 0 && ! pp->languageCharacters[ch])
+ pp->parseContext.commentCharacterCheck(ppToken->loc, ch);
} while (ch != '\n' && ch != EOF);
if (ch == EOF)
return EOF;
while (ch != '*') {
if (ch == '\n')
nlcount++;
- if (ch == EOF) {
+ else if (ch == EOF) {
pp->parseContext.error(ppToken->loc, "EOF in comment", "comment", "");
return EOF;
- }
+ } else if (! pp->languageCharacters[ch])
+ pp->parseContext.commentCharacterCheck(ppToken->loc, ch);
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
}
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
pp->parseContext.error(ppToken->loc, "EOF in comment", "comment", "");
return EOF;
- }
+ } else if (! pp->languageCharacters[ch])
+ pp->parseContext.commentCharacterCheck(ppToken->loc, ch);
} while (ch != '/');
if (nlcount)
return '\n';