unsigned TypeQuals, bool hasExceptionSpec,
bool hasAnyExceptionSpec, unsigned NumExs,
const QualType *ExArray, bool NoReturn) {
+ if (LangOpts.CPlusPlus) {
+ for (unsigned i = 0; i != NumArgs; ++i)
+ assert(!ArgArray[i].getCVRQualifiers() &&
+ "C++ arguments can't have toplevel CVR qualifiers!");
+ }
+
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
void DiagnoseMissingMember(SourceLocation MemberLoc, DeclarationName Member,
NestedNameSpecifier *NNS, SourceRange Range);
+ /// adjustFunctionParamType - Converts the type of a function parameter to a
+ // type that can be passed as an argument type to
+ /// ASTContext::getFunctionType.
+ ///
+ /// C++ [dcl.fct]p3: "...Any cv-qualifier modifying a parameter type is
+ /// deleted. Such cv-qualifiers affect only the definition of the parameter
+ /// within the body of the function; they do not affect the function type.
+ QualType adjustFunctionParamType(QualType T) const {
+ if (!Context.getLangOptions().CPlusPlus)
+ return T;
+
+ return T.getUnqualifiedType();
+ }
//===--------------------------------------------------------------------===//
// Extra semantic analysis beyond the C type system
private:
Invalid = true;
}
- ParamTypes[Idx] = ParamType;
+ ParamTypes[Idx] = adjustFunctionParamType(ParamType);
}
if (Invalid)
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
ParmVarDecl *Param = FTI.ArgInfo[i].Param.getAs<ParmVarDecl>();
- if (Param)
- ArgTys.push_back(Param->getType());
+ if (Param) {
+ QualType ArgTy = adjustFunctionParamType(Param->getType());
+
+ ArgTys.push_back(ArgTy);
+ }
}
SourceTy = Context.getFunctionType(SourceTy, ArgTys.data(),
ArgTys.size(),
}
}
- ArgTys.push_back(ArgTy);
+ ArgTys.push_back(adjustFunctionParamType(ArgTy));
}
llvm::SmallVector<QualType, 4> Exceptions;
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+void f(int) { } // expected-note {{previous definition is here}}
+void f(const int) { } // expected-error {{redefinition of 'f'}}
\ No newline at end of file