From 9a1191c047f3f2a135a1375881d3a73fc2c09140 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 6 Oct 2008 17:10:33 +0000 Subject: Implement support for C++ direct initializers in declarations, e.g. "int x(1);". This is how this kind of initializers appear in the AST: -The Init expression of the VarDecl is a functional type construction (of the VarDecl's type). -The new VarDecl::hasCXXDirectInitializer() returns true. e.g, for "int x(1);": -VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr). -hasCXXDirectInitializer() of VarDecl 'x' returns true. A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code. Note that codegening works now for "int x(1);" without any changes to CodeGen. llvm-svn: 57178 --- clang/lib/Parse/Parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Parse/Parser.cpp') diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 800be8dd013..fa4bdfafb74 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -449,7 +449,9 @@ Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() { Tok.is(tok::comma) || // int X(), -> not a function def Tok.is(tok::semi) || // int X(); -> not a function def Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def - Tok.is(tok::kw___attribute)) { // int X() __attr__ -> not a function def + Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def + (getLang().CPlusPlus && + Tok.is(tok::l_paren)) ) { // int X(0) -> not a function def [C++] // FALL THROUGH. } else if (DeclaratorInfo.isFunctionDeclarator() && (Tok.is(tok::l_brace) || // int X() {} -- cgit v1.2.3