diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2009-01-15 16:44:45 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2009-01-15 16:44:45 +0000 |
commit | 6ed2ef8281e44fdd8f002d1cbe11668068d3e530 (patch) | |
tree | dc09ef0a4f80014088c2206b6d5d6915c4336b39 /lib/Sema/SemaDecl.cpp | |
parent | eff2cd58a897379c7fc46e83447d4619d6f6e9ca (diff) |
add support for initializing static vars with a cast to union (gcc extension)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 468e95523c..07966399da 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2228,7 +2228,14 @@ bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) { // Allow block exprs at top level. if (Init->getType()->isBlockPointerType()) return false; - + + // GCC cast to union extension + // note: the validity of the cast expr is checked by CheckCastTypes() + if (CastExpr *C = dyn_cast<CastExpr>(Init)) { + QualType T = C->getType(); + return T->isUnionType() && CheckForConstantInitializer(C->getSubExpr(), T); + } + InitializerElementNotConstant(Init); return true; } |