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
d4ecca13
Commit
d4ecca13
authored
16 years ago
by
Daniel Dunbar
Browse files
Options
Downloads
Patches
Plain Diff
Fix IRgen of constant expressions referring to external/static
variables. - PR3657. llvm-svn: 65381
parent
c5437ea4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
clang/lib/CodeGen/CGExprConstant.cpp
+8
-5
8 additions, 5 deletions
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGen/const-init.c
+7
-0
7 additions, 0 deletions
clang/test/CodeGen/const-init.c
with
15 additions
and
5 deletions
clang/lib/CodeGen/CGExprConstant.cpp
+
8
−
5
View file @
d4ecca13
...
...
@@ -384,11 +384,14 @@ public:
if
(
const
FunctionDecl
*
FD
=
dyn_cast
<
FunctionDecl
>
(
Decl
))
return
CGM
.
GetAddrOfFunction
(
FD
);
if
(
const
VarDecl
*
VD
=
dyn_cast
<
VarDecl
>
(
Decl
))
{
if
(
VD
->
isFileVarDecl
())
return
CGM
.
GetAddrOfGlobalVar
(
VD
);
else
if
(
VD
->
isBlockVarDecl
())
{
assert
(
CGF
&&
"Can't access static local vars without CGF"
);
return
CGF
->
GetAddrOfStaticLocalVar
(
VD
);
// We can never refer to a variable with local storage.
if
(
!
VD
->
hasLocalStorage
())
{
if
(
VD
->
isFileVarDecl
()
||
VD
->
hasExternalStorage
())
return
CGM
.
GetAddrOfGlobalVar
(
VD
);
else
if
(
VD
->
isBlockVarDecl
())
{
assert
(
CGF
&&
"Can't access static local vars without CGF"
);
return
CGF
->
GetAddrOfStaticLocalVar
(
VD
);
}
}
}
break
;
...
...
This diff is collapsed.
Click to expand it.
clang/test/CodeGen/const-init.c
+
7
−
0
View file @
d4ecca13
...
...
@@ -79,4 +79,11 @@ long long g16 = (long long) ((void*) 0xFFFFFFFF);
// RUN: grep '@g17 = global i32\* @g15' %t &&
int
*
g17
=
(
int
*
)
((
long
)
&
g15
);
// RUN: grep '@g18.p = internal global \[1 x i32\*\] \[i32\* @g19\]' %t &&
// FIXME: Should we really accept this in Sema?
void
g18
(
void
)
{
extern
int
g19
;
static
int
*
p
[]
=
{
&
g19
};
}
// RUN: true
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