--- /dev/null
+
+
+
+
+
+
+struct A
+{
+ float4 a;
+ float4 b;
+ float4 c = { 1, 2, 3, 4 };
+ float4 d = {({ {(({ 1, 2, 3, 4 }))} })}, { { 1, 2, 3, 4 } };
+};
+
+void main()
+{
+}
+
--- /dev/null
+#define EMP1(a)\r
+#define EMP2(a, b)\r
+\r
+#define EXP1(a) = a\r
+#define EXP2(a, b) = a, b\r
+\r
+struct A\r
+{\r
+ float4 a EMP1({1,2,3,4}); // No PP arg errors\r
+ float4 b EMP2({({{(({1,2,3,4}))}})}, {{1,2,3,4}}); // No PP arg errors\r
+ float4 c EXP1({1,2,3,4}); // ERROR: No PP arg errors, but init error\r
+ float4 d EXP2({({{(({1,2,3,4}))}})}, {{1,2,3,4}}); // ERROR: No PP arg errors, but init error\r
+};\r
+\r
+void main()\r
+{\r
+}\r
diff -b $BASEDIR/hlsl.noSemantic.functionality1.comp.out $TARGETDIR/hlsl.noSemantic.functionality1.comp.out || HASERROR=1
#
+# Testing HLSL-specific PP feature expansion
+#
+$EXE -D -E hlsl.pp.expand.frag > $TARGETDIR/hlsl.pp.expand.frag.out 2> $TARGETDIR/hlsl.pp.expand.frag.err
+diff -b $BASEDIR/hlsl.pp.expand.frag.out $TARGETDIR/hlsl.pp.expand.frag.out || HASERROR=1
+diff -b $BASEDIR/hlsl.pp.expand.frag.err $TARGETDIR/hlsl.pp.expand.frag.err || HASERROR=1
+
+#
# Final checking
#
if [ $HASERROR -eq 0 ]
}
MacroSymbol* macro = macroAtom == 0 ? nullptr : lookupMacroDef(macroAtom);
- int depth = 0;
// no recursive expansions
if (macro != nullptr && macro->busy)
size_t arg = 0;
bool tokenRecorded = false;
do {
- depth = 0;
- while (1) {
+ TVector<char> nestStack;
+ while (true) {
token = scanToken(ppToken);
if (token == EndOfInput || token == tMarkerInput::marker) {
parseContext.ppError(loc, "End of input in macro", "macro expansion", atomStrings.getString(macroAtom));
}
if (in->mac->args.size() == 0 && token != ')')
break;
- if (depth == 0 && (token == ',' || token == ')'))
+ if (nestStack.size() == 0 && (token == ',' || token == ')'))
break;
if (token == '(')
- depth++;
- if (token == ')')
- depth--;
+ nestStack.push_back(')');
+ else if (token == '{' && parseContext.isReadingHLSL())
+ nestStack.push_back('}');
+ else if (nestStack.size() > 0 && token == nestStack.back())
+ nestStack.pop_back();
in->args[arg]->putToken(token, ppToken);
tokenRecorded = true;
}
+ // end of single argument scan
+
if (token == ')') {
+ // closing paren of call
if (in->mac->args.size() == 1 && tokenRecorded == 0)
break;
arg++;
}
arg++;
} while (arg < in->mac->args.size());
+ // end of all arguments scan
if (arg < in->mac->args.size())
parseContext.ppError(loc, "Too few args in Macro", "macro expansion", atomStrings.getString(macroAtom));
else if (token != ')') {
- depth=0;
+ // Error recover code; find end of call, if possible
+ int depth = 0;
while (token != EndOfInput && (depth > 0 || token != ')')) {
- if (token == ')')
+ if (token == ')' || token == '}')
depth--;
token = scanToken(ppToken);
- if (token == '(')
+ if (token == '(' || token == '{')
depth++;
}