Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -6245,7 +6245,7 @@ // -- a predefined __func__ variable if (auto *E = Value.getLValueBase().dyn_cast()) { if (isa(E)) { - Converted = TemplateArgument(const_cast(E)); + Converted = TemplateArgument(ArgResult.get()); break; } Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref) Index: test/SemaCXX/ms-uuid.cpp =================================================================== --- test/SemaCXX/ms-uuid.cpp +++ 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 @@ // the previous case). [uuid("000000A0-0000-0000-C000-000000000049"), uuid("000000A0-0000-0000-C000-000000000049")] class C10; + +template +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)>(); +} + }