[PATCH] D34198: Fix __has_trivial_destructor crash when the type is incomplete with unknown array bounds.

Puneetha K via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 14 03:24:08 PDT 2017


puneetha updated this revision to Diff 102516.
puneetha added a comment.

Incorrectly rejecting __is_destructible queries on arrays of unknown bound of incomplete types.


https://reviews.llvm.org/D34198

Files:
  lib/Sema/SemaExprCXX.cpp


Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4101,6 +4101,11 @@
   case UTT_IsDestructible:
   case UTT_IsNothrowDestructible:
   case UTT_IsTriviallyDestructible:
+    if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+      return true;
+
+    return !S.RequireCompleteType(
+        Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   // Per the GCC type traits documentation, the same constraints apply to these.
   case UTT_HasNothrowAssign:
   case UTT_HasNothrowMoveAssign:
@@ -4113,9 +4118,15 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-    if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+    if(ArgTy->isVoidType())
       return true;
 
+    if (ArgTy->isIncompleteArrayType()) {
+      QualType ElTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
+      if (!ElTy->isIncompleteType())
+        return true;
+    }
+
     return !S.RequireCompleteType(
         Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34198.102516.patch
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170614/93a66a43/attachment.bin>


More information about the cfe-commits mailing list