+2018-03-01 Marek Polacek <polacek@redhat.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/84582
+ * semantics.c (force_paren_expr): Create a PAREN_EXPR when in
+ a template.
+ (maybe_undo_parenthesized_ref): Unwrap PAREN_EXPR.
+ * typeck2.c (store_init_value): Call fold_non_dependent_expr instead
+ of instantiate_non_dependent_expr.
+ * tree.c (lvalue_kind): Handle PAREN_EXPR like NON_DEPENDENT_EXPR.
+
2018-03-01 Nathan Sidwell <nathan@acm.org>
PR c++/84434
if (TREE_CODE (expr) == COMPONENT_REF
|| TREE_CODE (expr) == SCOPE_REF)
REF_PARENTHESIZED_P (expr) = true;
- else if (type_dependent_expression_p (expr))
+ else if (type_dependent_expression_p (expr)
+ || processing_template_decl)
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. */;
tree
maybe_undo_parenthesized_ref (tree t)
{
- if (cxx_dialect >= cxx14
- && INDIRECT_REF_P (t)
- && REF_PARENTHESIZED_P (t))
+ if (cxx_dialect < cxx14)
+ return t;
+
+ if (INDIRECT_REF_P (t) && REF_PARENTHESIZED_P (t))
{
t = TREE_OPERAND (t, 0);
while (TREE_CODE (t) == NON_LVALUE_EXPR
|| TREE_CODE (t) == STATIC_CAST_EXPR);
t = TREE_OPERAND (t, 0);
}
+ else if (TREE_CODE (t) == PAREN_EXPR)
+ t = TREE_OPERAND (t, 0);
return t;
}
return lvalue_kind (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref)));
case NON_DEPENDENT_EXPR:
+ case PAREN_EXPR:
return lvalue_kind (TREE_OPERAND (ref, 0));
case VIEW_CONVERT_EXPR:
if (decl_maybe_constant_var_p (decl) || TREE_STATIC (decl))
{
bool const_init;
- value = instantiate_non_dependent_expr (value);
+ value = fold_non_dependent_expr (value);
if (DECL_DECLARED_CONSTEXPR_P (decl)
|| (DECL_IN_AGGR_P (decl) && !DECL_VAR_DECLARED_INLINE_P (decl)))
{
+2018-03-01 Marek Polacek <polacek@redhat.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/84582
+ * g++.dg/cpp1y/auto-fn15.C: Extend testing.
+ * g++.dg/cpp1z/static1.C: New test.
+ * g++.dg/template/static37.C: New test.
+
2018-03-01 Nathan Sidwell <nathan@acm.org>
PR c++/84434
decltype(auto) h5(T t) { return t.i; }
template <class T>
decltype(auto) h6(T t) { return (t.i); }
+template <class T>
+decltype(auto) h7(T t) { return (i); }
int main()
{
same_type<decltype(h4()),int&>();
same_type<decltype(h5(a)),int>();
same_type<decltype(h6(a)),int&>();
+ same_type<decltype(h7(a)),int&>();
}
--- /dev/null
+// PR c++/84582
+// { dg-options -std=c++17 }
+
+class C {
+ static inline const long b = 0;
+ static inline const unsigned c = (b);
+};
+class D {
+ static inline const long b = 0;
+ static inline const unsigned c = b;
+};
+template <class> class A {
+ static inline const long b = 0;
+ static inline const unsigned c = (b);
+};
+template <class> class B {
+ static inline const long b = 0;
+ static inline const unsigned c = b;
+};
--- /dev/null
+// PR c++/84582
+
+class C {
+ static const long b = 0;
+ static const unsigned c = (b);
+};
+class D {
+ static const long b = 0;
+ static const unsigned c = b;
+};
+template <class> class A {
+ static const long b = 0;
+ static const unsigned c = (b);
+};
+template <class> class B {
+ static const long b = 0;
+ static const unsigned c = b;
+};