[cfe-commits] r54600 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/va_arg_x86_64.c
Eli Friedman
eli.friedman at gmail.com
Sat Aug 9 16:32:41 PDT 2008
Author: efriedma
Date: Sat Aug 9 18:32:40 2008
New Revision: 54600
URL: http://llvm.org/viewvc/llvm-project?rev=54600&view=rev
Log:
Fix for PR2631; make va_arg work correctly on x86-64.
Added:
cfe/trunk/test/Sema/va_arg_x86_64.c
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=54600&r1=54599&r2=54600&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Aug 9 18:32:40 2008
@@ -2604,9 +2604,16 @@
QualType T = QualType::getFromOpaquePtr(type);
InitBuiltinVaListType();
-
- if (CheckAssignmentConstraints(Context.getBuiltinVaListType(), E->getType())
- != Compatible)
+
+ // Get the va_list type
+ QualType VaListType = Context.getBuiltinVaListType();
+ // Deal with implicit array decay; for example, on x86-64,
+ // va_list is an array, but it's supposed to decay to
+ // a pointer for va_arg.
+ if (VaListType->isArrayType())
+ VaListType = Context.getArrayDecayedType(VaListType);
+
+ if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible)
return Diag(E->getLocStart(),
diag::err_first_argument_to_va_arg_not_of_type_va_list,
E->getType().getAsString(),
Added: cfe/trunk/test/Sema/va_arg_x86_64.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/va_arg_x86_64.c?rev=54600&view=auto
==============================================================================
--- cfe/trunk/test/Sema/va_arg_x86_64.c (added)
+++ cfe/trunk/test/Sema/va_arg_x86_64.c Sat Aug 9 18:32:40 2008
@@ -0,0 +1,6 @@
+// RUN: clang -fsyntax-only -verify -triple=x86_64-unknown-freebsd7.0 %s
+
+char* foo(char *fmt, __builtin_va_list ap)
+{
+ return __builtin_va_arg((ap), char *);
+}
More information about the cfe-commits
mailing list