]> granicus.if.org Git - clang/commit
constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 19 Dec 2011 06:19:21 +0000 (06:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 19 Dec 2011 06:19:21 +0000 (06:19 +0000)
commit099e7f647ccda915513f2b2ec53352dc756082d3
tree20a7796c73f49f5e39604681e185a62bb9027f00
parent925be547b163675b312e3cac0cc7f37f31d787c1
constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'
variable is initialized by a non-constant expression, and pass in the variable
being declared so that earlier-initialized fields' values can be used.

Rearrange VarDecl init evaluation to make this possible, and in so doing fix a
long-standing issue in our C++ constant expression handling, where we would
mishandle cases like:

  extern const int a;
  const int n = a;
  const int a = 5;
  int arr[n];

Here, n is not initialized by a constant expression, so can't be used in an ICE,
even though the initialization expression would be an ICE if it appeared later
in the TU. This requires computing whether the initializer is an ICE eagerly,
and saving that information in PCH files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146856 91177308-0d34-0410-b5e6-96231b3b80d8
20 files changed:
include/clang/AST/Decl.h
include/clang/AST/Expr.h
include/clang/Basic/DiagnosticASTKinds.td
lib/AST/ASTImporter.cpp
lib/AST/Decl.cpp
lib/AST/ExprConstant.cpp
lib/Sema/SemaDecl.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CXX/basic/basic.types/p10.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
test/CXX/expr/expr.const/p2-0x.cpp
test/PCH/cxx-constexpr.cpp [new file with mode: 0644]
test/SemaCXX/constant-expression-cxx11.cpp
test/SemaCXX/constant-expression.cpp
test/SemaCXX/constexpr-depth.cpp
test/SemaCXX/constexpr-printing.cpp
test/SemaCXX/cxx0x-class.cpp
test/SemaCXX/i-c-e-cxx.cpp