Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
f631997c
Commit
f631997c
authored
17 years ago
by
Steve Naroff
Browse files
Options
Downloads
Patches
Plain Diff
A much better fix for
http://llvm.org/bugs/show_bug.cgi?id=1987
. llvm-svn: 47103
parent
a4621f04
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
clang/Parse/Parser.cpp
+14
-3
14 additions, 3 deletions
clang/Parse/Parser.cpp
clang/include/clang/Basic/DiagnosticKinds.def
+2
-0
2 additions, 0 deletions
clang/include/clang/Basic/DiagnosticKinds.def
clang/test/Sema/declspec.c
+7
-3
7 additions, 3 deletions
clang/test/Sema/declspec.c
with
23 additions
and
6 deletions
clang/Parse/Parser.cpp
+
14
−
3
View file @
f631997c
...
...
@@ -367,9 +367,6 @@ Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() {
// Parse the common declaration-specifiers piece.
DeclSpec
DS
;
ParseDeclarationSpecifiers
(
DS
);
// If the decl specs are invalid, there is no need to continue.
if
(
DS
.
isInvalid
())
return
0
;
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
...
...
@@ -422,6 +419,20 @@ Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() {
}
else
if
(
DeclaratorInfo
.
isFunctionDeclarator
()
&&
(
Tok
.
is
(
tok
::
l_brace
)
||
// int X()
{}
isDeclarationSpecifier
()))
{
// int X(f) int f; {}
if
(
DS
.
getStorageClassSpec
()
==
DeclSpec
::
SCS_typedef
)
{
Diag
(
Tok
,
diag
::
err_function_declared_typedef
);
if
(
Tok
.
is
(
tok
::
l_brace
))
{
// This recovery skips the entire function body. It would be nice
// to simply call ParseFunctionDefintion() below, however Sema
// assumes the declarator represents a function, not a typedef.
ConsumeBrace
();
SkipUntil
(
tok
::
r_brace
,
true
);
}
else
{
SkipUntil
(
tok
::
semi
);
}
return
0
;
}
return
ParseFunctionDefinition
(
DeclaratorInfo
);
}
else
{
if
(
DeclaratorInfo
.
isFunctionDeclarator
())
...
...
This diff is collapsed.
Click to expand it.
clang/include/clang/Basic/DiagnosticKinds.def
+
2
−
0
View file @
f631997c
...
...
@@ -352,6 +352,8 @@ DIAG(err_expected_semi_decl_list, ERROR,
"expected ';' at end of declaration list")
DIAG(ext_expected_semi_decl_list, EXTENSION,
"expected ';' at end of declaration list")
DIAG(err_function_declared_typedef, ERROR,
"function definition declared 'typedef'")
DIAG(err_expected_fn_body, ERROR,
"expected function body after function declarator")
DIAG(err_expected_after_declarator, ERROR,
...
...
This diff is collapsed.
Click to expand it.
clang/test/Sema/declspec.c
+
7
−
3
View file @
f631997c
...
...
@@ -5,8 +5,12 @@ T foo(int n, int m) { } // expected-error {{cannot return array or function}}
void
foof
(
const
char
*
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
))),
barf
(
void
);
int
typedef
validTypeDecl
()
{
}
// expected-error {{function definition declared 'typedef'}}
struct
_zend_module_entry
{
}
typedef
struct
_zend_function_entry
{
}
// expected-error {{cannot combine with previous 'struct' declaration specifier}}
static
void
buggy
(
int
*
x
)
{
// expected-error {{cannot combine with previous 'typedef' declaration specifier}} \
// expected-error {{cannot combine with previous 'struct' declaration specifier}}
// expected-error {{expected '}'}}
static
void
buggy
(
int
*
x
)
{
}
// expected-error {{function definition declared 'typedef'}} \
// expected-error {{cannot combine with previous 'typedef' declaration specifier}} \
// expected-error {{cannot combine with previous 'struct' declaration specifier}}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment