[Patch] Fix for PR9812

Erik Verbruggen erik.verbruggen at me.com
Fri Jan 10 07:30:44 PST 2014


On 07 Jan 2014, at 16:28, Erik Verbruggen <erik.verbruggen at me.com> wrote:

>> On Sat, Dec 14, 2013 at 5:31 AM, Erik Verbruggen <erik.verbrug... at me.com> wrote:
>>> This is a fix for PR9812, and I have to say that I don't know what more to 
>>> say in the commit message than "warn about bool instead of _Bool", so 
>>> feedback is welcome! I sometimes run into this, hence the patch.
>>> 
>>> Two notes: I have to say that the patch feels a bit intrusive, but I didn't 
>>> find a better way to do this. Also, in MS mode, it will warn about __wchar_t 
>>> v.s. wchar_t. I haven't extensively tested this on Windows, but to me it 
>>> looks like the correct thing. Again, feedback welcome!
>> 
>> Thank you for working on this!  This is a strict improvement for C++,
>> the issue still remains for C.  In that case, we should do something
>> like Sema::getPrintingPolicy().  We should not be printing 'bool' in C
>> unless the said macro exists -- we need tests for both cases.  Will
>> you fix the C case as well?
> 
> I can do that. Should I do that in a separate commit, or should I do it in this patch?

I looked at the C case today, and I'm not sure what should change in the output. Can you enlighten me? Below is an example, and the output I get with rev. 198940.

#define bool _Bool
int test1(int argc, char** argv)
{
    bool signed;

    return 0;
}
#undef bool

typedef int bool;

int test2(int argc, char** argv)
{
    bool signed;
    _Bool signed;

    return 0;
}

/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:6:10: error: 'bool' cannot be signed or unsigned
    bool signed;
         ^
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:6:5: warning: declaration does not declare anything
    bool signed;
    ^~~~~~~~~~~
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:3:14: note: expanded from macro 'bool'
#define bool _Bool
             ^
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:16:10: error: 'type-name' cannot be signed or unsigned
    bool signed;
         ^
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:16:5: warning: declaration does not declare anything
    bool signed;
    ^~~~~~~~~~~
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:17:11: error: '_Bool' cannot be signed or unsigned
    _Bool signed;
          ^
/Users/erik/dev/clang-llvm/llvm-git/tools/clang/test/SemaCXX/pr9812.c:17:5: warning: declaration does not declare anything
    _Bool signed;
    ^~~~~~~~~~~~
3 warnings and 3 errors generated.

-- Erik.



More information about the cfe-commits mailing list