summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-05-17 15:26:37 +0000
committerNico Weber <nicolasweber@gmx.de>2018-05-17 15:26:37 +0000
commitd60bbcee98a89e9fd2fa1ee0c0348a08481aa1a0 (patch)
treebf42bfb53bd9dcd33dc06fa72165308006419609
parentc8dd6ccc8a358273114ef7e6f19ad59f6258048c (diff)
downloadbcm5719-llvm-d60bbcee98a89e9fd2fa1ee0c0348a08481aa1a0.tar.gz
bcm5719-llvm-d60bbcee98a89e9fd2fa1ee0c0348a08481aa1a0.zip
Fix __uuidof handling on non-type template parameter in C++17
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. https://reviews.llvm.org/D46820?id=146557 Patch from Taiju Tsuiki <tzik@chromium.org>! llvm-svn: 332614
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp2
-rw-r--r--clang/test/SemaCXX/ms-uuid.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a5f6b3f026f..8f316024cc6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6245,7 +6245,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// -- 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)
diff --git a/clang/test/SemaCXX/ms-uuid.cpp b/clang/test/SemaCXX/ms-uuid.cpp
index c26ea688e37..624ac0541db 100644
--- a/clang/test/SemaCXX/ms-uuid.cpp
+++ b/clang/test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s -Wno-deprecated-declarations
typedef struct _GUID {
unsigned long Data1;
@@ -92,4 +93,16 @@ class __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
// the previous case).
[uuid("000000A0-0000-0000-C000-000000000049"),
uuid("000000A0-0000-0000-C000-000000000049")] class C10;
+
+template <const GUID* p>
+void F1() {
+ // Regression test for PR24986. The given GUID should just work as a pointer.
+ const GUID* q = p;
+}
+
+void F2() {
+ // The UUID should work for a non-type template parameter.
+ F1<&__uuidof(C1)>();
+}
+
}
OpenPOWER on IntegriCloud