Author: erichkeane Date: 2023-09-21T13:28:04-07:00 New Revision: 6bcef543e3a31da26b0164ba4ed6e79e8f0a72c3
URL: https://github.com/llvm/llvm-project/commit/6bcef543e3a31da26b0164ba4ed6e79e8f0a72c3 DIFF: https://github.com/llvm/llvm-project/commit/6bcef543e3a31da26b0164ba4ed6e79e8f0a72c3.diff LOG: Ensure we disambiguate NTTP names when doing TemplateTree comparisons 835b99e4c did this when we printed the NTTPs while NOT doing a TemplateTree comparison, this does the same change for the TemplateTree mechanism as well, amking the diagnostics less confusing in these cases. Fixes: #66744 Added: clang/test/AST/ast-nttp-template-tree-compares.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/ASTDiagnostic.cpp clang/test/SemaCXX/cxx2a-nttp-printing.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 77aad0c9731bea1..477a40630f11097 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 f96a4fa3c35b0f9..7b0d5f9cc1a93d5 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 000000000000000..a767e385b8f0abc --- /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<auto, auto> struct divided_units : empty { }; +template<auto> struct quantity { }; // #QUANT + +void use() { + quantity<divided_units<metre{}, second{}>{}> q{}; + quantity<metre{}> q2 = q; + // expected-error@-1 {{no viable conversion from 'quantity<divided_units<metre{}, second{}>{{}}>' to 'quantity<metre{{}}>'}} + // expected-note@#QUANT {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'quantity<divided_units<metre{}, second{}>{}>' to 'const quantity<metre{{}}> &' for 1st argument}} + // expected-note@#QUANT {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'quantity<divided_units<metre{}, second{}>{}>' to 'quantity<metre{{}}> &&' for 1st argument}} +} + diff --git a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp index f535404dc69c47c..d03a5dd7dd6ad58 100644 --- a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp +++ b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp @@ -7,9 +7,9 @@ template <int N> struct Str { template <Str V> 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<Str<43>{"this nontype template argument is too long"}>' to 'ASCII<Str<52>{"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<Str<14>{{119, 97, 105, 116, 32, 97, 32, 115, 27, 99, 111, 110, 100, 0}}>' to 'ASCII<Str<32>{"this nttp argument is too short"}>'}} +void Meow(ASCII<"what|">); // expected-note {{no known conversion from 'ASCII<Str<8>{"what??!"}>' to 'ASCII<Str<6>{"what|"}>' for 1st argument}} void test_ascii() { ASCII<"this nontype template argument" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits