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

Mark Heffernan meheff at google.com
Wed Jun 18 11:10:54 PDT 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4197.10579.patch
Type: text/x-patch
Size: 9076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140618/08f1c424/attachment.bin>


More information about the cfe-commits mailing list