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 | a4ed0d8d75212dc01b4438829a4b0c846d99458d (patch) | |
tree | f72d8fcea1a6e4db4a415065d4e7d0eff5e96c96 /lib/Sema/SemaDecl.cpp | |
parent | 3c902ced87cd3e9994116485d7f28ca7f58b68e7 (diff) |
Diagnose declarations that don't declare anything, and fix PR3020.
Examples:
int;
typedef int;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1f6cbc4f32..875f0f19ad 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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())); } |