From: David Majnemer Date: Mon, 15 Dec 2014 10:00:35 +0000 (+0000) Subject: Sema: Don't diagnose string + int if the int is value dependent X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e21745e2249c118ca71dee4aaf1346b12650aea;p=platform%2Fupstream%2Fllvm.git Sema: Don't diagnose string + int if the int is value dependent Don't send a value dependent expression into the expression evaluator, HandleSizeof would crash. Making HandleSizeof handle dependent types would noisily warn about the operation even if everything turns out OK after instantiation. This fixes PR21848. llvm-svn: 224240 --- diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c04b99d..876e5b7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7282,7 +7282,7 @@ static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, bool IsStringPlusInt = StrExpr && IndexExpr->getType()->isIntegralOrUnscopedEnumerationType(); - if (!IsStringPlusInt) + if (!IsStringPlusInt || IndexExpr->isValueDependent()) return; llvm::APSInt index; diff --git a/clang/test/SemaCXX/string-plus-int.cpp b/clang/test/SemaCXX/string-plus-int.cpp index 5752f8f..fe9c719 100644 --- a/clang/test/SemaCXX/string-plus-int.cpp +++ b/clang/test/SemaCXX/string-plus-int.cpp @@ -64,3 +64,8 @@ void f(int index) { consume(A B + sizeof(A) - 1); } +template +void PR21848() { + (void)(sizeof(T) + ""); // expected-warning {{to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} +} +template void PR21848(); // expected-note {{in instantiation of function template specialization 'PR21848' requested here}}