aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/union1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/template/union1.C')
-rw-r--r--gcc/testsuite/g++.dg/template/union1.C29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/union1.C b/gcc/testsuite/g++.dg/template/union1.C
new file mode 100644
index 00000000000..9019c38a285
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/union1.C
@@ -0,0 +1,29 @@
+// { dg-do run }
+
+extern "C" void abort ();
+
+void g (char c)
+{
+ if (c != 'a')
+ abort ();
+}
+
+void h (int i)
+{
+ if (i != 3)
+ abort ();
+}
+
+template <typename T> void f(T const &t)
+{
+ union { char c; T t_; };
+
+ c = 'a';
+ g (c);
+ t_ = 3;
+ h (t_);
+}
+
+int main () {
+ f (3);
+}