diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-06-28 03:01:15 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-06-28 03:01:15 +0000 |
commit | 3215398dc9dac2be19a9fc1df929e6b7d83eafca (patch) | |
tree | caa9ce1422d478e27e3e78767aef38253e2ff439 | |
parent | db7abf78dedc2ef6ccb42b3dac6ab330fe2ea469 (diff) |
Centralize the check for a tag definition in a Declarator::PrototypeContext inside GetTypeForDeclarator.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133985 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 9 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 7 |
3 files changed, 8 insertions, 18 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index adfc6f9501..25569be7b2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5971,21 +5971,13 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { DiagnoseFunctionSpecifiers(D); - TagDecl *OwnedDecl = 0; - TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S, &OwnedDecl); + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType parmDeclType = TInfo->getType(); if (getLangOptions().CPlusPlus) { // Check that there are no default arguments inside the type of this // parameter. CheckExtraCXXDefaultArguments(D); - - if (OwnedDecl && OwnedDecl->isDefinition()) { - // C++ [dcl.fct]p6: - // Types shall not be defined in return or parameter types. - Diag(OwnedDecl->getLocation(), diag::err_type_defined_in_param_type) - << Context.getTypeDeclType(OwnedDecl); - } // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1). if (D.getCXXScopeSpec().isSet()) { diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 3052b826b6..a3f53ec234 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2607,15 +2607,8 @@ Decl *Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { if (getLangOptions().CPlusPlus) CheckExtraCXXDefaultArguments(D); - TagDecl *OwnedDecl = 0; - TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S, &OwnedDecl); + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType ExceptionType = TInfo->getType(); - - if (getLangOptions().CPlusPlus && OwnedDecl && OwnedDecl->isDefinition()) { - // Objective-C++: Types shall not be defined in exception types. - Diag(OwnedDecl->getLocation(), diag::err_type_defined_in_param_type) - << Context.getTypeDeclType(OwnedDecl); - } VarDecl *New = BuildObjCExceptionDecl(TInfo, ExceptionType, D.getSourceRange().getBegin(), diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 489e50dc1c..a690530279 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2467,7 +2467,6 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, // or enumeration in a type-specifier-seq. switch (D.getContext()) { case Declarator::FileContext: - case Declarator::PrototypeContext: case Declarator::ObjCPrototypeContext: case Declarator::KNRTypeListContext: case Declarator::TypeNameContext: @@ -2481,6 +2480,12 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, case Declarator::AliasDeclContext: case Declarator::AliasTemplateContext: break; + case Declarator::PrototypeContext: + // C++ [dcl.fct]p6: + // Types shall not be defined in return or parameter types. + Diag(OwnedTagDeclInternal->getLocation(), diag::err_type_defined_in_param_type) + << Context.getTypeDeclType(OwnedTagDeclInternal); + break; case Declarator::ConditionContext: // C++ 6.4p2: // The type-specifier-seq shall not contain typedef and shall not declare |