r316177 - [Sema] Fix assertion failure when checking for unused variables in a dependent context.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 12:07:13 PDT 2017
Author: d0k
Date: Thu Oct 19 12:07:13 2017
New Revision: 316177
URL: http://llvm.org/viewvc/llvm-project?rev=316177&view=rev
Log:
[Sema] Fix assertion failure when checking for unused variables in a dependent context.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=316177&r1=316176&r2=316177&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 19 12:07:13 2017
@@ -1724,7 +1724,7 @@ static bool ShouldDiagnoseUnusedDecl(con
if (Construct && !Construct->isElidable()) {
CXXConstructorDecl *CD = Construct->getConstructor();
if (!CD->isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
- !VD->evaluateValue())
+ (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
return false;
}
}
Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=316177&r1=316176&r2=316177&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Thu Oct 19 12:07:13 2017
@@ -226,4 +226,14 @@ void test(int i) {
NoLiteral nl2(42); // no-warning
}
}
+
+namespace crash {
+struct a {
+ a(const char *);
+};
+template <typename b>
+void c() {
+ a d(b::e ? "" : "");
+}
+}
#endif
More information about the cfe-commits
mailing list