diff mbox

[C++] Avoid reporting routines re-entered errors from finish_compound_literal

Message ID 4EEE5A2F.2020406@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 18, 2011, 9:25 p.m. UTC
Hi,

today I was having a look to c++/50855: for the testcase therein 
currently we are trying to just emit a "sorry, unimplemented: mangling 
constructor" and bail out. This is actually the case in 4_6-branch. In 
mainline, instead:

50855.C: In substitution of ‘template<class T> decltype ({256}) 
test(const T&) [with T = char]’:
50855.C:8:14: required from here
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ 
inside { } [-Wnarrowing]
50855.C: In function ‘int main()’:
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ 
inside { } [-Wnarrowing]
‘
Internal compiler error: Error reporting routines re-entered.

Now, I don't know if we can get to fixing the substantive issue in time 
for 4.7.0, but the patchlet below leads to (ie, similarly to 4_6-branch 
+ Wnarrowing):

50855.C: In instantiation of ‘decltype ({256}) test(const T&) [with T = 
char; decltype ({256}) = char]’:
50855.C:8:14: required from here
50855.C:2:6: warning: narrowing conversion of ‘256’ from ‘int’ to ‘char’ 
inside { } [-Wnarrowing]
50855.C:2:6: sorry, unimplemented: mangling constructor

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
2011-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* semantics.c (finish_compound_literal): Don't call check_narrowing
	if !(complain & tf_warning).

Comments

Jason Merrill Dec. 18, 2011, 10:24 p.m. UTC | #1
Let's use tf_warning_or_error instead of tf_warning; I don't think we 
ever pass tf_error without tf_warning, but we would want to check 
narrowing in that case if we ever did.  OK with that change.

Jason
diff mbox

Patch

Index: semantics.c
===================================================================
--- semantics.c	(revision 182459)
+++ semantics.c	(working copy)
@@ -2370,7 +2370,8 @@  finish_compound_literal (tree type, tree compound_
     return error_mark_node;
   compound_literal = reshape_init (type, compound_literal, complain);
   if (SCALAR_TYPE_P (type)
-      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal))
+      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)
+      && (complain & tf_warning))
     check_narrowing (type, compound_literal);
   if (TREE_CODE (type) == ARRAY_TYPE
       && TYPE_DOMAIN (type) == NULL_TREE)