]> granicus.if.org Git - clang/commitdiff
[Sema] Fix assertion failure when checking for unused variables in a dependent context.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 19 Oct 2017 19:07:13 +0000 (19:07 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 19 Oct 2017 19:07:13 +0000 (19:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316177 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/warn-unused-variables.cpp

index 9e5fa0e563494d0f811c499de92b5352285925b7..d75a469970fc8651ab68e0a061aff04e0d44d6e9 100644 (file)
@@ -1724,7 +1724,7 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
           if (Construct && !Construct->isElidable()) {
             CXXConstructorDecl *CD = Construct->getConstructor();
             if (!CD->isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
-                !VD->evaluateValue())
+                (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
               return false;
           }
         }
index 0974cf5a61d699699714f67aebc77b7307c13d7f..a7ac9afc36ad6ade9a4d1d531c1af46093bad2db 100644 (file)
@@ -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