r208299 - Suggest fix-it ':' when '=' used in for-range-declaration

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Thu May 8 14:28:43 PDT 2014


On Thu, May 8, 2014 at 6:17 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=208299&r1=208298&r2=208299&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu May  8 06:28:25 2014
>> @@ -204,6 +204,8 @@ def err_expected_semi_after_attribute_li
>> def err_expected_semi_after_static_assert : Error<
>>   "expected ';' after static_assert">;
>> def err_expected_semi_for : Error<"expected ';' in 'for' statement specifier">;
>> +def err_single_decl_assign_in_for_range : Error<
>> +  "range based for statement requires ':' after range declaration">;
>> def warn_missing_selector_name : Warning<
>>   "%0 used as the name of the previous parameter rather than as part "
>>   "of the selector">,
>
> Wordsmithing suggestion: "range-based 'for' statement uses ':' , not '='".
>
> The part I'm sure about is the hyphenation. Putting quotes around "for" is less important, but still seems like a good idea since "for" is a normal English word. The "after range declaration" isn't so great, though, because what's being declared is the element variable, not the range, and normally the "= <init>" is considered part of the declaration.
>
> Jordan

Hi Jordan,

I have tried to be careful hyphenating both `for` and `range-based` in
Phabricator. It seems like I didn't pay that much attention to the
actual diagnostics. The reason it says "range declaration" is because
I couldn't come up with a better name than the one in 6.5/p1 :)

  for ( for-range-declaration : for-range-initializer ) statement

It's correct that the `for-range-declaration` declares the element. I
have tried "... after element declaration" and similar clauses, but
they didn't improve the message. Let's rephrase this as you suggested:

  "range-based 'for' statement uses ':', not '='"

Ismail




More information about the cfe-commits mailing list