From: Douglas Gregor Date: Fri, 1 Jul 2011 21:27:45 +0000 (+0000) Subject: When adding boolean keywords for typo correction, add either "bool" or X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07f4a06c402a2ccdd9eae7a3d710990b22040001;p=clang 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". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134263 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index a2e5c7c98f..951fbfac7a 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -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"); diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp index e35a0f5406..3d40da8d25 100644 --- a/test/FixIt/typo.cpp +++ b/test/FixIt/typo.cpp @@ -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'?}} + } +}