From 64a78e0baab0bffb302996f47efbda51faac598d Mon Sep 17 00:00:00 2001 From: Tyler Nowicki Date: Mon, 8 Jun 2015 23:13:43 +0000 Subject: [PATCH] Correct Loop Hint Diagnostic Message When pragma clang loop unroll() is specified without an argument the diagnostic message should inform that user that 'full' and 'disable' are valid arguments (not 'enable'). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239363 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParsePragma.cpp | 7 ++++--- test/Parser/pragma-loop.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp index a8641efb70..84256dfd8e 100644 --- a/lib/Parse/ParsePragma.cpp +++ b/lib/Parse/ParsePragma.cpp @@ -799,8 +799,10 @@ bool Parser::HandlePragmaLoopHint(LoopHint &Hint) { "PragmaLoopHintInfo::Toks must contain at least one token."); // If no option is specified the argument is assumed to be a constant expr. + bool OptionUnroll = false; bool StateOption = false; - if (OptionInfo) { // Pragma unroll does not specify an option. + if (OptionInfo) { // Pragma Unroll does not specify an option. + OptionUnroll = OptionInfo->isStr("unroll"); StateOption = llvm::StringSwitch(OptionInfo->getName()) .Case("vectorize", true) .Case("interleave", true) @@ -812,14 +814,13 @@ bool Parser::HandlePragmaLoopHint(LoopHint &Hint) { if (Toks[0].is(tok::eof)) { ConsumeToken(); // The annotation token. Diag(Toks[0].getLocation(), diag::err_pragma_loop_missing_argument) - << /*StateArgument=*/StateOption << /*FullKeyword=*/PragmaUnroll; + << /*StateArgument=*/StateOption << /*FullKeyword=*/OptionUnroll; return false; } // Validate the argument. if (StateOption) { ConsumeToken(); // The annotation token. - bool OptionUnroll = OptionInfo->isStr("unroll"); SourceLocation StateLoc = Toks[0].getLocation(); IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo(); if (!StateInfo || ((OptionUnroll ? !StateInfo->isStr("full") diff --git a/test/Parser/pragma-loop.cpp b/test/Parser/pragma-loop.cpp index 547d87395e..a0213ac50d 100644 --- a/test/Parser/pragma-loop.cpp +++ b/test/Parser/pragma-loop.cpp @@ -132,7 +132,7 @@ void test(int *List, int Length) { /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize() /* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop interleave_count() -/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll() +/* expected-error {{missing argument; expected 'full' or 'disable'}} */ #pragma clang loop unroll() /* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, or unroll_count}} */ #pragma clang loop /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword -- 2.40.0