Fix public bug 1277: #line L sets the next line to L+1 or just L, based on the version of the language.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@29277 e7fa87d3-cd2b-0410-9028-fcbf551c1848
diff --git a/Test/100.frag b/Test/100.frag
index ddf7ba0..4097916 100644
--- a/Test/100.frag
+++ b/Test/100.frag
@@ -196,4 +196,7 @@
#pragma STDGL invariant(all)
+#line 3000
+#error line of this error should be 3000
+
uniform samplerExternalOES badExt; // syntax ERROR
diff --git a/Test/150.vert b/Test/150.vert
index 9c0beb1..8e1db4d 100644
--- a/Test/150.vert
+++ b/Test/150.vert
@@ -20,3 +20,6 @@
int a[];
};
int a[5]; // ERROR, resizing user-block member
+
+#line 3000
+#error line of this error should be 3001
diff --git a/Test/baseResults/100.frag.out b/Test/baseResults/100.frag.out
index e4a5b7a..783e4d7 100644
--- a/Test/baseResults/100.frag.out
+++ b/Test/baseResults/100.frag.out
@@ -82,8 +82,9 @@
ERROR: 0:193: '.length' : not supported for this version or the enabled extensions
ERROR: 0:194: '.' : cannot apply to an array: method
ERROR: 0:194: 'a' : can't use function syntax on variable
-ERROR: 0:199: '' : syntax error
-ERROR: 75 compilation errors. No code generated.
+ERROR: 0:3000: '#error' : line of this error should be 3000
+ERROR: 0:3002: '' : syntax error
+ERROR: 76 compilation errors. No code generated.
Shader version: 100
diff --git a/Test/baseResults/150.vert.out b/Test/baseResults/150.vert.out
index 85f7e43..e31447d 100644
--- a/Test/baseResults/150.vert.out
+++ b/Test/baseResults/150.vert.out
@@ -1,6 +1,7 @@
150.vert
ERROR: 0:22: 'a' : cannot redeclare a user-block member array
-ERROR: 1 compilation errors. No code generated.
+ERROR: 0:3001: '#error' : line of this error should be 3001
+ERROR: 2 compilation errors. No code generated.
Shader version: 150
diff --git a/Test/baseResults/cppComplexExpr.vert.out b/Test/baseResults/cppComplexExpr.vert.out
index e5f8701..0cda42e 100644
--- a/Test/baseResults/cppComplexExpr.vert.out
+++ b/Test/baseResults/cppComplexExpr.vert.out
@@ -33,8 +33,9 @@
ERROR: 0:153: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile UNDEF
ERROR: 0:156: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile UNDEF2
ERROR: 0:159: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile UNDEF2
-ERROR: 0:10002: '' : missing #endif
-ERROR: 35 compilation errors. No code generated.
+ERROR: 0:3000: '#error' : line of this error should be 3000
+ERROR: 0:10001: '' : missing #endif
+ERROR: 36 compilation errors. No code generated.
Shader version: 300
diff --git a/Test/baseResults/cppSimple.vert.out b/Test/baseResults/cppSimple.vert.out
index 75b14e5..cbe3c52 100644
--- a/Test/baseResults/cppSimple.vert.out
+++ b/Test/baseResults/cppSimple.vert.out
@@ -61,28 +61,28 @@
ERROR: 0:236: '#error' : good continuation
ERROR: 0:238: '#' : invalid directive: flizbit
ERROR: 0:242: '#' : invalid directive: directive
-ERROR: 0:12001: '#error' : line should be 12001
-ERROR: 7:13001: '#error' : line should be 13001 , string 7
-ERROR: 7:14014: '#error' : line should be 14014 , string 7
-ERROR: 12:14014: '#error' : line should be 14014 , string 12
-ERROR: 12:14026: '#error' : line should be 14026 , string 12
-ERROR: 12:1234: '#line' : unexpected tokens following directive
-ERROR: 12:1237: '#line' : unexpected tokens following directive
-ERROR: 12:20001: '#error' : line should be 20001
-ERROR: 12:20011: '#error' : line should be 20011
-ERROR: 12:20021: '#error' : line should be 20021
-ERROR: 12:20046: '#define' : Macro redefined; different substitutions: SPACE_IN_MIDDLE
-ERROR: 12:20052: '#error' : good evaluation 1
-ERROR: 12:20056: '#error' : good evaluation 2
-ERROR: 12:9001: 'preprocessor evaluation' : expected ')'
-ERROR: 12:9003: '#if' : unexpected tokens following directive
+ERROR: 0:12000: '#error' : line should be 12000
+ERROR: 7:13000: '#error' : line should be 13000 , string 7
+ERROR: 7:14013: '#error' : line should be 14013 , string 7
+ERROR: 12:14013: '#error' : line should be 14013 , string 12
+ERROR: 12:14025: '#error' : line should be 14025 , string 12
+ERROR: 12:1233: '#line' : unexpected tokens following directive
+ERROR: 12:1236: '#line' : unexpected tokens following directive
+ERROR: 12:20000: '#error' : line should be 20000
+ERROR: 12:20010: '#error' : line should be 20010
+ERROR: 12:20020: '#error' : line should be 20020
+ERROR: 12:20045: '#define' : Macro redefined; different substitutions: SPACE_IN_MIDDLE
+ERROR: 12:20051: '#error' : good evaluation 1
+ERROR: 12:20055: '#error' : good evaluation 2
+ERROR: 12:9000: 'preprocessor evaluation' : expected ')'
+ERROR: 12:9002: '#if' : unexpected tokens following directive
+ERROR: 12:9014: 'macro expansion' : expected '(' following FOOOM
+ERROR: 12:9014: 'FOOOM' : undeclared identifier
+ERROR: 12:9014: '=' : cannot convert from 'float' to 'int'
ERROR: 12:9015: 'macro expansion' : expected '(' following FOOOM
-ERROR: 12:9015: 'FOOOM' : undeclared identifier
-ERROR: 12:9015: '=' : cannot convert from 'float' to 'int'
-ERROR: 12:9016: 'macro expansion' : expected '(' following FOOOM
-ERROR: 12:9017: 'preprocessor evaluation' : can't evaluate expression
-ERROR: 12:9017: 'preprocessor evaluation' : bad expression
-ERROR: 12:10003: '' : missing #endif
+ERROR: 12:9016: 'preprocessor evaluation' : can't evaluate expression
+ERROR: 12:9016: 'preprocessor evaluation' : bad expression
+ERROR: 12:10002: '' : missing #endif
ERROR: 79 compilation errors. No code generated.
@@ -161,23 +161,23 @@
0:202 'f' (double)
0:202 Constant:
0:202 0.000800
-12:20032 Function Definition: foo234( (void)
-12:20032 Function Parameters:
-12:20034 Sequence
-12:20034 move second child to first child (4-component vector of float)
-12:20034 gl_Position: direct index for structure (gl_Position 4-component vector of float)
-12:20034 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out implicitly-sized array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out implicitly-sized array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
-12:20034 Constant:
-12:20034 0 (const uint)
-12:20034 Constant:
-12:20034 6.000000
-12:20034 6.000000
-12:20034 6.000000
-12:20034 6.000000
-12:9012 Sequence
-12:9012 move second child to first child (int)
-12:9012 'R1' (int)
-12:9012 'RECURSE' (int)
+12:20031 Function Definition: foo234( (void)
+12:20031 Function Parameters:
+12:20033 Sequence
+12:20033 move second child to first child (4-component vector of float)
+12:20033 gl_Position: direct index for structure (gl_Position 4-component vector of float)
+12:20033 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out implicitly-sized array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out implicitly-sized array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
+12:20033 Constant:
+12:20033 0 (const uint)
+12:20033 Constant:
+12:20033 6.000000
+12:20033 6.000000
+12:20033 6.000000
+12:20033 6.000000
+12:9011 Sequence
+12:9011 move second child to first child (int)
+12:9011 'R1' (int)
+12:9011 'RECURSE' (int)
0:? Linker Objects
0:? 'sum' (float)
0:? 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out implicitly-sized array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out implicitly-sized array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
@@ -273,23 +273,23 @@
0:202 'f' (double)
0:202 Constant:
0:202 0.000800
-12:20032 Function Definition: foo234( (void)
-12:20032 Function Parameters:
-12:20034 Sequence
-12:20034 move second child to first child (4-component vector of float)
-12:20034 gl_Position: direct index for structure (gl_Position 4-component vector of float)
-12:20034 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out 1-element array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out 1-element array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
-12:20034 Constant:
-12:20034 0 (const uint)
-12:20034 Constant:
-12:20034 6.000000
-12:20034 6.000000
-12:20034 6.000000
-12:20034 6.000000
-12:9012 Sequence
-12:9012 move second child to first child (int)
-12:9012 'R1' (int)
-12:9012 'RECURSE' (int)
+12:20031 Function Definition: foo234( (void)
+12:20031 Function Parameters:
+12:20033 Sequence
+12:20033 move second child to first child (4-component vector of float)
+12:20033 gl_Position: direct index for structure (gl_Position 4-component vector of float)
+12:20033 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out 1-element array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out 1-element array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
+12:20033 Constant:
+12:20033 0 (const uint)
+12:20033 Constant:
+12:20033 6.000000
+12:20033 6.000000
+12:20033 6.000000
+12:20033 6.000000
+12:9011 Sequence
+12:9011 move second child to first child (int)
+12:9011 'R1' (int)
+12:9011 'RECURSE' (int)
0:? Linker Objects
0:? 'sum' (float)
0:? 'anon@0' (out block{gl_Position 4-component vector of float gl_Position, gl_PointSize float gl_PointSize, out 1-element array of float gl_ClipDistance, gl_ClipVertex 4-component vector of float gl_ClipVertex, out 4-component vector of float gl_FrontColor, out 4-component vector of float gl_BackColor, out 4-component vector of float gl_FrontSecondaryColor, out 4-component vector of float gl_BackSecondaryColor, out 1-element array of 4-component vector of float gl_TexCoord, out float gl_FogFragCoord})
diff --git a/Test/cppComplexExpr.vert b/Test/cppComplexExpr.vert
index c2c1360..fe01cd5 100644
--- a/Test/cppComplexExpr.vert
+++ b/Test/cppComplexExpr.vert
@@ -159,6 +159,9 @@
#if (VAL0 && UNDEF) || UNDEF2 // UNDEF2 ERROR
#endif
+#line 3000
+#error line of this error should be 3000
+
#line 10000
#if 0
// ERROR, EOF
\ No newline at end of file
diff --git a/Test/cppSimple.vert b/Test/cppSimple.vert
index ed13815..52d3cf7 100644
--- a/Test/cppSimple.vert
+++ b/Test/cppSimple.vert
@@ -242,19 +242,19 @@
#directive directive was expanded
#line 12000
-#error line should be 12001
+#error line should be 12000
#line 13000 7
-#error line should be 13001, string 7
+#error line should be 13000, string 7
#define L1 14000
#define L2 13
#define F1 5
#define F2 7
#line L1 + L2
-#error line should be 14014, string 7
+#error line should be 14013, string 7
#line L1 + L2 F1 + F2 // antoeuh sat comment
-#error line should be 14014, string 12
+#error line should be 14013, string 12
#line L1 + L2 + F1 + F2
-#error line should be 14026, string 12
+#error line should be 14025, string 12
#line 1234 F1 + F2 extra
#define empty_extra
#line 1235 F1 + F2 empty_extra
@@ -264,11 +264,11 @@
#line 1238 F1 + F2 moreEmpty empty_extra
#line 1239 empty_extra F1 empty_extra + empty_extra F2 empty_extra moreEmpty empty_extra
#line (20000)
-#error line should be 20001
+#error line should be 20000
#line (20000+10)
-#error line should be 20011
+#error line should be 20010
#line +20020
-#error line should be 20021
+#error line should be 20020
#define VAL1 1.0
#define VAL2 2.0
diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp
index 2bbf44c..85f24f8 100644
--- a/glslang/MachineIndependent/preprocessor/Pp.cpp
+++ b/glslang/MachineIndependent/preprocessor/Pp.cpp
@@ -635,7 +635,18 @@
if (! lineErr) {
if (token == '\n')
++lineRes;
+
+ // Desktop, pre-version 3.30: "After processing this directive
+ // (including its new-line), the implementation will behave as if it is compiling at line number line+1 and
+ // source string number source-string-number."
+ //
+ // Desktop, version 3.30 and later, and ES: "After processing this directive
+ // (including its new-line), the implementation will behave as if it is compiling at line number line and
+ // source string number source-string-number.
+ if (parseContext.profile == EEsProfile || parseContext.version >= 330)
+ --lineRes;
parseContext.setCurrentLine(lineRes);
+
if (token != '\n') {
int fileRes = 0;
bool fileErr = false;