summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-02-22 06:45:27 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-02-22 06:45:27 +0000
commit7bfab3687782a3e6a706f9a4966d81c55672b0cf (patch)
treed4373008ec9de4fd91911f66956f966e9c809a4e /clang/lib
parentc64c481d18826a0925c1b34f6877d0811236e849 (diff)
downloadbcm5719-llvm-7bfab3687782a3e6a706f9a4966d81c55672b0cf.tar.gz
bcm5719-llvm-7bfab3687782a3e6a706f9a4966d81c55672b0cf.zip
Throw the switch to exclusively use Evaluate (along with the small
helper isConstantInitializer) to check whether an initializer is constant. This passes tests, but it's possible that it'll cause regressions with real-world code. Future work: 1. The diagnostics obtained this way are lower quality at the moment; some work both here and in Evaluate is needed for accurate diagnostics. 2. We probably need some extra code when we're in -pedantic mode so we can strictly enforce the rules in C99 6.6p7. 3. Dead code cleanup (this should wait until after 2, because we might want to re-use some of the code). llvm-svn: 65265
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3130f02bef3..4ec2dc6968b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2371,6 +2371,12 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) {
}
bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
+ if (Init->isConstantInitializer(Context)) {
+ return false;
+ }
+ InitializerElementNotConstant(Init);
+ return true;
+
if (DesignatedInitExpr *DIE = dyn_cast<DesignatedInitExpr>(Init))
Init = DIE->getInit();
OpenPOWER on IntegriCloud