Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,8 @@ Crash and bug fixes
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
- Fixed a crash when parsing ``#embed`` parameters with unmatched closing brackets. (#GH152829)
- Fixed a crash when compiling ``__real__`` or ``__imag__`` unary operator on scalar value with type promotion. (#GH160583)

- Fixed a crash when parsing malformed #pragma clang loop vectorize_width(4,8,16)
by diagnosing invalid comma-separated argument lists. (#GH166325)
Improvements
^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParsePragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ bool Parser::HandlePragmaLoopHint(LoopHint &Hint) {
PP.Lex(Tok); // ,

StateInfo = Tok.getIdentifierInfo();
IsScalableStr = StateInfo->getName();
IsScalableStr = StateInfo ? StateInfo->getName() : "";

if (IsScalableStr != "scalable" && IsScalableStr != "fixed") {
Diag(Tok.getLocation(),
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Parser/pragma-loop-vectorize.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify

void sum_vector(unsigned int A[], unsigned int B[], unsigned int sum[]) {
#pragma clang loop vectorize_width(4,8,16) vectorize(assume_safety)
// expected-error@-1 {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}}
// expected-warning@-2 {{extra tokens at end of '#pragma clang loop vectorize_width' - ignored}}

for (int k = 0; k < 64; k++) {
sum[k] = A[k] + 3 * B[k];
}
}