From e9823fab83ac05476ce3bdcd1dd0559d24bc4d23 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 17 Dec 2009 11:35:26 +0000 Subject: implement PR3962: diagnose more faulty cases of usage of the restrict qualifier. this also removes a FIXME llvm-svn: 91601 --- clang/lib/Sema/SemaDecl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ee4bd226768..6ed9f7a772b 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1445,7 +1445,6 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) { Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { // FIXME: Error on auto/register at file scope // FIXME: Error on inline/virtual/explicit - // FIXME: Error on invalid restrict // FIXME: Warn on useless __thread // FIXME: Warn on useless const/volatile // FIXME: Warn on useless static/extern/typedef/private_extern/mutable @@ -1467,6 +1466,15 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { Tag = dyn_cast(TagD); } + if (unsigned TypeQuals = DS.getTypeQualifiers()) { + // Enforce C99 6.7.3p2: "Types other than pointer types derived from object + // or incomplete types shall not be restrict-qualified." + if (TypeQuals & DeclSpec::TQ_restrict) + Diag(DS.getRestrictSpecLoc(), + diag::err_typecheck_invalid_restrict_not_pointer_noarg) + << DS.getSourceRange(); + } + if (DS.isFriendSpecified()) { // If we're dealing with a class template decl, assume that the // template routines are handling it. -- cgit v1.2.3