[PATCH] Fix PR20069: bad loop pragma arguments crash FE

Tyler Nowicki tnowicki at apple.com
Wed Jun 18 15:19:57 PDT 2014


Hi Mark,

Thanks for working on this! Sorry about overlooking this bug.

LGTM! I previously differentiated between keyword and value to make it obvious that a vector width can’t be used with vectorize() and a enable/disable can’t be used with vectorize_width(). But the expected string should do that still.

Tyler

On Jun 18, 2014, at 11:10 AM, Mark Heffernan <meheff at google.com> wrote:

> Hi TylerNowicki, aaron.ballman,
> 
> This patch fixes a crash when handling malformed arguments to loop pragmas such as: "#pragma clang loop vectorize(()".  Essentially any argument which is not an identifier or constant resulted in a crash.  This patch also changes a couple of the error messages which weren't quite correct.  New behavior with this patch vs old behavior:
> 
> #pragma clang loop vectorize(1)
> OLD: error: missing keyword; expected 'enable' or 'disable'
> NEW: error: invalid argument; expected 'enable' or 'disable'
> 
> #pragma clang loop vectorize()
> OLD: error: expected ')'
> NEW: error: missing argument to loop pragma 'vectorize'
> 
> #pragma clang loop vectorize_width(bad)
> OLD: error: missing value; expected a positive integer value
> NEW: error: invalid argument; expected a positive integer value
> 
> #pragma clang loop vectorize(bad)
> OLD: invalid keyword 'bad'; expected 'enable' or 'disable'
> NEW: error: invalid argument; expected 'enable' or 'disable'
> 
> In the last example above, the old behavior isn't incorrect. I made the change as it simplified the code a bit and made the message consistent regardless of what the argument is (rather than just printing the argument if it is an identifier).  Happy to change it back if anyone thinks it's a step backwards.
> 
> http://reviews.llvm.org/D4197
> 
> Files:
>  include/clang/Basic/DiagnosticParseKinds.td
>  include/clang/Basic/DiagnosticSemaKinds.td
>  lib/Parse/ParsePragma.cpp
>  lib/Sema/SemaStmtAttr.cpp
>  test/Parser/pragma-loop.cpp
> <D4197.10579.patch>





More information about the cfe-commits mailing list