]> granicus.if.org Git - clang/commitdiff
Ignore parens when determining if an expr is a string literal. Fixes PR3382.
authorAnders Carlsson <andersca@mac.com>
Sat, 24 Jan 2009 17:47:50 +0000 (17:47 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 24 Jan 2009 17:47:50 +0000 (17:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/init.c

index e766ca06a5e11577d90da3592eedb553bbe20ac5..0fb939e23abc2130e71aa8d941c7f77223573f50 100644 (file)
@@ -1031,7 +1031,7 @@ bool Sema::CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT) {
 StringLiteral *Sema::IsStringLiteralInit(Expr *Init, QualType DeclType) {
   const ArrayType *AT = Context.getAsArrayType(DeclType);
   if (AT && AT->getElementType()->isCharType()) {
-    return dyn_cast<StringLiteral>(Init);
+    return dyn_cast<StringLiteral>(Init->IgnoreParens());
   }
   return 0;
 }
index edaaf64b8be387b935fc2803a51cf02ea57c0abb..9f0867869a98f3630174ccd6e28bfe9cc302afec 100644 (file)
@@ -78,3 +78,5 @@ struct s1 s2 = {
     .b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
 }
 
+// PR3382
+char t[] = ("Hello");