[PATCH] D46820: Fix __uuidof handling on non-type template parameter in C++17
Taiju Tsuiki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 14 02:23:13 PDT 2018
tzik created this revision.
tzik added reviewers: rsmith, thakis.
Herald added a subscriber: cfe-commits.
Clang used to pass the base lvalue of a non-type template parameter
to the template instantiation phase when the base part is __uuidof
and it's running in C++17 mode.
However, that drops its LValuePath, and unintentionally transforms
`&__uuidof(...)` to `__uuidof(...)`.
This CL fixes that by passing whole expr. Fixes PR24986.
Repository:
rC Clang
https://reviews.llvm.org/D46820
Files:
lib/Sema/SemaTemplate.cpp
test/SemaCXX/PR24986.cpp
Index: test/SemaCXX/PR24986.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR24986.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -std=c++17 %s
+
+typedef struct _GUID {} GUID;
+
+template <const GUID* p>
+void f() {
+ const GUID* q = p;
+}
+
+void g() {
+ f<&__uuidof(0)>();
+}
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6197,7 +6197,7 @@
// -- a predefined __func__ variable
if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) {
if (isa<CXXUuidofExpr>(E)) {
- Converted = TemplateArgument(const_cast<Expr*>(E));
+ Converted = TemplateArgument(ArgResult.get());
break;
}
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46820.146557.patch
Type: text/x-patch
Size: 917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180514/ae8b26e0/attachment.bin>
More information about the cfe-commits
mailing list