[PATCH] D144285: [Clang] Implement CWG2518 - static_assert(false)

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 17 10:56:16 PST 2023


erichkeane added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16805
+    // definition, the declaration has no effect.
+    bool InTemplateDefinition = getLangOpts().CPlusPlus && getTemplateDepth(getCurScope()) != 0;
+
----------------
Hmm... interesting way to calculate template depth, I wasn't aware of that one.  Does this cause problems in 'a template caused another template to instantiate' sorta thing? 

Also, is the "CPlusPlus" test here necessary?


================
Comment at: clang/test/SemaTemplate/instantiate-var-template.cpp:34
   template<typename T> void f() {
-    static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // expected-error {{static assertion failed due to requirement 'a<sizeof (sizeof (f(type-parameter-0-0())))> == 0'}} \
-                                                       // expected-note {{evaluates to '1 == 0'}}
+    static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // fixme: can we check a var is dependant?
   }
----------------
You should be able to instantiate this template later, and probably what we now have to do.  Also, 'dependent' is the spelling in this case, 'dependant' is something different :)


================
Comment at: clang/test/SemaTemplate/instantiation-dependence.cpp:41
     static_assert(!__is_void(indirect_void_t<T>)); // "ok", dependent
-    static_assert(!__is_void(void_t<T>)); // expected-error {{failed}}
+    static_assert(!__is_void(void_t<T>)); // fixme: can we check a type is dependant?
   }
----------------
This one is probably a bigger pain to test, and I don't have a good idea.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144285/new/

https://reviews.llvm.org/D144285



More information about the cfe-commits mailing list