glsl: Fix yylloc.source propagation in YYLLOC_DEFAULT
authorSviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Mon, 3 Jul 2023 06:45:29 +0000 (09:45 +0300)
committerMarge Bot <emma+marge@anholt.net>
Wed, 5 Jul 2023 20:22:27 +0000 (20:22 +0000)
Currently, it's always initialized to 0, but we should take the value from
the grouping passed to the macro. This way parser will have the full
location info, and errors originating from it will show the correct
source file number.

Fixes: a0cfe8c4 ("glsl: Fix missing initialization of yylloc.source")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9229
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23966>

src/compiler/glsl/glcpp/glcpp.h
src/compiler/glsl/glsl_parser_extras.h

index b797433..d1d2227 100644 (file)
@@ -91,6 +91,7 @@ do {                                                          \
       (Current).first_column = YYRHSLOC(Rhs, 1).first_column;  \
       (Current).last_line    = YYRHSLOC(Rhs, N).last_line;     \
       (Current).last_column  = YYRHSLOC(Rhs, N).last_column;   \
+      (Current).source       = YYRHSLOC(Rhs, N).source;                \
    }                                                           \
    else                                                                \
    {                                                           \
@@ -98,8 +99,8 @@ do {                                                          \
         YYRHSLOC(Rhs, 0).last_line;                            \
       (Current).first_column = (Current).last_column =         \
         YYRHSLOC(Rhs, 0).last_column;                          \
+      (Current).source       = YYRHSLOC(Rhs, 0).source;                \
    }                                                           \
-   (Current).source = 0;                                       \
 } while (0)
 
 struct token {
index efb4054..90d4017 100644 (file)
@@ -1000,6 +1000,7 @@ do {                                                            \
       (Current).last_line    = YYRHSLOC(Rhs, N).last_line;      \
       (Current).last_column  = YYRHSLOC(Rhs, N).last_column;    \
       (Current).path         = YYRHSLOC(Rhs, N).path;           \
+      (Current).source       = YYRHSLOC(Rhs, N).source;         \
    }                                                            \
    else                                                         \
    {                                                            \
@@ -1007,9 +1008,9 @@ do {                                                            \
          YYRHSLOC(Rhs, 0).last_line;                            \
       (Current).first_column = (Current).last_column =          \
          YYRHSLOC(Rhs, 0).last_column;                          \
-      (Current).path = YYRHSLOC(Rhs, 0).path;                   \
+      (Current).path         = YYRHSLOC(Rhs, 0).path;           \
+      (Current).source       = YYRHSLOC(Rhs, 0).source;         \
    }                                                            \
-   (Current).source = 0;                                        \
 } while (0)
 
 /**