[PATCH] D31637: [Sema] Implement LWG 2015 for the builtin type-traits.

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 3 18:50:25 PDT 2017


EricWF updated this revision to Diff 93985.
EricWF edited the summary of this revision.

https://reviews.llvm.org/D31637

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits-incomplete.cpp


Index: test/SemaCXX/type-traits-incomplete.cpp
===================================================================
--- test/SemaCXX/type-traits-incomplete.cpp
+++ test/SemaCXX/type-traits-incomplete.cpp
@@ -1,8 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
 
-struct S; // expected-note 2 {{forward declaration of 'S'}}
+struct S; // expected-note 5 {{forward declaration of 'S'}}
+typedef S SAr[10];
+typedef S SArNB[];
+typedef S SArMB[10][2];
+
+struct C {};
 
 void f() {
   __is_pod(S); // expected-error{{incomplete type 'S' used in type trait expression}}
   __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[10]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[10][2]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[][10]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  (void)__is_pod(C[]);
+  (void)__is_pod(C[][10]);
+  (void)__is_pod(void); // OK
+  (void)__is_pod(const volatile void); // OK
 }
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4081,10 +4081,11 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-    // Arrays of unknown bound are expressly allowed.
-    QualType ElTy = ArgTy;
-    if (ArgTy->isIncompleteArrayType())
-      ElTy = S.Context.getAsArrayType(ArgTy)->getElementType();
+    // C++14 [meta.unary.prop]
+    //   remove_all_extents_t<T> shall be a complete type or
+    //   (possibly cv-qualified) void.
+    // See LWG 2015
+    QualType ElTy = S.Context.getBaseElementType(ArgTy);
 
     // The void type is expressly allowed.
     if (ElTy->isVoidType())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31637.93985.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170404/43f61d6a/attachment-0001.bin>


More information about the cfe-commits mailing list