diff --git a/Test/baseResults/preprocessor.cpp_style___FILE__.vert.out b/Test/baseResults/preprocessor.cpp_style___FILE__.vert.out index 5487ac38..e63d81a6 100644 --- a/Test/baseResults/preprocessor.cpp_style___FILE__.vert.out +++ b/Test/baseResults/preprocessor.cpp_style___FILE__.vert.out @@ -1,26 +1,37 @@ #extension GL_GOOGLE_cpp_style_line_directive : enable 0 -#line 150 a.h + +#line 150 "a.h" "a.h" + #line 24 "a.h" + #line 42 "a.h" -#line 30 b.cc + +#line 30 "b.cc" "b.cc" + #line 10 3 3 + #line 48 3 + #line 4 3 + #line 55 100 100 -#line 1000 c + +#line 1000 "c" "c" + #line 42 1 1 -#line 42 this-is-a-quite-long-name-maybe-i-should-shorten-it + +#line 42 "this-is-a-quite-long-name-maybe-i-should-shorten-it" "this-is-a-quite-long-name-maybe-i-should-shorten-it" diff --git a/Test/test-preprocessor-list b/Test/test-preprocessor-list index 5ecc57fd..e75ac1b4 100644 --- a/Test/test-preprocessor-list +++ b/Test/test-preprocessor-list @@ -1,4 +1,5 @@ preprocessor.cpp_style_line_directive.vert +preprocessor.cpp_style___FILE__.vert preprocessor.edge_cases.vert preprocessor.errors.vert preprocessor.extensions.vert diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 486b4f80..279706ec 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -604,7 +604,7 @@ int TPpContext::CPPline(TPpToken* ppToken) // "#line line source-string-number" int token = scanToken(ppToken); - const int directiveLoc = ppToken->loc.line; + const TSourceLoc directiveLoc = ppToken->loc; if (token == '\n') { parseContext.ppError(ppToken->loc, "must by followed by an integral literal", "#line", ""); return token; @@ -628,7 +628,8 @@ int TPpContext::CPPline(TPpToken* ppToken) parseContext.setCurrentLine(lineRes); if (token != '\n') { - if (parseContext.extensionTurnedOn(E_GL_GOOGLE_cpp_style_line_directive) && token == PpAtomConstString) { + if (token == PpAtomConstString) { + parseContext.requireExtensions(directiveLoc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based #line"); // We need to save a copy of the string instead of pointing // to the name field of the token since the name field // will likely be overwritten by the next token scan. @@ -646,7 +647,7 @@ int TPpContext::CPPline(TPpToken* ppToken) } } if (!fileErr && !lineErr) { - parseContext.notifyLineDirective(directiveLoc, lineToken, hasFile, fileRes, sourceName); + parseContext.notifyLineDirective(directiveLoc.line, lineToken, hasFile, fileRes, sourceName); } token = extraTokenCheck(PpAtomLine, ppToken, token); @@ -965,8 +966,8 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool return 1; case PpAtomFileMacro: { - const char* current_file = parseContext.getCurrentLoc().name; - if (parseContext.extensionTurnedOn(E_GL_GOOGLE_cpp_style_line_directive) && current_file != nullptr) { + if (const char* current_file = parseContext.getCurrentLoc().name) { + parseContext.requireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__"); sprintf(ppToken->name, "\"%s\"", current_file); } else { ppToken->ival = parseContext.getCurrentLoc().string;