diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 77aad0c9731be..477a40630f110 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -335,6 +335,10 @@ Bug Fixes to C++ Support - Clang now no longer asserts when an UnresolvedLookupExpr is used as an expression requirement. (`#66612 https://github.com/llvm/llvm-project/issues/66612`) +- Clang now disambiguates NTTP types when printing diagnostics where the + NTTP types are compared with the 'diff' method. + (`#66744 https://github.com/llvm/llvm-project/issues/66744`) + Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ - Fixed an import failure of recursive friend class template. diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index f96a4fa3c35b0..7b0d5f9cc1a93 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1890,6 +1890,7 @@ class TemplateDiff { // FIXME: Diffing the APValue would be neat. // FIXME: Suppress this and use the full name of the declaration if the // parameter is a pointer or reference. + TPO->getType().getUnqualifiedType().print(OS, Policy); TPO->printAsInit(OS, Policy); return; } diff --git a/clang/test/AST/ast-nttp-template-tree-compares.cpp b/clang/test/AST/ast-nttp-template-tree-compares.cpp new file mode 100644 index 0000000000000..a767e385b8f0a --- /dev/null +++ b/clang/test/AST/ast-nttp-template-tree-compares.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s -o - + +struct empty {}; +struct metre : empty { }; +struct second : empty { }; +template struct divided_units : empty { }; +template struct quantity { }; // #QUANT + +void use() { + quantity{}> q{}; + quantity q2 = q; + // expected-error@-1 {{no viable conversion from 'quantity{{}}>' to 'quantity'}} + // expected-note@#QUANT {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'quantity{}>' to 'const quantity &' for 1st argument}} + // expected-note@#QUANT {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'quantity{}>' to 'quantity &&' for 1st argument}} +} + diff --git a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp index f535404dc69c4..d03a5dd7dd6ad 100644 --- a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp +++ b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp @@ -7,9 +7,9 @@ template struct Str { template class ASCII {}; -void Foo(ASCII<"this nontype template argument is too long to print">); // expected-note {{no known conversion from 'ASCII<{"this nontype template argument is too long"}>' to 'ASCII<{"this nontype template argument is too long to print"}>'}} -void Bar(ASCII<"this nttp argument is too short">); // expected-note {{no known conversion from 'ASCII<{{119, 97, 105, 116, 32, 97, 32, 115, 27, 99, 111, 110, 100, 0}}>' to 'ASCII<{"this nttp argument is too short"}>'}} -void Meow(ASCII<"what|">); // expected-note {{no known conversion from 'ASCII<{"what??!"}>' to 'ASCII<{"what|"}>' for 1st argument}} +void Foo(ASCII<"this nontype template argument is too long to print">); // expected-note {{no known conversion from 'ASCII{"this nontype template argument is too long"}>' to 'ASCII{"this nontype template argument is too long to print"}>'}} +void Bar(ASCII<"this nttp argument is too short">); // expected-note {{no known conversion from 'ASCII{{119, 97, 105, 116, 32, 97, 32, 115, 27, 99, 111, 110, 100, 0}}>' to 'ASCII{"this nttp argument is too short"}>'}} +void Meow(ASCII<"what|">); // expected-note {{no known conversion from 'ASCII{"what??!"}>' to 'ASCII{"what|"}>' for 1st argument}} void test_ascii() { ASCII<"this nontype template argument"