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_unbounded_array built-in trait
This patch implements built-in trait for std::is_unbounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_unbounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_UNBOUNDED_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_unbounded_array. * g++.dg/ext/is_unbounded_array.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
- Loading branch information
1 parent
04aa840
commit 11ed329
Showing
5 changed files
with
48 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,37 @@ | ||
// { dg-do compile { target c++11 } } | ||
|
||
#include <testsuite_tr1.h> | ||
|
||
using namespace __gnu_test; | ||
|
||
#define SA(X) static_assert((X),#X) | ||
|
||
#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_unbounded_array, int[2], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int[], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int[2][3], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int[][3], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, float*[2], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, float*[], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, float*[2][3], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, float*[][3], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, ClassType[], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2][3], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, ClassType[][3], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[2][3], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[][3], true); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int(*)[2], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int(*)[], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int(&)[2], false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, int(&)[], false); | ||
|
||
// Sanity check. | ||
SA_TEST_CATEGORY(__is_unbounded_array, ClassType, false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass, false); | ||
SA_TEST_CATEGORY(__is_unbounded_array, IncompleteUnion, false); |