summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr49516.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/tree-ssa/pr49516.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/tree-ssa/pr49516.C')
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr49516.C86
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr49516.C b/gcc/testsuite/g++.dg/tree-ssa/pr49516.C
new file mode 100644
index 000000000..2c6fd0496
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr49516.C
@@ -0,0 +1,86 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern "C" void abort (void);
+
+typedef int int32;
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+typedef short int16;
+
+class Tp {
+ public:
+ Tp(int, const int segment, const int index) __attribute__((noinline));
+
+ inline bool operator==(const Tp& other) const;
+ inline bool operator!=(const Tp& other) const;
+ int GetType() const { return type_; }
+ int GetSegment() const { return segment_; }
+ int GetIndex() const { return index_; }
+ private:
+ inline static bool IsValidSegment(const int segment);
+ static const int kSegmentBits = 28;
+ static const int kTypeBits = 4;
+ static const int kMaxSegment = (1 << kSegmentBits) - 1;
+
+ union {
+
+ struct {
+ int32 index_;
+ uint32 segment_ : kSegmentBits;
+ uint32 type_ : kTypeBits;
+ };
+ struct {
+ int32 dummy_;
+ uint32 type_and_segment_;
+ };
+ uint64 value_;
+ };
+};
+
+Tp::Tp(int t, const int segment, const int index)
+ : index_(index), segment_(segment), type_(t) {}
+
+inline bool Tp::operator==(const Tp& other) const {
+ return value_ == other.value_;
+}
+inline bool Tp::operator!=(const Tp& other) const {
+ return value_ != other.value_;
+}
+
+class Range {
+ public:
+ inline Range(const Tp& position, const int count) __attribute__((always_inline));
+ inline Tp GetBeginTokenPosition() const;
+ inline Tp GetEndTokenPosition() const;
+ private:
+ Tp position_;
+ int count_;
+ int16 begin_index_;
+ int16 end_index_;
+};
+
+inline Range::Range(const Tp& position,
+ const int count)
+ : position_(position), count_(count), begin_index_(0), end_index_(0)
+ { }
+
+inline Tp Range::GetBeginTokenPosition() const {
+ return position_;
+}
+inline Tp Range::GetEndTokenPosition() const {
+ return Tp(position_.GetType(), position_.GetSegment(),
+ position_.GetIndex() + count_);
+}
+
+int main ()
+{
+ Range range(Tp(0, 0, 3), 0);
+ if (!(range.GetBeginTokenPosition() == Tp(0, 0, 3)))
+ abort ();
+
+ if (!(range.GetEndTokenPosition() == Tp(0, 0, 3)))
+ abort();
+
+ return 0;
+}