[OpenACC] Fix bug with directive name being a 'special token'

If the 'directive name' is a special token instead of an identifier, we
end up asserting.  This fixes that.
This commit is contained in:
erichkeane 2023-12-08 09:32:01 -08:00
parent 965fe352a7
commit 731361cd15
2 changed files with 14 additions and 6 deletions

View File

@ -206,7 +206,7 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
// Just #pragma acc can get us immediately to the end, make sure we don't
// introspect on the spelling before then.
if (FirstTok.isAnnotation()) {
if (FirstTok.isNot(tok::identifier)) {
P.Diag(FirstTok, diag::err_acc_missing_directive);
return OpenACCDirectiveKind::Invalid;
}
@ -224,11 +224,8 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
if (ExDirKind >= OpenACCDirectiveKindEx::Invalid) {
switch (ExDirKind) {
case OpenACCDirectiveKindEx::Invalid: {
if (!FirstTok.is(tok::identifier))
P.Diag(FirstTok, diag::err_expected) << tok::identifier;
else
P.Diag(FirstTok, diag::err_acc_invalid_directive)
<< 0 << FirstTok.getIdentifierInfo();
P.Diag(FirstTok, diag::err_acc_invalid_directive)
<< 0 << FirstTok.getIdentifierInfo();
return OpenACCDirectiveKind::Invalid;
}
case OpenACCDirectiveKindEx::Enter:

View File

@ -7,6 +7,17 @@ void func() {
#pragma acc
for(;;){}
// expected-error@+4{{expected OpenACC directive}}
// expected-error@+3{{expected clause-list or newline in OpenACC directive}}
// expected-warning@+2{{OpenACC clause parsing not yet implemented}}
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
#pragma acc(whatever) routine
// expected-error@+3{{expected OpenACC directive}}
// expected-warning@+2{{OpenACC clause parsing not yet implemented}}
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
#pragma acc) routine
// expected-error@+2{{invalid OpenACC directive 'invalid'}}
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
#pragma acc invalid