From 91b9f2072a20906dd34ac6cb83813debf3595328 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 24 Jan 2009 17:47:50 +0000 Subject: [PATCH] Ignore parens when determining if an expr is a string literal. Fixes PR3382. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62922 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/Sema/init.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e766ca06a5..0fb939e23a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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(Init); + return dyn_cast(Init->IgnoreParens()); } return 0; } diff --git a/test/Sema/init.c b/test/Sema/init.c index edaaf64b8b..9f0867869a 100644 --- a/test/Sema/init.c +++ b/test/Sema/init.c @@ -78,3 +78,5 @@ struct s1 s2 = { .b = bogus // expected-error {{use of undeclared identifier 'bogus'}} } +// PR3382 +char t[] = ("Hello"); -- 2.40.0