// A class is abstract if at least one function is pure virtual.
cast<CXXRecordDecl>(CurContext)->setAbstract(true);
- } else {
+ } else if (!Method->isInvalidDecl()) {
Diag(Method->getLocation(), diag::err_non_virtual_pure)
<< Method->getDeclName() << Init->getSourceRange();
Method->setInvalidDecl();
/// well-formedness, issuing any diagnostics required. Returns true if
/// the constructor declarator is invalid.
bool Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
- if (Constructor->isInvalidDecl())
+ CXXRecordDecl *ClassDecl
+ = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
+ if (!ClassDecl)
return true;
- CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Constructor->getDeclContext());
- bool Invalid = false;
+ bool Invalid = Constructor->isInvalidDecl();
// C++ [class.copy]p3:
// A declaration of a constructor for a class X is ill-formed if
// its first parameter is of type (optionally cv-qualified) X and
// either there are no other parameters or else all other
// parameters have default arguments.
- if ((Constructor->getNumParams() == 1) ||
- (Constructor->getNumParams() > 1 &&
- Constructor->getParamDecl(1)->getDefaultArg() != 0)) {
+ if (!Constructor->isInvalidDecl() &&
+ ((Constructor->getNumParams() == 1) ||
+ (Constructor->getNumParams() > 1 &&
+ Constructor->getParamDecl(1)->getDefaultArg() != 0))) {
QualType ParamType = Constructor->getParamDecl(0)->getType();
QualType ClassTy = Context.getTagDeclType(ClassDecl);
if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
((Foo))(INT); // expected-error{{cannot be redeclared}}
- Foo(Foo foo, int i = 17, int j = 42); // expected-error {{copy constructor must pass its first argument by reference}}
+ Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}}
static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}}
virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}}