[PATCH] D77598: Integral template argument suffix printing
Aristotelis Koutsouridis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 15:16:57 PDT 2020
arisKoutsou created this revision.
arisKoutsou added a reviewer: v.g.vassilev.
arisKoutsou added a project: clang.
Herald added a subscriber: cfe-commits.
Added 'U' suffix for unsigned integral types and 'LL' for 64-bit types. Some tests fail to pass due to this change, because they expect a diagnostic with integral literal without suffix.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77598
Files:
clang/lib/AST/TemplateBase.cpp
clang/test/SemaTemplate/temp_arg_nontype.cpp
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===================================================================
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,24 @@
void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::type'?}}
void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>'; did you mean 'enable_if_char<'a'>::type'?}}
void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>'; did you mean 'enable_if_char<'a'>::type'?}}
+
+ template <int N> struct enable_if_int {};
+ template <> struct enable_if_int<1> { typedef int type; }; // expected-note{{'enable_if_int<1>::type' declared here}}
+ void test_int() { enable_if_int<2>::type i; } // expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+ template <unsigned int N> struct enable_if_unsigned_int {};
+ template <> struct enable_if_unsigned_int<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+ void test_unsigned_int() { enable_if_unsigned_int<2>::type i; } // expected-error{{enable_if_unsigned_int<2U>'; did you mean 'enable_if_unsigned_int<1>::type'?}}
+
+
+ template <unsigned long long N> struct enable_if_unsigned_long_long {};
+ template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_long_long<1>::type' declared here}}
+ void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } // expected-error{{enable_if_unsigned_long_long<2ULL>'; did you mean 'enable_if_unsigned_long_long<1>::type'?}}
+
+ template <long long N> struct enable_if_long_long {};
+ template <> struct enable_if_long_long<1> { typedef int type; }; // expected-note{{'enable_if_long_long<1>::type' declared here}}
+ void test_long_long() { enable_if_long_long<2>::type i; } // expected-error{{enable_if_long_long<2LL>'; did you mean 'enable_if_long_long<1>::type'?}}
+
}
namespace PR10579 {
Index: clang/lib/AST/TemplateBase.cpp
===================================================================
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -77,6 +77,12 @@
Out << "'";
} else {
Out << Val;
+ if (T->isBuiltinType()) {
+ if (Val.isUnsigned())
+ Out << "U";
+ if (Val.getBitWidth() == 64)
+ Out << "LL";
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77598.255504.patch
Type: text/x-patch
Size: 2563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/4f5489b3/attachment-0001.bin>
More information about the cfe-commits
mailing list