소스 검색

Suppress false-positive -Wdeprecated-volatile warning from __is_*_assignable(volatile T&, U).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374580 91177308-0d34-0410-b5e6-96231b3b80d8
Richard Smith 5 년 전
부모
커밋
58fa5962e2
2개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      lib/Sema/SemaExprCXX.cpp
  2. 2 0
      test/SemaCXX/deprecated.cpp

+ 7 - 1
lib/Sema/SemaExprCXX.cpp

@@ -5243,7 +5243,13 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
     Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl());
     Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl());
     ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs,
     ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs,
                                         &Rhs);
                                         &Rhs);
-    if (Result.isInvalid() || SFINAE.hasErrorOccurred())
+    if (Result.isInvalid())
+      return false;
+
+    // Treat the assignment as unused for the purpose of -Wdeprecated-volatile.
+    Self.CheckUnusedVolatileAssignment(Result.get());
+
+    if (SFINAE.hasErrorOccurred())
       return false;
       return false;
 
 
     if (BTT == BTT_IsAssignable)
     if (BTT == BTT_IsAssignable)

+ 2 - 0
test/SemaCXX/deprecated.cpp

@@ -178,6 +178,8 @@ namespace DeprecatedVolatile {
     n /= 2; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
     n /= 2; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
     n %= 42; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
     n %= 42; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
 
 
+    (void)__is_trivially_assignable(volatile int&, int); // no warning
+
 #if __cplusplus >= 201703L
 #if __cplusplus >= 201703L
     struct X { int a, b; };
     struct X { int a, b; };
     volatile auto [x, y] = X{1, 2}; // cxx20-warning {{volatile qualifier in structured binding declaration is deprecated}}
     volatile auto [x, y] = X{1, 2}; // cxx20-warning {{volatile qualifier in structured binding declaration is deprecated}}