forked from OSchip/llvm-project
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
This commit is contained in:
parent
c8dd6ccc8a
commit
d60bbcee98
|
@ -6245,7 +6245,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
|
||||||
// -- a predefined __func__ variable
|
// -- a predefined __func__ variable
|
||||||
if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) {
|
if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) {
|
||||||
if (isa<CXXUuidofExpr>(E)) {
|
if (isa<CXXUuidofExpr>(E)) {
|
||||||
Converted = TemplateArgument(const_cast<Expr*>(E));
|
Converted = TemplateArgument(ArgResult.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
|
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
|
// 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 {
|
typedef struct _GUID {
|
||||||
unsigned long Data1;
|
unsigned long Data1;
|
||||||
|
@ -92,4 +93,16 @@ class __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
|
||||||
// the previous case).
|
// the previous case).
|
||||||
[uuid("000000A0-0000-0000-C000-000000000049"),
|
[uuid("000000A0-0000-0000-C000-000000000049"),
|
||||||
uuid("000000A0-0000-0000-C000-000000000049")] class C10;
|
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)>();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue