Use requireExtensions() to check extension and turn on more tests.

Use requireExtensions() to check GL_GOOGLE_cpp_style_line_directive
is turned on. Add register more tests for running.
This commit is contained in:
Lei Zhang 2015-07-28 11:59:24 -04:00
parent 5011fbebc3
commit 780a2f4426
3 changed files with 22 additions and 9 deletions

View File

@ -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"

View File

@ -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

View File

@ -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;