Browse Source

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 years ago
parent
commit
58fa5962e2
2 changed files with 9 additions and 1 deletions
  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());
     ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs,
                                         &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;
 
     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 %= 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
     struct X { int a, b; };
     volatile auto [x, y] = X{1, 2}; // cxx20-warning {{volatile qualifier in structured binding declaration is deprecated}}