]> granicus.if.org Git - clang/commitdiff
Revert rL315787, "[Sema] Warn about unused variables if we can constant evaluate...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 14 Oct 2017 14:46:04 +0000 (14:46 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 14 Oct 2017 14:46:04 +0000 (14:46 +0000)
check-libcxx dislikes it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315806 91177308-0d34-0410-b5e6-96231b3b80d8

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

index e6f3aeae9617e52fc9e05c4f358cfe352d148268..31abdfa3f6c0d1cb183471ac83536c713287c0b0 100644 (file)
@@ -1723,8 +1723,7 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
             dyn_cast<CXXConstructExpr>(Init);
           if (Construct && !Construct->isElidable()) {
             CXXConstructorDecl *CD = Construct->getConstructor();
-            if (!CD->isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
-                !VD->evaluateValue())
+            if (!CD->isTrivial() && !RD->hasAttr<WarnUnusedAttr>())
               return false;
           }
         }
index 0974cf5a61d699699714f67aebc77b7307c13d7f..d7be785b35a6918c856573992c3c124a0b2d5bbf 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s
 template<typename T> void f() {
   T t;
   t = 17;
@@ -195,35 +194,3 @@ void test() {
 }
 
 }
-
-#if __cplusplus >= 201103L
-namespace with_constexpr {
-template <typename T>
-struct Literal {
-  T i;
-  Literal() = default;
-  constexpr Literal(T i) : i(i) {}
-};
-
-struct NoLiteral {
-  int i;
-  NoLiteral() = default;
-  constexpr NoLiteral(int i) : i(i) {}
-  ~NoLiteral() {}
-};
-
-static Literal<int> gl1;          // expected-warning {{unused variable 'gl1'}}
-static Literal<int> gl2(1);       // expected-warning {{unused variable 'gl2'}}
-static const Literal<int> gl3(0); // expected-warning {{unused variable 'gl3'}}
-
-template <typename T>
-void test(int i) {
-  Literal<int> l1;     // expected-warning {{unused variable 'l1'}}
-  Literal<int> l2(42); // expected-warning {{unused variable 'l2'}}
-  Literal<int> l3(i);  // no-warning
-  Literal<T> l4(0);    // no-warning
-  NoLiteral nl1;       // no-warning
-  NoLiteral nl2(42);   // no-warning
-}
-}
-#endif