aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-05-31 16:31:35 -0400
committerJason Merrill <jason@redhat.com>2022-06-01 15:20:44 -0400
commite2e471d83d16449a325315c0f33dc52b90ce0fac (patch)
tree00d48a812db47add8febf8e3ef4ba4d78ba5c45e /gcc
parent72e52b88582e738c8b8bde5f85af63d3a0e15d2b (diff)
downloadgcc-e2e471d83d16449a325315c0f33dc52b90ce0fac.zip
gcc-e2e471d83d16449a325315c0f33dc52b90ce0fac.tar.gz
gcc-e2e471d83d16449a325315c0f33dc52b90ce0fac.tar.bz2
c++: auto and dependent member name [PR105734]
In r12-3643 I improved our handling of type names after . or -> when unqualified lookup doesn't find anything, but it needs to handle auto specially. PR c++/105734 gcc/cp/ChangeLog: * parser.cc (cp_parser_postfix_dot_deref_expression): Use typeof if the expression has auto type. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/auto57.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/parser.cc2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto57.C15
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 0eefa74..3fc7344 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -8262,7 +8262,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
tree type = TREE_TYPE (postfix_expression);
/* If we don't have a (type-dependent) object of class type, use
typeof to figure out the type of the object. */
- if (type == NULL_TREE)
+ if (type == NULL_TREE || is_auto (type))
type = finish_typeof (postfix_expression);
parser->context->object_type = type;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto57.C b/gcc/testsuite/g++.dg/cpp0x/auto57.C
new file mode 100644
index 0000000..fedcfde
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto57.C
@@ -0,0 +1,15 @@
+// PR c++/105734
+// { dg-do compile { target c++11 } }
+
+namespace N {
+ struct A { };
+ A f(A);
+}
+
+template <class T>
+void bar() {
+ auto m = f(T());
+ m.~A();
+}
+
+void foo() { bar<N::A>(); }