ch = getChar();
// 1.#INF or -1.#INF
- if (parseContext.intermediate.getSource() == EShSourceHlsl && ch == '#') {
+ if (ch == '#' && (ifdepth > 0 || parseContext.intermediate.getSource() == EShSourceHlsl)) {
if ((len < 2) ||
(len == 2 && ppToken->name[0] != '1') ||
(len == 3 && ppToken->name[1] != '1' && !(ppToken->name[0] == '-' || ppToken->name[0] == '+')) ||
// Suffix:
bool isFloat16 = false;
if (ch == 'l' || ch == 'L') {
- if (parseContext.intermediate.getSource() == EShSourceGlsl)
+ if (ifdepth == 0 && parseContext.intermediate.getSource() == EShSourceGlsl)
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
- if (! HasDecimalOrExponent)
+ if (ifdepth == 0 && !HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
if (parseContext.intermediate.getSource() == EShSourceGlsl) {
int ch2 = getChar();
isDouble = 1;
}
} else if (ch == 'h' || ch == 'H') {
- if (parseContext.intermediate.getSource() == EShSourceGlsl)
+ if (ifdepth == 0 && parseContext.intermediate.getSource() == EShSourceGlsl)
parseContext.float16Check(ppToken->loc, "half floating-point suffix");
- if (!HasDecimalOrExponent)
+ if (ifdepth == 0 && !HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
if (parseContext.intermediate.getSource() == EShSourceGlsl) {
int ch2 = getChar();
isFloat16 = true;
}
} else if (ch == 'f' || ch == 'F') {
- parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
- if (! parseContext.relaxedErrors())
+ if (ifdepth == 0)
+ parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
+ if (ifdepth == 0 && !parseContext.relaxedErrors())
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
- if (! HasDecimalOrExponent)
+ if (ifdepth == 0 && !HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
saveName(ch);
} else
ppToken->name[len] = '\0';
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
- pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
+ if (pp->ifdepth == 0) {
+ pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit hexadecimal literal");
- pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
- Num_Int64_Extensions, Int64_Extensions, "64-bit hexadecimal literal");
+ pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
+ Num_Int64_Extensions, Int64_Extensions, "64-bit hexadecimal literal");
+ }
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
} else if (isInt16) {
- if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
- pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
- "16-bit hexadecimal literal");
- pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
- Num_Int16_Extensions, Int16_Extensions, "16-bit hexadecimal literal");
+ if (pp->ifdepth == 0) {
+ if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
+ pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
+ "16-bit hexadecimal literal");
+ pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
+ Num_Int16_Extensions, Int16_Extensions, "16-bit hexadecimal literal");
+ }
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
pp->parseContext.ppError(ppToken->loc, "octal literal too big", "", "");
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
- pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
+ if (pp->ifdepth == 0) {
+ pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit octal literal");
- pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
- Num_Int64_Extensions, Int64_Extensions, "64-bit octal literal");
+ pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
+ Num_Int64_Extensions, Int64_Extensions, "64-bit octal literal");
+ }
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
} else if (isInt16) {
- if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
- pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
- "16-bit octal literal");
- pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
- Num_Int16_Extensions, Int16_Extensions, "16-bit octal literal");
+ if (pp->ifdepth == 0) {
+ if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
+ pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
+ "16-bit octal literal");
+ pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
+ Num_Int16_Extensions, Int16_Extensions, "16-bit octal literal");
+ }
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
}
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
- pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
+ if (pp->ifdepth == 0) {
+ pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit literal");
- pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
- Num_Int64_Extensions, Int64_Extensions, "64-bit literal");
+ pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
+ Num_Int64_Extensions, Int64_Extensions, "64-bit literal");
+ }
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
} else if (isInt16) {
- if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
+ if (pp->ifdepth == 0 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
- "16-bit literal");
+ "16-bit literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
Num_Int16_Extensions, Int16_Extensions, "16-bit literal");
}
continue;
break;
case PpAtomConstString:
- if (parseContext.intermediate.getSource() != EShSourceHlsl) {
+ if (ifdepth == 0 && parseContext.intermediate.getSource() != EShSourceHlsl) {
// HLSL allows string literals.
parseContext.ppError(ppToken.loc, "string literals not supported", "\"\"", "");
continue;