[cfe-commits] r88759 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/vararg-default-arg.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Nov 13 20:43:10 PST 2009
Author: efriedma
Date: Fri Nov 13 22:43:10 2009
New Revision: 88759
URL: http://llvm.org/viewvc/llvm-project?rev=88759&view=rev
Log:
PR5462: Don't run off the edge of the argument array for vararg handling
when there are more parameters in the prototype than arguments to the call.
Added:
cfe/trunk/test/SemaCXX/vararg-default-arg.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=88759&r1=88758&r2=88759&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Nov 13 22:43:10 2009
@@ -2679,7 +2679,7 @@
CallType = VariadicMethod;
// Promote the arguments (C99 6.5.2.2p7).
- for (unsigned i = NumArgsInProto; i != NumArgs; i++) {
+ for (unsigned i = NumArgsInProto; i < NumArgs; i++) {
Expr *Arg = Args[i];
Invalid |= DefaultVariadicArgumentPromotion(Arg, CallType);
Call->setArg(i, Arg);
Added: cfe/trunk/test/SemaCXX/vararg-default-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vararg-default-arg.cpp?rev=88759&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/vararg-default-arg.cpp (added)
+++ cfe/trunk/test/SemaCXX/vararg-default-arg.cpp Fri Nov 13 22:43:10 2009
@@ -0,0 +1,10 @@
+// RUN: clang-cc %s -verify -fsyntax-only
+// PR5462
+
+void f1(void);
+void f2(const char * = __null, ...);
+
+void f1(void)
+{
+ f2();
+}
More information about the cfe-commits
mailing list