commit a5e9d513231728c3c52d956311fb9e5f06097184
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jul 30 14:55:57 2015 -0400
PR c++/67064
* semantics.c (force_paren_expr): Don't mess with hard register vars.
@@ -1660,6 +1660,8 @@ force_paren_expr (tree expr)
REF_PARENTHESIZED_P (expr) = true;
else if (type_dependent_expression_p (expr))
expr = build1 (PAREN_EXPR, TREE_TYPE (expr), expr);
+ else if (VAR_P (expr) && DECL_HARD_REGISTER (expr))
+ /* We can't bind a hard register variable to a reference. */;
else
{
cp_lvalue_kind kind = lvalue_kind (expr);
new file mode 100644
@@ -0,0 +1,18 @@
+// PR c++/67064
+// { dg-options "-w" }
+
+struct s {
+ int i;
+};
+
+register struct s *reg __asm__( "1" );
+
+int f(void)
+{
+ int i;
+
+ i = reg->i;
+ i = (reg)->i;
+
+ return i;
+}