From d918d4bc563aceaa2d45b9c38bf27c0dfbef393b Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 10 Jun 2015 10:37:21 -0400 Subject: [PATCH 14/16] Add test-tree.c to unittests gcc/testsuite/ChangeLog: * unittests/test-tree.c: New file. --- gcc/testsuite/unittests/test-tree.c | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 gcc/testsuite/unittests/test-tree.c diff --git a/gcc/testsuite/unittests/test-tree.c b/gcc/testsuite/unittests/test-tree.c new file mode 100644 index 0000000..39754af --- /dev/null +++ b/gcc/testsuite/unittests/test-tree.c @@ -0,0 +1,101 @@ +/* Unit tests for GCC's tree types. + Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "gtest/gtest.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "opts.h" +#include "signop.h" +#include "hash-set.h" +#include "fixed-value.h" +#include "alias.h" +#include "flags.h" +#include "symtab.h" +#include "tree-core.h" +#include "stor-layout.h" +#include "tree.h" +#include "stringpool.h" +#include "stor-layout.h" +#include "rtl.h" +#include "predict.h" +#include "vec.h" +#include "hashtab.h" +#include "hash-set.h" +#include "machmode.h" +#include "hard-reg-set.h" +#include "input.h" +#include "function.h" +#include "dominance.h" +#include "cfg.h" +#include "cfganal.h" +#include "basic-block.h" +#include "tree-ssa-alias.h" +#include "internal-fn.h" +#include "gimple-fold.h" +#include "gimple-expr.h" +#include "toplev.h" +#include "print-tree.h" +#include "tree-iterator.h" +#include "gimplify.h" +#include "tree-cfg.h" +#include "fold-const.h" + +namespace { + +/* Verify that integer constants are sane. */ + +TEST (tree_test, integer_constants) +{ + ASSERT_TRUE (integer_type_node != NULL); + EXPECT_TRUE (build_int_cst (integer_type_node, 0) != NULL); + + tree type = integer_type_node; + + tree zero = build_zero_cst (type); + EXPECT_EQ (INTEGER_CST, TREE_CODE (zero)); + EXPECT_EQ (type, TREE_TYPE (zero)); + + tree one = build_int_cst (type, 1); + EXPECT_EQ (INTEGER_CST, TREE_CODE (one)); + EXPECT_EQ (type, TREE_TYPE (zero)); +} + +/* Verify identifiers. */ + +TEST (tree_test, identifiers) +{ + tree identifier = get_identifier ("foo"); + EXPECT_EQ (3, IDENTIFIER_LENGTH (identifier)); + EXPECT_STREQ ("foo", IDENTIFIER_POINTER (identifier)); +} + +/* Verify LABEL_DECL. */ + +TEST (tree_test, labels) +{ + tree identifier = get_identifier ("err"); + tree label_decl = build_decl (UNKNOWN_LOCATION, LABEL_DECL, + identifier, void_type_node); + EXPECT_EQ (-1, LABEL_DECL_UID (label_decl)); + EXPECT_FALSE (FORCED_LABEL (label_decl)); +} + +} // anon namespace -- 1.8.5.3