llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Constructor-style initialization of bool fails

Open llvmbot opened this issue 18 years ago • 2 comments

Bugzilla Link 2704
Resolution FIXED
Resolved on Mar 12, 2010 00:56
Version unspecified
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @akyrtzi

Extended Description

Despite the C++ status page saying boolean is fully supported, when running a pretty simple test just to try out the AST generation, it seems like ctor initializing native types confuses the parser (and subsequently the AST).

The line

bool b(true);

causes an error in ParseDecl.cpp on line 1366 (as of rev. 55139).

Here is the original code:

// test constructor-style initialization of PODs int main() { bool b(true); return 0; }

and here is the output from clang:

/Users/mike/Code/asttests/shunt.cpp:3:9: error: expected parameter declarator bool b(true); ^ /Users/mike/Code/asttests/shunt.cpp:3:9: error: expected ')' /Users/mike/Code/asttests/shunt.cpp:3:8: error: to match this '(' bool b(true); ^

int main() (CompoundStmt 0xc08030 </Users/mike/Code/asttests/shunt.cpp:2:12, line:5:1> (DeclStmt 0xc07fc0 line:3:2 0xc07f80 "_Bool (b)(void)" (ReturnStmt 0xc07d80 <line:4:2, col:9> (IntegerLiteral 0xc07fe0 col:9 'int' 0)))

3 diagnostics generated.

llvmbot avatar Aug 22 '08 00:08 llvmbot

This has now been fixed (rev. 57178).

akyrtzi avatar Oct 06 '08 19:10 akyrtzi

This is because constructor style inits aren't supported yet. :)

lattner avatar Aug 22 '08 00:08 lattner