[cfe-commits] r143977 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/Misc/integer-literal-printing.cpp
Richard Trieu
rtrieu at google.com
Mon Nov 7 10:40:31 PST 2011
Author: rtrieu
Date: Mon Nov 7 12:40:31 2011
New Revision: 143977
URL: http://llvm.org/viewvc/llvm-project?rev=143977&view=rev
Log:
Add support for printing integer literals of type short, unsigned short,
__int128_t and __uint128_t. Short and unsigned short integer literals support
is only to work around a crasher as reported in PR11179 and will be removed
once Clang no longer builds short integer literals.
Added:
cfe/trunk/test/Misc/integer-literal-printing.cpp
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=143977&r1=143976&r2=143977&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Nov 7 12:40:31 2011
@@ -675,12 +675,19 @@
// Emit suffixes. Integer literals are always a builtin integer type.
switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
default: llvm_unreachable("Unexpected type for integer literal!");
+ // FIXME: The Short and UShort cases are to handle cases where a short
+ // integeral literal is formed during template instantiation. They should
+ // be removed when template instantiation no longer needs integer literals.
+ case BuiltinType::Short:
+ case BuiltinType::UShort:
case BuiltinType::Int: break; // no suffix.
case BuiltinType::UInt: OS << 'U'; break;
case BuiltinType::Long: OS << 'L'; break;
case BuiltinType::ULong: OS << "UL"; break;
case BuiltinType::LongLong: OS << "LL"; break;
case BuiltinType::ULongLong: OS << "ULL"; break;
+ case BuiltinType::Int128: OS << "i128"; break;
+ case BuiltinType::UInt128: OS << "Ui128"; break;
}
}
void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
Added: cfe/trunk/test/Misc/integer-literal-printing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/integer-literal-printing.cpp?rev=143977&view=auto
==============================================================================
--- cfe/trunk/test/Misc/integer-literal-printing.cpp (added)
+++ cfe/trunk/test/Misc/integer-literal-printing.cpp Mon Nov 7 12:40:31 2011
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// PR11179
+template <short T> class Type1 {};
+template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type1<-42>' to 'Type1<-42> &' for 1st argument;}}
+
+template <unsigned short T> class Type2 {};
+template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type2<42>' to 'Type2<42> &' for 1st argument;}}
+
+template <__int128_t T> class Type3 {};
+template <__int128_t T> void Function3(Type3<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type3<-42>' to 'Type3<-42i128> &' for 1st argument;}}
+
+template <__uint128_t T> class Type4 {};
+template <__uint128_t T> void Function4(Type4<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type4<42>' to 'Type4<42Ui128> &' for 1st argument;}}
+
+void Function() {
+ Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}}
+ Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}}
+ Function3(Type3<-42>()); // expected-error{{no matching function for call to 'Function3'}}
+ Function4(Type4<42>()); // expected-error{{no matching function for call to 'Function4'}}
+}
More information about the cfe-commits
mailing list