================
Comment at: lib/Sema/SemaInit.cpp:1923-1931
@@ -1973,16 +1922,11 @@
 
-      if (!KnownField) {
-        // The replacement field comes from typo correction; find it
-        // in the list of fields.
-        FieldIndex = 0;
-        Field = RT->getDecl()->field_begin();
-        for (; Field != FieldEnd; ++Field) {
-          if (Field->isUnnamedBitfield())
-            continue;
-
-          if (ReplacementField == *Field ||
-              Field->getIdentifier() == ReplacementField->getIdentifier())
-            break;
-
-          ++FieldIndex;
+        if (!ReplacementField) {
+          // Name lookup found something, but it wasn't a field.
+          SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield)
+              << FieldName;
+          SemaRef.Diag(Lookup.front()->getLocation(),
+                       diag::note_field_designator_found);
+          ++Index;
+          return true;
         }
+
----------------
This looks to be unreachable now.

I think you should rearrange this a little: if `lookup` found something, but 
didn't find a field, then issue this diagnostic. Otherwise, fall through to 
here and do typo correction.

================
Comment at: lib/Sema/SemaInit.cpp:1933-1934
@@ +1932,4 @@
+
+        // The replacement field comes from typo correction;
+        // find it in the list of fields.
+        KnownField = ReplacementField;
----------------
This comment doesn't make sense any more.

http://reviews.llvm.org/D4839



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to