[PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 30 14:04:19 PDT 2016
aaron.ballman added inline comments.
================
Comment at: include/clang/Basic/AttrDocs.td:836
@@ +835,3 @@
+ let Content = [{
+This attribute specifies that the variable to which it is attached is intended
+to have a `constant initializer <http://en.cppreference.com/w/cpp/language/constant_initialization>`_
----------------
I don't think I ever heard whether this attribute was usable in C or not. I suspect it's not particularly needed in C. If that's true, we should state that in the documentation, and consider making the attribute a C++-only attribute?
================
Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++11 %s
----------------
Can you run this file through clang-format?
================
Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:7-9
@@ +6,5 @@
+
+#if !__has_feature(cxx_static_assert)
+#define static_assert(b_, m_) _Static_assert(b_, m_)
+#endif
+
----------------
This doesn't appear to be needed by the test.
================
Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:11
@@ +10,3 @@
+
+#define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
+
----------------
Hah, I've not seen `0+` before in a verify comment, that's a neat trick!
https://reviews.llvm.org/D23385
More information about the cfe-commits
mailing list