]> granicus.if.org Git - clang/commit
Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 6 Oct 2008 17:10:33 +0000 (17:10 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 6 Oct 2008 17:10:33 +0000 (17:10 +0000)
commit73a0d889eda0f000a441319e39540509175b8e81
tree683f7b24cbec0ea01151430f7122a067da5639ff
parentebe0af9359fa42933439a307a2cb1e2954199c56
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57178 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Decl.h
include/clang/Parse/Action.h
include/clang/Parse/DeclSpec.h
lib/Parse/ParseDecl.cpp
lib/Parse/Parser.cpp
lib/Sema/Sema.h
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/direct-initializer.cpp [new file with mode: 0644]