void created this revision. void added a reviewer: rsmith. Herald added a subscriber: cfe-commits.
Sugar, like ConstantExpr, causes an infinite expansion of the template object. Repository: rC Clang https://reviews.llvm.org/D57114 Files: lib/Sema/SemaTemplate.cpp test/CodeGenCXX/pr40395.cpp Index: test/CodeGenCXX/pr40395.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/pr40395.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++17 -fms-extensions -emit-llvm %s -o - -triple=x86_64-pc-win32 + +struct _GUID {}; +struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) B {}; + +template <const _GUID* piid> +struct A { + virtual void baz() { A<piid>(); } +}; + +void f() { + A<&__uuidof(B)>(); +} Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -6308,7 +6308,7 @@ // -- a predefined __func__ variable if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) { if (isa<CXXUuidofExpr>(E)) { - Converted = TemplateArgument(ArgResult.get()); + Converted = TemplateArgument(ArgResult.get()->IgnoreImpCasts()); break; } Diag(Arg->getBeginLoc(), diag::err_template_arg_not_decl_ref)
Index: test/CodeGenCXX/pr40395.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/pr40395.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++17 -fms-extensions -emit-llvm %s -o - -triple=x86_64-pc-win32 + +struct _GUID {}; +struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) B {}; + +template <const _GUID* piid> +struct A { + virtual void baz() { A<piid>(); } +}; + +void f() { + A<&__uuidof(B)>(); +} Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -6308,7 +6308,7 @@ // -- a predefined __func__ variable if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) { if (isa<CXXUuidofExpr>(E)) { - Converted = TemplateArgument(ArgResult.get()); + Converted = TemplateArgument(ArgResult.get()->IgnoreImpCasts()); break; } Diag(Arg->getBeginLoc(), diag::err_template_arg_not_decl_ref)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits