PR c++/82357 - bit-field in template
authorJason Merrill <jason@redhat.com>
Fri, 13 Oct 2017 19:03:41 +0000 (15:03 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Oct 2017 19:03:41 +0000 (15:03 -0400)
* tree.c (cp_stabilize_reference): Just return a NON_DEPENDENT_EXPR.

From-SVN: r253739

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/template/bitfield4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/cast4.C [new file with mode: 0644]

index c22583554e540f9fe5e00de72c6d072a6d7831d5..2b6e3b68b3c60876e8b1bc228623f590a36cc121 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/82357 - bit-field in template
+       * tree.c (cp_stabilize_reference): Just return a NON_DEPENDENT_EXPR.
+
 2017-10-13  David Malcolm  <dmalcolm@redhat.com>
 
        * cp-tree.h (maybe_show_extern_c_location): New decl.
index e21ff6a1572f853a2e772f09dcfb315cfbdb74f2..366f46f150656a882fdabfddebd2fcd7b25e129c 100644 (file)
@@ -333,6 +333,10 @@ cp_stabilize_reference (tree ref)
 {
   switch (TREE_CODE (ref))
     {
+    case NON_DEPENDENT_EXPR:
+      /* We aren't actually evaluating this.  */
+      return ref;
+
     /* We need to treat specially anything stabilize_reference doesn't
        handle specifically.  */
     case VAR_DECL:
diff --git a/gcc/testsuite/g++.dg/template/bitfield4.C b/gcc/testsuite/g++.dg/template/bitfield4.C
new file mode 100644 (file)
index 0000000..4927b7a
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/82357
+
+template <typename> struct A {
+  A() { x |= 0; }
+  int x : 8;
+};
diff --git a/gcc/testsuite/g++.dg/template/cast4.C b/gcc/testsuite/g++.dg/template/cast4.C
new file mode 100644 (file)
index 0000000..2f46c71
--- /dev/null
@@ -0,0 +1,4 @@
+template <class T> void f()
+{
+  static_cast<int&>(42);       // { dg-error "static_cast" }
+}