aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-10-16 17:31:08 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-10-16 17:31:08 +0000
commitc6f7345e44e079f373d6bdecaa06c7e06574dc27 (patch)
treec968ecc2fa20d9c4be92e73094c05e7e6ba257ff /lib/Sema/SemaType.cpp
parentfd0269d1945669355d52809f6c2e6065f77ff488 (diff)
In C++, an empty parameter list indicates a function that takes no parameters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57646 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 209a003988..a9e8b0117d 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -406,8 +406,14 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
}
if (FTI.NumArgs == 0) {
- // Simple void foo(), where the incoming T is the result type.
- T = Context.getFunctionTypeNoProto(T);
+ if (getLangOptions().CPlusPlus) {
+ // C++ 8.3.5p2: If the parameter-declaration-clause is empty, the
+ // function takes no arguments.
+ T = Context.getFunctionType(T, NULL, 0, FTI.isVariadic);
+ } else {
+ // Simple void foo(), where the incoming T is the result type.
+ T = Context.getFunctionTypeNoProto(T);
+ }
} else if (FTI.ArgInfo[0].Param == 0) {
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);