]> granicus.if.org Git - clang/commitdiff
Explicitly set the string literal type from "char *" to "constant array of char".
authorSteve Naroff <snaroff@apple.com>
Tue, 11 Dec 2007 00:00:01 +0000 (00:00 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 11 Dec 2007 00:00:01 +0000 (00:00 +0000)
At this point, I am fairly certain the front-end is correct. Unfortunately, the back-end is still unhappy.

That said, I've commented out the two lines in globalinit.c that are causing problems.

Chris, please have a look...thanks!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44823 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
test/CodeGen/globalinit.c

index 1290975a24b0b315758f155484ad644b8f8c008a..c77496f0664792dfb3919aa120f52c26f909c2a1 100644 (file)
@@ -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;
       }
     }
index f47fd5c457754d9ab20aacf9bf7641c4fd7ba5ab..36cde9f45d6d5eca2148e0b722240807e07efbb3 100644 (file)
@@ -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