forked from wangliu-iscas/gcc-patch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
c++: Implement __is_bounded_array built-in trait
This patch implements built-in trait for std::is_bounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_bounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_BOUNDED_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_bounded_array. * g++.dg/ext/is_bounded_array.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
- Loading branch information
1 parent
cd0d216
commit 2d5449b
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// { dg-do compile { target c++11 } } | ||
|
||
#include <testsuite_tr1.h> | ||
|
||
using namespace __gnu_test; | ||
|
||
#define SA(X) static_assert((X),#X) | ||
|
||
#define SA_TEST_CONST(TRAIT, TYPE, EXPECT) \ | ||
SA(TRAIT(TYPE) == EXPECT); \ | ||
SA(TRAIT(const TYPE) == EXPECT) | ||
|
||
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ | ||
SA(TRAIT(TYPE) == EXPECT); \ | ||
SA(TRAIT(const TYPE) == EXPECT); \ | ||
SA(TRAIT(volatile TYPE) == EXPECT); \ | ||
SA(TRAIT(const volatile TYPE) == EXPECT) | ||
|
||
SA_TEST_CATEGORY(__is_bounded_array, int[2], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, int[], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, int[][3], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, float*[2], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, float*[], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, float*[2][3], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, float*[][3], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, ClassType[2], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, ClassType[], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][3], true); | ||
SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false); | ||
SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false); | ||
SA_TEST_CONST(__is_bounded_array, int(&)[], false); | ||
|
||
// Sanity check. | ||
SA_TEST_CATEGORY(__is_bounded_array, ClassType, false); | ||
SA_TEST_CONST(__is_bounded_array, void(), false); |