From 82b0001f79568199c7e5aa564f7ca9d43cc89d86 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 21 May 2013 23:29:46 +0000 Subject: [PATCH] Fix crash-on-invalid: only use TransformAddressOfOperand when transforming the operand of a unary address-of expression, not for *all* expressions! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182436 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TreeTransform.h | 6 +++++- test/SemaTemplate/instantiate-expr-5.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 95ea9bc4ec..7f3a7d7540 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -6320,7 +6320,11 @@ TreeTransform::TransformAddressOfOperand(Expr *E) { template ExprResult TreeTransform::TransformUnaryOperator(UnaryOperator *E) { - ExprResult SubExpr = TransformAddressOfOperand(E->getSubExpr()); + ExprResult SubExpr; + if (E->getOpcode() == UO_AddrOf) + SubExpr = TransformAddressOfOperand(E->getSubExpr()); + else + SubExpr = TransformExpr(E->getSubExpr()); if (SubExpr.isInvalid()) return ExprError(); diff --git a/test/SemaTemplate/instantiate-expr-5.cpp b/test/SemaTemplate/instantiate-expr-5.cpp index 13b7eae21f..c42c2a964d 100644 --- a/test/SemaTemplate/instantiate-expr-5.cpp +++ b/test/SemaTemplate/instantiate-expr-5.cpp @@ -36,3 +36,13 @@ namespace PR5880 { template void test_anon_union(); } + +namespace AddrOfClassMember { + template struct S { + int n; + static void f() { + +T::n; // expected-error {{invalid use of member}} + } + }; + void g() { S >::f(); } // expected-note {{in instantiation of}} +}