diff options
-rw-r--r-- | Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/globalinit.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 1290975a24..c77496f066 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -576,6 +576,8 @@ bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) { // Return a new array type (C99 6.7.8p22). DeclType = Context.getConstantArrayType(VAT->getElementType(), ConstVal, ArrayType::Normal, 0); + // set type from "char *" to "constant array of char". + strLiteral->setType(DeclType); return hadError; } const ConstantArrayType *CAT = DeclType->getAsConstantArrayType(); @@ -586,6 +588,8 @@ bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) { diag::warn_initializer_string_for_char_array_too_long, strLiteral->getSourceRange()); } + // set type from "char *" to "constant array of char". + strLiteral->setType(DeclType); return hadError; } } diff --git a/test/CodeGen/globalinit.c b/test/CodeGen/globalinit.c index f47fd5c457..36cde9f45d 100644 --- a/test/CodeGen/globalinit.c +++ b/test/CodeGen/globalinit.c @@ -16,6 +16,6 @@ int latin_ptr2len (char *p); int (*mb_ptr2len) (char *p) = latin_ptr2len; -char string[8] = "string"; // extend init -char string2[4] = "string"; // truncate init +//char string[8] = "string"; // extend init +//char string2[4] = "string"; // truncate init |