[llvm-commits] [llvm-gcc-4.2] r53566 - in /llvm-gcc-4.2/trunk/gcc/cp: cp-tree.h decl2.c lex.c pt.c
Chris Lattner
sabre at nondot.org
Mon Jul 14 11:06:32 PDT 2008
Author: lattner
Date: Mon Jul 14 13:06:32 2008
New Revision: 53566
URL: http://llvm.org/viewvc/llvm-project?rev=53566&view=rev
Log:
reapply Rafael's patch that I reverted, which is GPL2. His
commit message:
port http://gcc.gnu.org/viewcvs?view=rev&revision=127716
2007-08-22 Jason Merrill <jason at redhat.com>
PR c++/29365
* pt.c (outermost_tinst_level): New function.
* lex.c (in_main_input_context): New function.
* cp-tree.h: Declare it.
* decl2.c (constrain_class_visibility): Use it to avoid warning
about uses of the anonymous namespace in the main input file.
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080707/064926.html
Modified:
llvm-gcc-4.2/trunk/gcc/cp/cp-tree.h
llvm-gcc-4.2/trunk/gcc/cp/decl2.c
llvm-gcc-4.2/trunk/gcc/cp/lex.c
llvm-gcc-4.2/trunk/gcc/cp/pt.c
Modified: llvm-gcc-4.2/trunk/gcc/cp/cp-tree.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/cp-tree.h?rev=53566&r1=53565&r2=53566&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/cp-tree.h (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/cp-tree.h Mon Jul 14 13:06:32 2008
@@ -4122,6 +4122,7 @@
extern void yyhook (int);
extern bool cxx_init (void);
extern void cxx_finish (void);
+extern bool in_main_input_context (void);
/* in method.c */
extern void init_method (void);
@@ -4204,6 +4205,7 @@
extern bool reregister_specialization (tree, tree, tree);
extern tree fold_non_dependent_expr (tree);
extern bool explicit_class_specialization_p (tree);
+extern tree outermost_tinst_level (void);
/* in repo.c */
extern void init_repo (void);
Modified: llvm-gcc-4.2/trunk/gcc/cp/decl2.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/decl2.c?rev=53566&r1=53565&r2=53566&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/decl2.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/decl2.c Mon Jul 14 13:06:32 2008
@@ -1879,9 +1879,12 @@
int subvis = type_visibility (ftype);
if (subvis == VISIBILITY_ANON)
- warning (0, "\
+ {
+ if (!in_main_input_context ())
+ warning (0, "\
%qT has a field %qD whose type uses the anonymous namespace",
type, t);
+ }
else if (IS_AGGR_TYPE (ftype)
&& vis < VISIBILITY_HIDDEN
&& subvis >= VISIBILITY_HIDDEN)
@@ -1896,9 +1899,12 @@
int subvis = type_visibility (TREE_TYPE (t));
if (subvis == VISIBILITY_ANON)
- warning (0, "\
+ {
+ if (!in_main_input_context())
+ warning (0, "\
%qT has a base %qT whose type uses the anonymous namespace",
type, TREE_TYPE (t));
+ }
else if (vis < VISIBILITY_HIDDEN
&& subvis >= VISIBILITY_HIDDEN)
warning (OPT_Wattributes, "\
Modified: llvm-gcc-4.2/trunk/gcc/cp/lex.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/lex.c?rev=53566&r1=53565&r2=53566&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/lex.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/lex.c Mon Jul 14 13:06:32 2008
@@ -877,3 +877,18 @@
return t;
}
+
+/* Returns true if we are currently in the main source file, or in a
+ template instantiation started from the main source file. */
+
+bool
+in_main_input_context (void)
+{
+ tree tl = outermost_tinst_level();
+
+ if (tl)
+ return strcmp (main_input_filename,
+ LOCATION_FILE (TINST_LOCATION (tl))) == 0;
+ else
+ return strcmp (main_input_filename, input_filename) == 0;
+}
Modified: llvm-gcc-4.2/trunk/gcc/cp/pt.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/pt.c?rev=53566&r1=53565&r2=53566&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/pt.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/pt.c Mon Jul 14 13:06:32 2008
@@ -5288,6 +5288,15 @@
pop_tinst_level ();
}
+/* Returns the TINST_LEVEL which gives the original instantiation
+ context. */
+
+tree
+outermost_tinst_level (void)
+{
+ return tree_last (current_tinst_level);
+}
+
/* DECL is a friend FUNCTION_DECL or TEMPLATE_DECL. ARGS is the
vector of template arguments, as for tsubst.
More information about the llvm-commits
mailing list