From: Jason Merrill Date: Fri, 13 Oct 2017 19:03:41 +0000 (-0400) Subject: PR c++/82357 - bit-field in template X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c9c546b9d321b34fd02d2cab8d020297dd7686a;p=gcc.git PR c++/82357 - bit-field in template * tree.c (cp_stabilize_reference): Just return a NON_DEPENDENT_EXPR. From-SVN: r253739 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c22583554e5..2b6e3b68b3c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-10-13 Jason Merrill + + PR c++/82357 - bit-field in template + * tree.c (cp_stabilize_reference): Just return a NON_DEPENDENT_EXPR. + 2017-10-13 David Malcolm * cp-tree.h (maybe_show_extern_c_location): New decl. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e21ff6a1572..366f46f1506 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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 index 00000000000..4927b7ab144 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/bitfield4.C @@ -0,0 +1,6 @@ +// PR c++/82357 + +template 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 index 00000000000..2f46c7189eb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/cast4.C @@ -0,0 +1,4 @@ +template void f() +{ + static_cast(42); // { dg-error "static_cast" } +}