]> granicus.if.org Git - clang/commitdiff
PR14950: Fix out-of-bounds function parameter access in literal operator lookup.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Jan 2013 07:12:59 +0000 (07:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Jan 2013 07:12:59 +0000 (07:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172514 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLookup.cpp
test/SemaCXX/cxx11-user-defined-literals.cpp

index fdd33cf73aefafd2bddc83308ecae8c21ae66bc9..4ae27a4adc82f15f9be880091490dccddea76fa3 100644 (file)
@@ -2536,7 +2536,7 @@ Sema::LookupLiteralOperator(Scope *S, LookupResult &R,
       if (FD->getNumParams() == 1 &&
           FD->getParamDecl(0)->getType()->getAs<PointerType>())
         IsRaw = true;
-      else {
+      else if (FD->getNumParams() == ArgTys.size()) {
         IsExactMatch = true;
         for (unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
           QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
index 4bbecdb5b8e4a71916941c7815f998a94ac3c4d5..f8bbcd960fd32ba4671b6a004fdf52b182192cd7 100644 (file)
@@ -135,3 +135,9 @@ namespace Namespace {
   int _y(unsigned long long);
   int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}}
 }
+
+namespace PR14950 {
+  template<...> // expected-error {{expected template parameter}}
+  int operator"" _b(); // expected-error {{no function template matches function template specialization}}
+  int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator "" _b'}}
+}