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".

llvm-svn: 134263
This commit is contained in:
Douglas Gregor 2011-07-01 21:27:45 +00:00
parent c063ac20d8
commit 3b22a88488
2 changed files with 10 additions and 2 deletions

View 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");

View 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'?}}
}
}