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
Родитель 5011fbebc3
Коммит 780a2f4426
3 изменённых файлов: 22 добавлений и 9 удалений

Просмотреть файл

@ -1,26 +1,37 @@
#extension GL_GOOGLE_cpp_style_line_directive : enable #extension GL_GOOGLE_cpp_style_line_directive : enable
0 0
#line 150 a.h
#line 150 "a.h"
"a.h" "a.h"
#line 24 #line 24
"a.h" "a.h"
#line 42 #line 42
"a.h" "a.h"
#line 30 b.cc
#line 30 "b.cc"
"b.cc" "b.cc"
#line 10 3 #line 10 3
3 3
#line 48 #line 48
3 3
#line 4 #line 4
3 3
#line 55 100 #line 55 100
100 100
#line 1000 c
#line 1000 "c"
"c" "c"
#line 42 1 #line 42 1
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" "this-is-a-quite-long-name-maybe-i-should-shorten-it"

Просмотреть файл

@ -1,4 +1,5 @@
preprocessor.cpp_style_line_directive.vert preprocessor.cpp_style_line_directive.vert
preprocessor.cpp_style___FILE__.vert
preprocessor.edge_cases.vert preprocessor.edge_cases.vert
preprocessor.errors.vert preprocessor.errors.vert
preprocessor.extensions.vert preprocessor.extensions.vert

Просмотреть файл

@ -604,7 +604,7 @@ int TPpContext::CPPline(TPpToken* ppToken)
// "#line line source-string-number" // "#line line source-string-number"
int token = scanToken(ppToken); int token = scanToken(ppToken);
const int directiveLoc = ppToken->loc.line; const TSourceLoc directiveLoc = ppToken->loc;
if (token == '\n') { if (token == '\n') {
parseContext.ppError(ppToken->loc, "must by followed by an integral literal", "#line", ""); parseContext.ppError(ppToken->loc, "must by followed by an integral literal", "#line", "");
return token; return token;
@ -628,7 +628,8 @@ int TPpContext::CPPline(TPpToken* ppToken)
parseContext.setCurrentLine(lineRes); parseContext.setCurrentLine(lineRes);
if (token != '\n') { 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 // We need to save a copy of the string instead of pointing
// to the name field of the token since the name field // to the name field of the token since the name field
// will likely be overwritten by the next token scan. // will likely be overwritten by the next token scan.
@ -646,7 +647,7 @@ int TPpContext::CPPline(TPpToken* ppToken)
} }
} }
if (!fileErr && !lineErr) { if (!fileErr && !lineErr) {
parseContext.notifyLineDirective(directiveLoc, lineToken, hasFile, fileRes, sourceName); parseContext.notifyLineDirective(directiveLoc.line, lineToken, hasFile, fileRes, sourceName);
} }
token = extraTokenCheck(PpAtomLine, ppToken, token); token = extraTokenCheck(PpAtomLine, ppToken, token);
@ -965,8 +966,8 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool
return 1; return 1;
case PpAtomFileMacro: { case PpAtomFileMacro: {
const char* current_file = parseContext.getCurrentLoc().name; if (const char* current_file = parseContext.getCurrentLoc().name) {
if (parseContext.extensionTurnedOn(E_GL_GOOGLE_cpp_style_line_directive) && current_file != nullptr) { parseContext.requireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__");
sprintf(ppToken->name, "\"%s\"", current_file); sprintf(ppToken->name, "\"%s\"", current_file);
} else { } else {
ppToken->ival = parseContext.getCurrentLoc().string; ppToken->ival = parseContext.getCurrentLoc().string;