diff mbox

Use CAN_HAVE_LOCATION_P in EXPR_LOCATION

Message ID 4FB26E5A.1090400@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 15, 2012, 2:55 p.m. UTC
Hi,

this is something I noticed when looking into more EXPR_LOC_OR_HERE uses 
in the C++ front-end: I don't think we want to crash if EXPR_LOC_OR_HERE 
is passed a NULL_TREE. Tested x86_64-linux.

Thanks,
Paolo.

///////////////////
2012-05-15  Paolo Carlini  <paolo.carlini@oracle.com>

    	* tree.h (EXPR_LOCATION): Use CAN_HAVE_LOCATION_P.

Comments

Jason Merrill May 15, 2012, 7:17 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: tree.h
===================================================================
--- tree.h	(revision 187501)
+++ tree.h	(working copy)
@@ -1684,7 +1684,7 @@  struct GTY(()) tree_constructor {
    decls and constants can be shared among multiple locations, so
    return nothing.  */
 #define EXPR_LOCATION(NODE) \
-  (EXPR_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION)
+  (CAN_HAVE_LOCATION_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION)
 #define SET_EXPR_LOCATION(NODE, LOCUS) EXPR_CHECK ((NODE))->exp.locus = (LOCUS)
 #define EXPR_HAS_LOCATION(NODE) (EXPR_LOCATION (NODE) != UNKNOWN_LOCATION)
 #define EXPR_LOC_OR_HERE(NODE) (EXPR_HAS_LOCATION (NODE) ? (NODE)->exp.locus : input_location)