diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-28 15:28:59 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-28 15:28:59 +0000 |
commit | a2b5e31cb19f4fd4680e7230cd5497f5ef09a438 (patch) | |
tree | 6fd57f409f89d403fd1223128378c58cf61cbd3c /clang/lib/Sema/SemaDecl.cpp | |
parent | 85cd7bac29a05dbab8b784eec5585ae1aa9564d7 (diff) | |
download | bcm5719-llvm-a2b5e31cb19f4fd4680e7230cd5497f5ef09a438.tar.gz bcm5719-llvm-a2b5e31cb19f4fd4680e7230cd5497f5ef09a438.zip |
Diagnose declarations that don't declare anything, and fix PR3020.
Examples:
int;
typedef int;
llvm-svn: 61454
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1f6cbc4f32c..875f0f19ad9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -773,10 +773,17 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) { /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with /// no declarator (e.g. "struct foo;") is parsed. Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { - // TODO: emit error on 'int;' or 'const enum foo;'. - // TODO: emit error on 'typedef int;' - // if (!DS.isMissingDeclaratorOk()) Diag(...); - + // FIXME: Isn't that more of a parser diagnostic than a sema diagnostic? + if (!DS.isMissingDeclaratorOk()) { + // FIXME: This diagnostic is emitted even when various previous + // errors occurred (see e.g. test/Sema/decl-invalid.c). However, + // DeclSpec has no means of communicating this information, and the + // responsible parser functions are quite far apart. + Diag(DS.getSourceRange().getBegin(), diag::err_no_declarators) + << DS.getSourceRange(); + return 0; + } + return dyn_cast_or_null<TagDecl>(static_cast<Decl *>(DS.getTypeRep())); } |