]> granicus.if.org Git - clang/commitdiff
When adding boolean keywords for typo correction, add either "bool" or
authorDouglas Gregor <dgregor@apple.com>
Fri, 1 Jul 2011 21:27:45 +0000 (21:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 1 Jul 2011 21:27:45 +0000 (21:27 +0000)
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134263 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLookup.cpp
test/FixIt/typo.cpp

index a2e5c7c98f4916e0de68b7035503b90195dbf72a..951fbfac7ac335abf8d14174638312921f834ce7 100644 (file)
@@ -3417,7 +3417,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef,
     // 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 @@ static void AddKeywordsToConsumer(Sema &SemaRef,
       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");
index e35a0f540692a5aef877341b6bea670393b7cd20..3d40da8d256a17abbf5550adac3db3643e1de05a 100644 (file)
@@ -80,3 +80,9 @@ namespace nonstd {
 }
 
 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'?}}
+  }
+}