summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/README1
-rw-r--r--gcc/testsuite/g++.dg/eh/goto1.C34
-rw-r--r--gcc/testsuite/g++.dg/ext/asm3.C2
-rw-r--r--gcc/testsuite/g++.dg/ext/label3.C39
-rw-r--r--gcc/testsuite/g++.dg/init/pmf1.C17
-rw-r--r--gcc/testsuite/g++.dg/opt/bool1.C25
-rw-r--r--gcc/testsuite/g++.dg/opt/cfg4.C45
-rw-r--r--gcc/testsuite/g++.dg/opt/crash1.C14
-rw-r--r--gcc/testsuite/g++.dg/opt/inline7.C7
-rw-r--r--gcc/testsuite/g++.dg/opt/nothrow1.C24
-rw-r--r--gcc/testsuite/g++.dg/opt/static4.C15
-rw-r--r--gcc/testsuite/g++.dg/parse/crash10.C2
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/20040317-1.C38
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/nothrow-1.C19
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/tree-ssa.exp36
-rw-r--r--gcc/testsuite/g++.dg/warn/Wswitch-1.C14
-rw-r--r--gcc/testsuite/g++.dg/warn/Wswitch-2.C8
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-5.C30
-rw-r--r--gcc/testsuite/g++.dg/warn/noeffect5.C8
19 files changed, 354 insertions, 24 deletions
diff --git a/gcc/testsuite/g++.dg/README b/gcc/testsuite/g++.dg/README
index 4e2e4ce9bbc..14b736e7a73 100644
--- a/gcc/testsuite/g++.dg/README
+++ b/gcc/testsuite/g++.dg/README
@@ -22,6 +22,7 @@ rtti Tests for run-time type identification (typeid, dynamic_cast, etc.)
template Tests for templates.
tc1 Tests for Technical Corrigendum 1 conformance.
tls Tests for support of thread-local data.
+tree-ssa Tests for Tree SSA optimizations.
warn Tests for compiler warnings.
other Tests that don't fit into one of the other categories.
diff --git a/gcc/testsuite/g++.dg/eh/goto1.C b/gcc/testsuite/g++.dg/eh/goto1.C
new file mode 100644
index 00000000000..f3e3e4216fb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/goto1.C
@@ -0,0 +1,34 @@
+extern "C" void abort ();
+
+static int count;
+
+struct S {
+ S() { ++count; }
+ ~S() { --count; }
+};
+
+int foo(int p)
+{
+ S s1;
+ {
+ S s2;
+ if (p)
+ goto L;
+ else
+ return 1;
+ }
+ foo (p);
+ L:
+ return 0;
+}
+
+int main()
+{
+ foo(0);
+ if (count != 0)
+ abort ();
+ foo(1);
+ if (count != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/ext/asm3.C b/gcc/testsuite/g++.dg/ext/asm3.C
index 699ab4c8252..5eff16ffe7c 100644
--- a/gcc/testsuite/g++.dg/ext/asm3.C
+++ b/gcc/testsuite/g++.dg/ext/asm3.C
@@ -8,6 +8,6 @@
int two(int in)
{
register int out;
- __asm__ ("" : "r" (out) : "r" (in)); // { dg-error "output operand" "" }
+ __asm__ ("" : "r" (out) : "r" (in)); // { dg-error "" "" }
return out;
}
diff --git a/gcc/testsuite/g++.dg/ext/label3.C b/gcc/testsuite/g++.dg/ext/label3.C
new file mode 100644
index 00000000000..604bfdc12c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/label3.C
@@ -0,0 +1,39 @@
+// Bug: we were removing the p = q assignment in dce, and then reinserting
+// it *after* the try/catch in out-of-ssa. Oops.
+
+// testcase reduced from libjava/interpret.cc.
+
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C" int printf (const char *, ...);
+
+bool b;
+
+int main()
+{
+ __label__ one, two, done;
+ void *labs[] = { &&one, &&two, &&done };
+ const void **q = (const void **)labs;
+ const void **p = q;
+
+ try
+ {
+ one:
+ printf ("one!\n");
+ if (b)
+ throw 42;
+ goto **p++;
+
+ two:
+ printf ("two!\n");
+ goto **p++;
+
+ done:
+ printf ("done!\n");
+ }
+ catch (int)
+ {
+ printf ("caught!\n");
+ }
+}
diff --git a/gcc/testsuite/g++.dg/init/pmf1.C b/gcc/testsuite/g++.dg/init/pmf1.C
new file mode 100644
index 00000000000..93c67bdd706
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/pmf1.C
@@ -0,0 +1,17 @@
+// PR c++/14089
+// { dg-do compile }
+//
+// C++ front end generated assignment between types that were not
+// compatible in any sense visible to the optimizers.
+
+struct pair {
+ typedef void (pair::*fp)();
+ int first;
+ pair::fp second;
+ pair(const int& a, const pair::fp& b) : first(a), second(b) {}
+ void f(const int& a, const pair::fp& b) { first = a; second = b; }
+};
+
+void op() {
+ pair(5, pair::fp());
+}
diff --git a/gcc/testsuite/g++.dg/opt/bool1.C b/gcc/testsuite/g++.dg/opt/bool1.C
new file mode 100644
index 00000000000..78cdebe32aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/bool1.C
@@ -0,0 +1,25 @@
+// PR opt/13869
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C" void abort ();
+
+int test ()
+{
+ bool my_bool = true;
+ for (int i = 0; i < 10; ++i)
+ {
+ if (!my_bool)
+ ;
+ else
+ my_bool = false;
+ };
+ return my_bool;
+}
+
+int main ()
+{
+ if (test ())
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/opt/cfg4.C b/gcc/testsuite/g++.dg/opt/cfg4.C
new file mode 100644
index 00000000000..94522ed4171
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/cfg4.C
@@ -0,0 +1,45 @@
+// PR optimization/13067
+// Origin: <bryner@brianryner.com>
+
+// This used to fail on the tree-ssa because of "out-of-ssa"
+// We might have a valid variable, but not a valid value when trying to find
+// useless statements created by out-of-ssa translation. In this case
+// val will be set to null, then later dereferenced. Bad.
+
+// { dg-do compile }
+// { dg-options "-Os" }
+
+
+
+struct Iterator
+{
+ Iterator operator++();
+};
+
+void GetChar(char* aChar);
+
+void foo(char aChar)
+{
+ char quote;
+ Iterator end;
+
+ while (1) {
+ if (aChar == '"')
+ GetChar(&aChar);
+
+ switch (aChar) {
+ case 'a':
+ ++end;
+ if (quote) {
+ if (quote == aChar) {
+ quote = 0;
+ }
+ } else {
+ quote = aChar;
+ }
+ }
+ }
+}
+
+
+
diff --git a/gcc/testsuite/g++.dg/opt/crash1.C b/gcc/testsuite/g++.dg/opt/crash1.C
new file mode 100644
index 00000000000..3526df1ddc9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/crash1.C
@@ -0,0 +1,14 @@
+// PR opt/13681
+// Here we have an out-of-range array index. We should not abort
+// trying to resolve the indirection back to an object.
+
+struct X {
+ double values[1];
+ double & foo (const unsigned int index) { return values[index]; }
+};
+
+void foo() {
+ double d;
+ X h1;
+ h1.foo(1) = d;
+}
diff --git a/gcc/testsuite/g++.dg/opt/inline7.C b/gcc/testsuite/g++.dg/opt/inline7.C
new file mode 100644
index 00000000000..7a873b01a31
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/inline7.C
@@ -0,0 +1,7 @@
+// PR c++/13543
+// { dg-do compile }
+// { dg-options "-O3" }
+
+struct basic_string { basic_string(const basic_string&); };
+basic_string operator+(const basic_string& lhs, char);
+void dumpNode(basic_string start) { dumpNode(start + 'a'); }
diff --git a/gcc/testsuite/g++.dg/opt/nothrow1.C b/gcc/testsuite/g++.dg/opt/nothrow1.C
new file mode 100644
index 00000000000..fb6c6040408
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/nothrow1.C
@@ -0,0 +1,24 @@
+// Test that the nothrow optimization works properly.
+// { dg-do compile }
+// { dg-options "-O -fdump-tree-optimized" }
+
+extern void blah() throw();
+
+int i, j, k;
+
+int main()
+{
+ try
+ {
+ ++i;
+ blah();
+ ++j;
+ }
+ catch (...)
+ {
+ return 42;
+ }
+}
+
+// The catch block should be optimized away.
+// { dg-final { scan-tree-dump-times "42" 0 "optimized" } }
diff --git a/gcc/testsuite/g++.dg/opt/static4.C b/gcc/testsuite/g++.dg/opt/static4.C
new file mode 100644
index 00000000000..87e11b02756
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/static4.C
@@ -0,0 +1,15 @@
+// PR 13898
+// Make sure the two X variables get assigned unique assembler names
+// if they are promoted to static storage.
+
+// { dg-do compile }
+
+int g(int i) {
+ if (i<1) {
+ const int x[3] = { 1,2,3 };
+ return x[i];
+ } else {
+ const int x[3] = { 4,5,6 };
+ return x[i];
+ }
+}
diff --git a/gcc/testsuite/g++.dg/parse/crash10.C b/gcc/testsuite/g++.dg/parse/crash10.C
index 878139fa0de..8212fcb5b29 100644
--- a/gcc/testsuite/g++.dg/parse/crash10.C
+++ b/gcc/testsuite/g++.dg/parse/crash10.C
@@ -5,6 +5,8 @@
// PR c++ 10953. ICE
+// { dg-bogus "" "" { target *-*-* } 14 }
+
class
{
typename:: // { dg-error "" "" }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C b/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C
new file mode 100644
index 00000000000..e2f3dcdceb8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+/* Test provided by Brian Ryner in PR 14511. The alias analyzer was
+ not handling structures containing arrays properly. In this case,
+ the static cast was introducing two assignments of the form
+
+ this_6->_vptr.IFoo = &_ZTV4IFoo[2];
+ this_4->_vptr.IFoo = &_ZTV3Bar[2];
+
+ which were not considered to alias each other because the alias
+ analyzer was not computing a proper pointer to array elements.
+ Another related bug was the type based alias analyzer not computing
+ alias relations to _ZTV4IFoo and _ZTV3Bar. Since those variables
+ are read-only, it was disregarding alias information for them.
+ So, the memory tags for the two 'this' variables were not being
+ marked as aliased with these variables. Resulting in the two
+ assignments not aliasing each other.
+
+ This was causing the optimizers to generate a call to the virtual
+ method Foo() instead of the overloaded version. */
+
+struct IFoo
+{
+ virtual void Foo() = 0;
+};
+
+struct Bar : IFoo
+{
+ void Foo() { }
+};
+
+int main(int argc, char **argv)
+{
+ Bar* b = new Bar();
+ static_cast<IFoo*>(b)->Foo();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/tree-ssa/nothrow-1.C b/gcc/testsuite/g++.dg/tree-ssa/nothrow-1.C
new file mode 100644
index 00000000000..6bd092977cd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/nothrow-1.C
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-cfg" } */
+double a;
+void t()
+{
+ a=1;
+}
+void t1(void);
+void abort(void);
+
+void q()
+{
+ try {
+ t();
+ }
+ catch (...) {abort();}
+}
+/* We shouldnotice nothrow attribute. */
+/* { dg-final { scan-tree-dump-times "exception" 0 "cfg"} } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/tree-ssa.exp b/gcc/testsuite/g++.dg/tree-ssa/tree-ssa.exp
new file mode 100644
index 00000000000..4788baa7838
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/tree-ssa.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2003 Free Software Foundation, Inc.
+
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CXXFLAGS
+if ![info exists DEFAULT_CXXFLAGS] then {
+ set DEFAULT_CXXFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[CS\]]] \
+ "" $DEFAULT_CXXFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/g++.dg/warn/Wswitch-1.C b/gcc/testsuite/g++.dg/warn/Wswitch-1.C
index e9fcb581817..4f44e12576e 100644
--- a/gcc/testsuite/g++.dg/warn/Wswitch-1.C
+++ b/gcc/testsuite/g++.dg/warn/Wswitch-1.C
@@ -19,17 +19,17 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
case 4: return 3;
default: break;
}
- switch (ei)
- { /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" { target *-*-* } 24 } */
- } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
+ switch (ei) /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */
+ { /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" { target *-*-* } 22 } */
+ }
switch (ej)
{
default: break;
}
- switch (ek)
+ switch (ek) /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
{
case e1: return 1;
- } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
+ }
switch (el)
{
case e1: return 1;
@@ -50,8 +50,8 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
{
case e1: return 1;
case e2: return 2;
- case 3: return 3;
- } /* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */
+ case 3: return 3; /* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */
+ }
switch (ep)
{
case e1: return 1;
diff --git a/gcc/testsuite/g++.dg/warn/Wswitch-2.C b/gcc/testsuite/g++.dg/warn/Wswitch-2.C
index b151e2310c7..9bc7d022b46 100644
--- a/gcc/testsuite/g++.dg/warn/Wswitch-2.C
+++ b/gcc/testsuite/g++.dg/warn/Wswitch-2.C
@@ -13,19 +13,19 @@ foo (enum e ei, int j)
case e3: return 2;
case e4: return 3;
} /* No warning here since e2 has the same value as e3. */
- switch (ei)
+ switch (ei) /* { dg-warning "enumeration value `e4' not handled in switch" "enum e4" } */
{
case e1: return 1;
case e2: return 2;
- } /* { dg-warning "enumeration value `e4' not handled in switch" "enum e4" } */
+ }
switch ((int) ei)
{
case e1: return 1;
} /* No warning here since switch condition was cast to int. */
- switch ((enum e) j)
+ switch ((enum e) j) /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */
{
case e2: return 1;
case e4: return 2;
- } /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */
+ }
return 0;
}
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-5.C b/gcc/testsuite/g++.dg/warn/Wunused-5.C
index 06d1a0516bc..8a8d9d280fc 100644
--- a/gcc/testsuite/g++.dg/warn/Wunused-5.C
+++ b/gcc/testsuite/g++.dg/warn/Wunused-5.C
@@ -1,13 +1,19 @@
-// PR c++/14199
-// { dg-options "-W -Wall -Wunused" }
-
-struct X {
- static void foo ();
-};
-
-template <typename T>
-void foo (const T &t) {
- t.foo();
-}
+/* PR opt/14288 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wall" } */
+
+volatile int sink;
+extern int foo(int);
+
+struct S
+{
+ int x;
-template void foo (const X &);
+ S() { x = foo(0); }
+ ~S() { sink = x; }
+};
+
+int test(bool p)
+{
+ return p ? foo(S().x) : 0; /* { dg-bogus "uninitialized" } */
+}
diff --git a/gcc/testsuite/g++.dg/warn/noeffect5.C b/gcc/testsuite/g++.dg/warn/noeffect5.C
new file mode 100644
index 00000000000..f0f4e74109a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/noeffect5.C
@@ -0,0 +1,8 @@
+/* PR middle-end/13325 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n);
+void f (void *dest, const void *src) {
+ memcpy (dest, src, 0);
+}