[cfe-commits] r134263 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/FixIt/typo.cpp

Douglas Gregor dgregor at apple.com
Fri Jul 1 14:27:45 PDT 2011


Author: dgregor
Date: Fri Jul  1 16:27:45 2011
New Revision: 134263

URL: http://llvm.org/viewvc/llvm-project?rev=134263&view=rev
Log:
When adding boolean keywords for typo correction, add either "bool" or
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/FixIt/typo.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=134263&r1=134262&r2=134263&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Jul  1 16:27:45 2011
@@ -3417,7 +3417,7 @@
     // Add type-specifier keywords to the set of results.
     const char *CTypeSpecs[] = {
       "char", "const", "double", "enum", "float", "int", "long", "short",
-      "signed", "struct", "union", "unsigned", "void", "volatile", "_Bool",
+      "signed", "struct", "union", "unsigned", "void", "volatile", 
       "_Complex", "_Imaginary",
       // storage-specifiers as well
       "extern", "inline", "static", "typedef"
@@ -3431,7 +3431,9 @@
       Consumer.addKeywordResult("restrict");
     if (SemaRef.getLangOptions().Bool || SemaRef.getLangOptions().CPlusPlus)
       Consumer.addKeywordResult("bool");
-
+    else if (SemaRef.getLangOptions().C99)
+      Consumer.addKeywordResult("_Bool");
+    
     if (SemaRef.getLangOptions().CPlusPlus) {
       Consumer.addKeywordResult("class");
       Consumer.addKeywordResult("typename");

Modified: cfe/trunk/test/FixIt/typo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.cpp?rev=134263&r1=134262&r2=134263&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo.cpp (original)
+++ cfe/trunk/test/FixIt/typo.cpp Fri Jul  1 16:27:45 2011
@@ -80,3 +80,9 @@
 }
 
 yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
+
+namespace check_bool {
+  void f() {
+    Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
+  }
+}





More information about the cfe-commits mailing list