Index: include/clang/AST/Type.h =================================================================== --- include/clang/AST/Type.h (revision 54780) +++ include/clang/AST/Type.h (working copy) @@ -130,6 +130,8 @@ bool isRestrictQualified() const { return (ThePtr & Restrict) ? true : false; } + + bool isConstant(ASTContext& Ctx) const; /// addConst/addVolatile/addRestrict - add the specified type qual to this /// QualType. Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp (revision 54780) +++ lib/CodeGen/CodeGenModule.cpp (working copy) @@ -585,6 +585,7 @@ } GV->setInitializer(Init); + GV->setConstant(D->getType().isConstant(Context)); // FIXME: This is silly; getTypeAlign should just work for incomplete arrays unsigned Align; Index: lib/AST/Type.cpp =================================================================== --- lib/AST/Type.cpp (revision 54780) +++ lib/AST/Type.cpp (working copy) @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/AST/ASTContext.h" #include "clang/AST/Type.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" @@ -19,6 +20,16 @@ #include using namespace clang; +bool QualType::isConstant(ASTContext& Ctx) const { + if (isConstQualified()) + return true; + + if (getTypePtr()->isArrayType()) + return Ctx.getAsArrayType(*this)->getElementType().isConstant(Ctx); + + return false; +} + void Type::Destroy(ASTContext& C) { delete this; } void FunctionTypeProto::Destroy(ASTContext& C) {